Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ updates:
schedule:
interval: "daily"

- package-ecosystem: "pip"
- package-ecosystem: "uv"
directory: "/"
open-pull-requests-limit: 10
schedule:
Expand Down
115 changes: 48 additions & 67 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow automatically creates a GitHub release for the project on successful version update

name: Create a GitHub release
name: Create a release

on:
push:
Expand All @@ -11,97 +11,79 @@ permissions:
contents: write

jobs:
linux:
generate-matrix:
name: Derive Python version matrix from pyproject.toml
runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.python-versions.outputs.python-versions }}
steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: "uv.lock"
enable-cache: true
python-version: "3.12"
version: "0.5.13"

- name: Install library and dependencies
run: |
uv sync --frozen

- uses: messense/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --sdist -o dist --find-interpreter

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels
path: dist

windows:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: "uv.lock"
enable-cache: true
python-version: "3.12"
version: "0.5.13"

- name: Install library and dependencies
- name: Read supported versions from classifiers
id: python-versions
run: |
uv sync --frozen

- uses: messense/maturin-action@v1
with:
command: build
args: --release -o dist --find-interpreter
python - <<'EOF' >> "$GITHUB_OUTPUT"
import json
import tomllib

with open("pyproject.toml", "rb") as f:
classifiers = tomllib.load(f)["project"]["classifiers"]

prefix = "Programming Language :: Python :: 3."
versions = [
classifier.rsplit("::", 1)[-1].strip()
for classifier in classifiers
if classifier.startswith(prefix)
]
print(f"python-versions={json.dumps(versions)}")
EOF

build:
needs: generate-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-versions) }}

env:
PYTHON_VERSION: ${{ matrix.python-version }}

- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels
path: dist

macos:
runs-on: macos-latest
steps:

- name: Checkout repository
uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: "uv.lock"
enable-cache: true
version: "0.5.13"
enable-cache: false
python-version: ${{ matrix.python-version }}

- name: Install library and dependencies
run: |
uv sync --frozen

- uses: messense/maturin-action@v1
with:
manylinux: auto
command: build
args: --release -o dist --universal2 --find-interpreter
args: --release --sdist --out dist --find-interpreter --auditwheel repair

- name: Upload wheels
- name: Upload builds
uses: actions/upload-artifact@v7
with:
name: wheels
path: dist
name: ${{ matrix.os }}-${{ matrix.python-version }}
path: dist/

release:
name: Release
runs-on: ubuntu-latest
needs: [ macos, windows, linux ]
needs: build
steps:

- name: Checkout repository
Expand All @@ -110,7 +92,8 @@ jobs:
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
name: wheels
merge-multiple: true
path: dist/

- name: Check Version
uses: nowsprinting/check-version-format-action@v5
Expand Down Expand Up @@ -146,9 +129,7 @@ jobs:
*.tar.gz

- name: Publish to PyPI
uses: messense/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
command: upload
args: --skip-existing *
print-hash: true
skip-existing: true
3 changes: 0 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '41 10 * * 5'

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
tags-ignore:
- 'v*' # Avoid re-running existing commit on release

permissions:
contents: write
Expand Down
100 changes: 60 additions & 40 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ on:
- 'gh-pages' # GitHub Pages do not trigger all tests
tags-ignore:
- 'v*' # Avoid re-running existing commit on release
pull_request:
branches:
- 'main'

permissions:
contents: read
Expand All @@ -25,17 +22,43 @@ env:
FORCE_COLOR: 1

jobs:
test:
generate-matrix:
name: Derive Python version matrix from pyproject.toml
runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.python-versions.outputs.python-versions }}
steps:

- name: Checkout repository
uses: actions/checkout@v7

- name: Read supported versions from classifiers
id: python-versions
run: |
python - <<'EOF' >> "$GITHUB_OUTPUT"
import json
import tomllib

with open("pyproject.toml", "rb") as f:
classifiers = tomllib.load(f)["project"]["classifiers"]

prefix = "Programming Language :: Python :: 3."
versions = [
classifier.rsplit("::", 1)[-1].strip()
for classifier in classifiers
if classifier.startswith(prefix)
]
print(f"python-versions={json.dumps(versions)}")
EOF

test-and-build:
needs: generate-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [
'3.11',
'3.12',
'3.13',
]
python-version: ${{ fromJson(needs.generate-matrix.outputs.python-versions) }}

env:
PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -51,16 +74,16 @@ jobs:
cache-dependency-glob: "uv.lock"
enable-cache: false
python-version: ${{ matrix.python-version }}
version: "0.5.13"

- name: Install library and dependencies
run: |
uv sync --frozen
uv run maturin develop
uvx maturin develop

- name: Run Tox (Pytest + Coverage)
- name: Run tests (Pytest + Coverage)
run: |
uvx --with tox-uv tox
uv run --frozen pytest
uv run --frozen coverage report
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLATFORM: ${{ matrix.os }}
Expand All @@ -69,46 +92,43 @@ jobs:
if: success()
uses: codecov/codecov-action@v7
with:
env_vars: TOXENV
env_vars: PYTHON_VERSION
fail_ci_if_error: false
files: ./tests/reports/coverage-html/index.html,./tests/reports/coverage.xml
flags: unittests
name: "${{ matrix.os }} - Python ${{ matrix.python-version }}"
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build binaries for ${{ matrix.os }}-${{ matrix.python-version }}
run: |
uv build

- name: Upload builds
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}-${{ matrix.python-version }}
path: dist/


testpypi-deploy:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
environment: testpypi
permissions:
id-token: write
runs-on: ubuntu-latest
needs: test
needs: test-and-build
steps:

- name: Checkout repository
uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
cache-dependency-glob: "uv.lock"
enable-cache: true

- name: Install Python
uses: actions/setup-python@v7
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
python-version-file: "pyproject.toml"
merge-multiple: true
path: dist/

- name: Build test release 📦
uses: messense/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --sdist -o dist --find-interpreter

- name: Publish test release 📦 to Test PyPI
uses: messense/maturin-action@v1
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
env:
MATURIN_PYPI_TOKEN: ${{ secrets.TEST_PYPI_PASSWORD }}
with:
command: upload
args: --skip-existing * --repository-url "https://test.pypi.org/legacy"
print-hash: true
repository-url: https://test.pypi.org/legacy/
skip-existing: true
Loading