Skip to content

Commit

Permalink
ci: enable caching of github actions and use of uv
Browse files Browse the repository at this point in the history
* standardize python setup and ensure caching of dependencies
  • Loading branch information
clintonsteiner committed Feb 5, 2025
1 parent b7af1ba commit 190a66d
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 23 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/help-in-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Verify that README contains output of darker --help
run: uvx --from '.[flynt,isort]' darker --verify-readme
3 changes: 2 additions & 1 deletion .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: '3.x'
cache: 'pip'
- run: pip install 'isort>=5.0.1'
- uses: akaihola/lint-action@master
with:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- run: |
uv pip install --system -U \
black \
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Install dependencies for running Pylint
run: |
uv pip install --system -U \
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ jobs:
wheel-path: ${{ steps.get-darker-version.outputs.wheel-path }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Build wheel distribution
run: uv build --wheel
- name: Upload wheel for other jobs
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/pyupgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Ensure modern Python style using pyupgrade
run: |
uvx \
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/safety.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- run: uvx --from pip-tools pip-compile setup.cfg
- name: Check dependencies for known security vulnerabilities using Safety
run: uvx safety check --file requirements.txt
9 changes: 7 additions & 2 deletions .github/workflows/test-bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Make sure that `darkgray_bump_version` still finds all version strings
and that there's a future milestone on GitHub Issues.
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/test-future.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,27 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: 'master'
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Install dependencies
run: |
# strict dependency resolution added in pip 20.3
# CVE-2021-3572 fixed in pip 21.1
python -m pip install --upgrade 'pip>=21.1'
pip install \
uv pip install \
--constraint=constraints-future.txt \
--upgrade \
--upgrade-strategy=eager \
-e '.[test]'
uv python install
- name: Test with pytest
run: |
pytest
uv run pytest
- name: Note a possible Black incompatibility and required actions
if: failure()
shell: python
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ These features will be included in the next release:

Added
-----
- CI workflow, enable caching of packages via uv across all actions
- New exit codes 2 for file not found, 3 for invalid command line arguments, 4 for
missing dependencies and 123 for unknown failures.
- Display exit code in parentheses after error message.
Expand Down

0 comments on commit 190a66d

Please sign in to comment.