Skip to content

Commit 18921c6

Browse files
Nathan Simpsonclaude
andcommitted
feat: rewrite GitHub Actions CI/CD to be uv-native
CI: - Split into parallel lint, typecheck, and test jobs - Use astral-sh/setup-uv with caching - Derive Python version matrix from min_python_version - Use uv sync --locked to verify lockfile - Add concurrency group to cancel stale runs CD: - Replace pipx run build with uv build - Update to actions/upload-artifact@v4 and download-artifact@v4 - Simplify to only trigger on release published Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 893b1c9 commit 18921c6

2 files changed

Lines changed: 39 additions & 56 deletions

File tree

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
11
name: CD
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
94
release:
105
types:
116
- published
127

138
jobs:
149
dist:
15-
needs: [pre-commit]
16-
name: Distribution build
10+
name: Build distribution
1711
runs-on: ubuntu-latest
18-
1912
steps:
2013
- uses: actions/checkout@v4
2114
with:
2215
fetch-depth: 0
23-
24-
- name: Build sdist and wheel
25-
run: pipx run build
26-
27-
- uses: actions/upload-artifact@v3
16+
- uses: astral-sh/setup-uv@v5
2817
with:
18+
enable-cache: true
19+
- run: uv build
20+
- uses: actions/upload-artifact@v4
21+
with:
22+
name: dist
2923
path: dist
3024

31-
- name: Check products
32-
run: pipx run twine check dist/*
33-
3425
publish:
3526
needs: [dist]
3627
name: Publish to PyPI
3728
environment: pypi
3829
permissions:
3930
id-token: write
4031
runs-on: ubuntu-latest
41-
if: github.event_name == 'release' && github.event.action == 'published'
4232

4333
steps:
44-
- uses: actions/download-artifact@v3
34+
- uses: actions/download-artifact@v4
4535
with:
46-
name: artifact
36+
name: dist
4737
path: dist
48-
4938
- uses: pypa/gh-action-pypi-publish@release/v1
50-
if: github.event_name == 'release' && github.event.action == 'published'
5139
with:
5240
# Remove this line to publish to PyPI
5341
repository-url: https://test.pypi.org/legacy/
Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,49 @@
11
name: CI
22

33
on:
4-
workflow_dispatch:
5-
pull_request:
64
push:
7-
branches:
8-
- main
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %}
10+
cancel-in-progress: true
911

1012
jobs:
11-
pre-commit:
12-
name: Format + lint code
13+
lint:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v4
17+
- uses: astral-sh/setup-uv@v5
1618
with:
17-
fetch-depth: 0
18-
- uses: actions/setup-python@v4
19-
with:
20-
python-version: "3.x"
21-
- uses: pre-commit/action@v3.0.0
19+
enable-cache: true
20+
- run: uv run ruff check --output-format=github .
21+
- run: uv run ruff format --check .
22+
23+
typecheck:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: astral-sh/setup-uv@v5
2228
with:
23-
extra_args: --hook-stage manual --all-files
29+
enable-cache: true
30+
- run: uvx ty check
2431

25-
checks:
26-
name: {% raw %}Run tests for Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}{% endraw %}
27-
runs-on: {% raw %}${{ matrix.runs-on }}{% endraw %}
28-
needs: [pre-commit]
32+
test:
33+
runs-on: ubuntu-latest
2934
strategy:
3035
fail-fast: false
3136
matrix:
32-
python-version: ["{{ min_python_version }}", "3.12"] # test oldest and latest supported versions
33-
runs-on: [ubuntu-latest, macos-latest] # can be extended to other OSes, e.g. [ubuntu-latest, macos-latest, windows-latest]
34-
37+
python-version: [{% for v in range(min_python_version.split('.')[1]|int, 14) %}"3.{{ v }}"{% if not loop.last %}, {% endif %}{% endfor %}]
3538
steps:
3639
- uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
39-
40-
- uses: actions/setup-python@v4
40+
- uses: astral-sh/setup-uv@v5
4141
with:
4242
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
43-
allow-prereleases: true
44-
45-
- name: Install package
46-
run: python -m pip install .[dev]
47-
48-
- name: Test package
49-
run: >-
50-
python -m pytest -ra --cov --cov-report=xml --cov-report=term
51-
--durations=20
52-
53-
- name: Upload coverage report
54-
uses: codecov/codecov-action@v3.1.4
43+
enable-cache: true
44+
- run: uv sync --locked --group test
45+
- run: uv run pytest --cov --cov-report=xml
46+
- uses: codecov/codecov-action@v5
47+
if: {% raw %}matrix.python-version == '3.13'{% endraw %}
48+
with:
49+
files: coverage.xml

0 commit comments

Comments
 (0)