Skip to content

Commit d0b1d32

Browse files
authored
fix: Use modern uv versions in CI (#380)
# [Pull request title here] ## Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. Fixes # (issue) ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ## How has this been tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B **Test Configuration**: - Firmware version: - Hardware: - Toolchain: - SDK: ## Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
2 parents eccbd93 + 848006f commit d0b1d32

8 files changed

Lines changed: 152 additions & 469 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ updates:
1515
schedule:
1616
interval: "daily"
1717

18-
- package-ecosystem: "pip"
18+
- package-ecosystem: "uv"
1919
directory: "/"
2020
open-pull-requests-limit: 10
2121
schedule:
Lines changed: 48 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This workflow automatically creates a GitHub release for the project on successful version update
22

3-
name: Create a GitHub release
3+
name: Create a release
44

55
on:
66
push:
@@ -11,97 +11,79 @@ permissions:
1111
contents: write
1212

1313
jobs:
14-
linux:
14+
generate-matrix:
15+
name: Derive Python version matrix from pyproject.toml
1516
runs-on: ubuntu-latest
17+
outputs:
18+
python-versions: ${{ steps.python-versions.outputs.python-versions }}
1619
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v7
19-
20-
- name: Install uv
21-
uses: astral-sh/setup-uv@v7
22-
with:
23-
cache-dependency-glob: "uv.lock"
24-
enable-cache: true
25-
python-version: "3.12"
26-
version: "0.5.13"
27-
28-
- name: Install library and dependencies
29-
run: |
30-
uv sync --frozen
31-
32-
- uses: messense/maturin-action@v1
33-
with:
34-
manylinux: auto
35-
command: build
36-
args: --release --sdist -o dist --find-interpreter
37-
38-
- name: Upload wheels
39-
uses: actions/upload-artifact@v7
40-
with:
41-
name: wheels
42-
path: dist
4320

44-
windows:
45-
runs-on: windows-latest
46-
steps:
4721
- name: Checkout repository
4822
uses: actions/checkout@v7
4923

50-
- name: Install uv
51-
uses: astral-sh/setup-uv@v7
52-
with:
53-
cache-dependency-glob: "uv.lock"
54-
enable-cache: true
55-
python-version: "3.12"
56-
version: "0.5.13"
57-
58-
- name: Install library and dependencies
24+
- name: Read supported versions from classifiers
25+
id: python-versions
5926
run: |
60-
uv sync --frozen
61-
62-
- uses: messense/maturin-action@v1
63-
with:
64-
command: build
65-
args: --release -o dist --find-interpreter
27+
python - <<'EOF' >> "$GITHUB_OUTPUT"
28+
import json
29+
import tomllib
30+
31+
with open("pyproject.toml", "rb") as f:
32+
classifiers = tomllib.load(f)["project"]["classifiers"]
33+
34+
prefix = "Programming Language :: Python :: 3."
35+
versions = [
36+
classifier.rsplit("::", 1)[-1].strip()
37+
for classifier in classifiers
38+
if classifier.startswith(prefix)
39+
]
40+
print(f"python-versions={json.dumps(versions)}")
41+
EOF
42+
43+
build:
44+
needs: generate-matrix
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [macos-latest, ubuntu-latest, windows-latest]
50+
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-versions) }}
51+
52+
env:
53+
PYTHON_VERSION: ${{ matrix.python-version }}
6654

67-
- name: Upload wheels
68-
uses: actions/upload-artifact@v7
69-
with:
70-
name: wheels
71-
path: dist
72-
73-
macos:
74-
runs-on: macos-latest
7555
steps:
56+
7657
- name: Checkout repository
7758
uses: actions/checkout@v7
7859

7960
- name: Install uv
8061
uses: astral-sh/setup-uv@v7
8162
with:
8263
cache-dependency-glob: "uv.lock"
83-
enable-cache: true
84-
version: "0.5.13"
64+
enable-cache: false
65+
python-version: ${{ matrix.python-version }}
8566

8667
- name: Install library and dependencies
8768
run: |
8869
uv sync --frozen
8970
9071
- uses: messense/maturin-action@v1
9172
with:
73+
manylinux: auto
9274
command: build
93-
args: --release -o dist --universal2 --find-interpreter
75+
args: --release --sdist --out dist --find-interpreter --auditwheel repair
9476

95-
- name: Upload wheels
77+
- name: Upload builds
9678
uses: actions/upload-artifact@v7
9779
with:
98-
name: wheels
99-
path: dist
80+
name: ${{ matrix.os }}-${{ matrix.python-version }}
81+
path: dist/
10082

10183
release:
10284
name: Release
10385
runs-on: ubuntu-latest
104-
needs: [ macos, windows, linux ]
86+
needs: build
10587
steps:
10688

10789
- name: Checkout repository
@@ -110,7 +92,8 @@ jobs:
11092
- name: Download Artifacts
11193
uses: actions/download-artifact@v8
11294
with:
113-
name: wheels
95+
merge-multiple: true
96+
path: dist/
11497

11598
- name: Check Version
11699
uses: nowsprinting/check-version-format-action@v5
@@ -146,9 +129,7 @@ jobs:
146129
*.tar.gz
147130
148131
- name: Publish to PyPI
149-
uses: messense/maturin-action@v1
150-
env:
151-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }}
132+
uses: pypa/gh-action-pypi-publish@release/v1
152133
with:
153-
command: upload
154-
args: --skip-existing *
134+
print-hash: true
135+
skip-existing: true

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ name: "CodeQL"
55
on:
66
push:
77
branches: [ "main" ]
8-
pull_request:
9-
# The branches below must be a subset of the branches above
10-
branches: [ "main" ]
118
schedule:
129
- cron: '41 10 * * 5'
1310

