| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
|
| 9 |
permissions: write-all |
| 10 |
|
| 11 |
concurrency: |
| 12 |
group: ${{ github.head_ref || github.run_id }} |
| 13 |
cancel-in-progress: true |
| 14 |
|
| 15 |
jobs: |
| 16 |
lint: |
| 17 |
env: |
| 18 |
SKIP: no-commit-to-branch |
| 19 |
runs-on: ubuntu-latest |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 22 |
with: |
| 23 |
persist-credentials: false |
| 24 |
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 |
| 25 |
with: |
| 26 |
python-version: "3.14" # renovate: customPinnedDependency=python,datasource=python-version |
| 27 |
- uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0 |
| 28 |
|
| 29 |
# Make sure commit messages follow the conventional commits convention: |
| 30 |
# https://www.conventionalcommits.org |
| 31 |
commitlint: |
| 32 |
name: Lint Commit Messages |
| 33 |
runs-on: ubuntu-latest |
| 34 |
steps: |
| 35 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 36 |
with: |
| 37 |
fetch-depth: 0 |
| 38 |
persist-credentials: false |
| 39 |
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 |
| 40 |
|
| 41 |
test: |
| 42 |
strategy: |
| 43 |
fail-fast: false |
| 44 |
matrix: |
| 45 |
python-version: |
| 46 |
- "3.12" |
| 47 |
- "3.13" |
| 48 |
- "3.14" # renovate: depName=python datasource=python-version |
| 49 |
os: |
| 50 |
- ubuntu-latest |
| 51 |
- windows-latest |
| 52 |
- macOS-latest |
| 53 |
runs-on: ${{ matrix.os }} |
| 54 |
steps: |
| 55 |
- name: Checkout code |
| 56 |
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 57 |
with: |
| 58 |
persist-credentials: false |
| 59 |
- name: Set up Python |
| 60 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 |
| 61 |
with: |
| 62 |
python-version: ${{ matrix.python-version }} |
| 63 |
- name: Extract UV version |
| 64 |
run: | |
| 65 |
echo "UV_VERSION=$(./scripts/get-pyproject-uv.version.sh)" >> "$GITHUB_ENV" |
| 66 |
shell: bash |
| 67 |
- name: Setup UV |
| 68 |
uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0 |
| 69 |
with: |
| 70 |
version: ${{ env.UV_VERSION }} |
| 71 |
- name: Verify lock consistency |
| 72 |
run: uv lock --check |
| 73 |
shell: bash |
| 74 |
- name: Sync Dependencies |
| 75 |
run: uv sync --frozen --all-groups |
| 76 |
shell: bash |
| 77 |
- name: Test with Pytest |
| 78 |
run: uv run pytest --cov-report=xml |
| 79 |
shell: bash |
| 80 |
- name: Upload coverage to Codecov |
| 81 |
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 |
| 82 |
with: |
| 83 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 84 |
|
| 85 |
release: |
| 86 |
needs: |
| 87 |
- test |
| 88 |
- lint |
| 89 |
- commitlint |
| 90 |
|
| 91 |
runs-on: ubuntu-latest |
| 92 |
environment: release |
| 93 |
permissions: |
| 94 |
id-token: write |
| 95 |
contents: write |
| 96 |
|
| 97 |
steps: |
| 98 |
# Checkout must work for both PRs (including forks) and pushes to main |
| 99 |
- name: Checkout code |
| 100 |
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 101 |
with: |
| 102 |
fetch-depth: 0 |
| 103 |
persist-credentials: false |
| 104 |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} |
| 105 |
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} |
| 106 |
|
| 107 |
- name: Set up Python |
| 108 |
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 |
| 109 |
with: |
| 110 |
python-version: "3.14" # renovate: customPinnedDependency=python,datasource=python-version |
| 111 |
|
| 112 |
# Do a dry run of PSR |
| 113 |
- name: Test release |
| 114 |
uses: python-semantic-release/python-semantic-release@9a026e9303981c866c3425723009becb2437c757 # v10.6.2 |
| 115 |
if: github.event_name == 'pull_request' |
| 116 |
with: |
| 117 |
no_operation_mode: true |
| 118 |
vcs_release: false |
| 119 |
push: false |
| 120 |
tag: false |
| 121 |
github_token: ${{ github.token }} |
| 122 |
|
| 123 |
# On main branch: actual PSR + upload to PyPI & GitHub |
| 124 |
- name: Release |
| 125 |
uses: python-semantic-release/python-semantic-release@9a026e9303981c866c3425723009becb2437c757 # v10.6.2 |
| 126 |
id: release |
| 127 |
if: github.event_name == 'push' && github.ref_name == 'main' |
| 128 |
with: |
| 129 |
verbosity: 2 # equivalent to "-vv" |
| 130 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 131 |
|
| 132 |
- name: Publish package distributions to PyPI |
| 133 |
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1 |
| 134 |
if: steps.release.outputs.released == 'true' |
| 135 |
with: |
| 136 |
packages-dir: dist |
| 137 |
|
| 138 |
- name: Publish package distributions to GitHub Releases |
| 139 |
uses: python-semantic-release/publish-action@6d89e2de8d40ecb3717316ecbbf15a6fa8ea9039 # v10.6.2 |
| 140 |
if: steps.release.outputs.released == 'true' |
| 141 |
with: |
| 142 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 143 |
tag: ${{ steps.release.outputs.tag }} |