.github/workflows/ruff.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ on:
66
push:
77
branches:
88
- '**'
9-
pull_request:
10-
branches:
11-
- '**'
9+
tags-ignore:
10+
- 'v*' # Avoid re-running existing commit on release
1211

1312
permissions:
1413
contents: write

.github/workflows/unit_tests.yml

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ on:
1414
- 'gh-pages' # GitHub Pages do not trigger all tests
1515
tags-ignore:
1616
- 'v*' # Avoid re-running existing commit on release
17-
pull_request:
18-
branches:
19-
- 'main'
2017

2118
permissions:
2219
contents: read
@@ -25,17 +22,43 @@ env:
2522
FORCE_COLOR: 1
2623

2724
jobs:
28-
test:
25+
generate-matrix:
26+
name: Derive Python version matrix from pyproject.toml
27+
runs-on: ubuntu-latest
28+
outputs:
29+
python-versions: ${{ steps.python-versions.outputs.python-versions }}
30+
steps:
31+
32+
- name: Checkout repository
33+
uses: actions/checkout@v7
34+
35+
- name: Read supported versions from classifiers
36+
id: python-versions
37+
run: |
38+
python - <<'EOF' >> "$GITHUB_OUTPUT"
39+
import json
40+
import tomllib
41+
42+
with open("pyproject.toml", "rb") as f:
43+
classifiers = tomllib.load(f)["project"]["classifiers"]
44+
45+
prefix = "Programming Language :: Python :: 3."
46+
versions = [
47+
classifier.rsplit("::", 1)[-1].strip()
48+
for classifier in classifiers
49+
if classifier.startswith(prefix)
50+
]
51+
print(f"python-versions={json.dumps(versions)}")
52+
EOF
53+
54+
test-and-build:
55+
needs: generate-matrix
2956
runs-on: ${{ matrix.os }}
3057
strategy:
3158
fail-fast: false
3259
matrix:
3360
os: [macos-latest, ubuntu-latest, windows-latest]
34-
python-version: [
35-
'3.11',
36-
'3.12',
37-
'3.13',
38-
]
61+
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-versions) }}
3962

4063
env:
4164
PYTHON_VERSION: ${{ matrix.python-version }}
@@ -51,16 +74,16 @@ jobs:
5174
cache-dependency-glob: "uv.lock"
5275
enable-cache: false
5376
python-version: ${{ matrix.python-version }}
54-
version: "0.5.13"
5577

5678
- name: Install library and dependencies
5779
run: |
5880
uv sync --frozen
59-
uv run maturin develop
81+
uvx maturin develop
6082
61-
- name: Run Tox (Pytest + Coverage)
83+
- name: Run tests (Pytest + Coverage)
6284
run: |
63-
uvx --with tox-uv tox
85+
uv run --frozen pytest
86+
uv run --frozen coverage report
6487
env:
6588
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6689
PLATFORM: ${{ matrix.os }}
@@ -69,46 +92,43 @@ jobs:
6992
if: success()
7093
uses: codecov/codecov-action@v7
7194
with:
72-
env_vars: TOXENV
95+
env_vars: PYTHON_VERSION
7396
fail_ci_if_error: false
7497
files: ./tests/reports/coverage-html/index.html,./tests/reports/coverage.xml
7598
flags: unittests
7699
name: "${{ matrix.os }} - Python ${{ matrix.python-version }}"
77100
token: ${{ secrets.CODECOV_TOKEN }}
78101

102+
- name: Build binaries for ${{ matrix.os }}-${{ matrix.python-version }}
103+
run: |
104+
uv build
105+
106+
- name: Upload builds
107+
uses: actions/upload-artifact@v7
108+
with:
109+
name: ${{ matrix.os }}-${{ matrix.python-version }}
110+
path: dist/
111+
79112

80113
testpypi-deploy:
81114
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
115+
environment: testpypi
116+
permissions:
117+
id-token: write
82118
runs-on: ubuntu-latest
83-
needs: test
119+
needs: test-and-build
84120
steps:
85121

86-
- name: Checkout repository
87-
uses: actions/checkout@v7
88-
89-
- name: Install uv
90-
uses: astral-sh/setup-uv@v7
91-
with:
92-
cache-dependency-glob: "uv.lock"
93-
enable-cache: true
94-
95-
- name: Install Python
96-
uses: actions/setup-python@v7
122+
- name: Download Artifacts
123+
uses: actions/download-artifact@v8
97124
with:
98-
python-version-file: "pyproject.toml"
125+
merge-multiple: true
126+
path: dist/
99127

100-
- name: Build test release 📦
101-
uses: messense/maturin-action@v1
102-
with:
103-
manylinux: auto
104-
command: build
105-
args: --release --sdist -o dist --find-interpreter
106-
107-
- name: Publish test release 📦 to Test PyPI
108-
uses: messense/maturin-action@v1
128+
- name: Publish to Test PyPI
129+
uses: pypa/gh-action-pypi-publish@release/v1
109130
continue-on-error: true
110-
env:
111-
MATURIN_PYPI_TOKEN: ${{ secrets.TEST_PYPI_PASSWORD }}
112131
with:
113-
command: upload
114-
args: --skip-existing * --repository-url "https://test.pypi.org/legacy"
132+
print-hash: true
133+
repository-url: https://test.pypi.org/legacy/
134+
skip-existing: true

0 commit comments

Comments
 (0)