Skip to content

Commit 1bcd57d

Browse files
committed
Overhaul CI/CD and development tooling
Refactor GitHub Actions workflows: * Split `ci.yml` into dedicated `tests.yml`, `code_quality.yml`, and `publish.yml`. * Add `check_pull_request_title.yml` to enforce PR title conventions. * Update `docs-publish.yml` for consistency. Migrate project automation from `Makefile` to `justfile`. Introduce `tox.ini` for isolated and consistent testing environments. Update `pre-commit-config.yaml`, `pyproject.toml`, and `uv.lock` to align with new tooling and dependency changes. Refresh `CONTRIBUTING.md` and `README.md` to reflect the updated development setup.
1 parent 78a39f5 commit 1bcd57d

File tree

14 files changed

+672
-279
lines changed

14 files changed

+672
-279
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Check PR title"
2+
on:
3+
pull_request:
4+
types: [edited, opened, synchronize, reopened]
5+
6+
jobs:
7+
pr-title-check:
8+
runs-on: ubuntu-latest
9+
if: ${{ github.event.pull_request.user.login != 'allcontributors[bot]' }}
10+
steps:
11+
# Echo the user's login
12+
- name: Echo user login
13+
run: echo ${{ github.event.pull_request.user.login }}
14+
15+
- uses: naveenk1223/action-pr-title@master
16+
with:
17+
# ^ Start of string
18+
# [A-Z] First character must be an uppercase ASCII letter
19+
# [a-zA-Z]* Followed by zero or more ASCII letters
20+
# (?<![^s]s) Negative lookbehind: disallow a single 's' at the end of the first word
21+
# ( .+)+ At least one space and one or more characters (requires more words)
22+
# [^.] Final character must not be a period
23+
# $ End of string
24+
regex: "^[A-Z][a-zA-Z]*(?<![^s]s)( .+)+[^.]$"
25+
# Valid titles:
26+
# - "Do something"
27+
# - "Address something"
28+
# Invalid title:
29+
# - "do something"
30+
# - "Do something."
31+
# - "Does something"
32+
# - "Do"
33+
# - "Addresses something"
34+
min_length: 10
35+
max_length: 72

.github/workflows/ci.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/code_quality.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Code quality
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: "0 4 * * *"
11+
12+
env:
13+
FORCE_COLOR: 1
14+
15+
jobs:
16+
check:
17+
name: tox env ${{ matrix.tox_env }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
tox_env:
23+
- format
24+
- lint
25+
- types
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Install the latest version of uv
34+
uses: astral-sh/setup-uv@v6
35+
36+
- name: Run check for tox env "${{ matrix.tox_env }}"
37+
run: uvx --with tox-uv -- tox -e ${{ matrix.tox_env }}

.github/workflows/docs-publish.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ jobs:
1414
run: |
1515
git config user.name github-actions[bot]
1616
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
17-
- uses: actions/setup-python@v5
18-
with:
19-
python-version: 3.x
20-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
21-
- uses: actions/cache@v4
22-
with:
23-
key: mkdocs-material-${{ env.cache_id }}
24-
path: .cache
25-
restore-keys: |
26-
mkdocs-material-
27-
- run: pip install mkdocs-material mkdocs-autorefs mkdocstrings mkdocs-gen-files mkdocs-literate-nav mkdocs-section-index mkdocstrings-python
28-
- run: mkdocs gh-deploy --force
17+
- name: Install the latest version of uv
18+
uses: astral-sh/setup-uv@v6
19+
20+
- name: Install dependencies
21+
run: uv sync --only-group docs
22+
23+
- name: Deploy docs
24+
run: uv run --only-group docs mkdocs gh-deploy --force

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # Push events to matching v*, i.e. v1.0.0, v0.1.0
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build the package
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
21+
22+
- name: Build a binary wheel and a source tarball
23+
run: uv build
24+
25+
- name: Upload dist directory
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: dist
29+
path: dist
30+
31+
publish:
32+
name: Publish the package
33+
needs: build
34+
runs-on: ubuntu-latest
35+
permissions:
36+
id-token: write
37+
38+
steps:
39+
- name: Print ref
40+
run: echo ${{ github.ref }}
41+
42+
- name: Download all workflow run artifacts
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: dist
46+
path: dist
47+
48+
- name: Publish package to TestPyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
repository-url: https://test.pypi.org/legacy/
52+
skip-existing: true
53+
54+
- name: Install uv if commit is tagged
55+
if: startsWith(github.ref, 'refs/tags')
56+
uses: astral-sh/setup-uv@v6
57+
58+
- name: Publish package to PyPI if commit is tagged
59+
# Publish only tagged commits
60+
if: startsWith(github.ref, 'refs/tags')
61+
run: uv publish --verbose

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: "0 4 * * *"
11+
12+
env:
13+
FORCE_COLOR: 1
14+
15+
jobs:
16+
pytest:
17+
name: Unit tests
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
python: ["3.10", "3.11", "3.12"]
22+
fail-fast: false
23+
24+
runs-on: ${{ matrix.os }}
25+
env:
26+
OS: ${{ matrix.os }}
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Install the latest version of uv
35+
uses: astral-sh/setup-uv@v6
36+
37+
- name: Install tox
38+
run: uv tool install --python ${{ matrix.python }} --with tox-uv tox
39+
40+
41+
- name: Setup test suite
42+
run: tox run -v --notest --skip-missing-interpreters false -e ${{ matrix.python }}
43+
44+
# Run all tests on schedule, but only non-slow tests on push
45+
- name: Run pytest
46+
run: |
47+
if [ "${{ github.event_name }}" == "schedule" ]; then
48+
tox -e pytest
49+
else
50+
tox -e pytest -- -m "not slow"
51+
fi
52+
shell: bash # this wouldn't work on Powershell
53+
54+
- name: Upload coverage reports to Codecov
55+
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python == '3.12' }}
56+
uses: codecov/[email protected]
57+
env:
58+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.pre-commit-config.yaml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@ default_stages: [commit, push]
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v2.5.0
5+
rev: v4.6.0
66
hooks:
77
- id: check-yaml
88
- id: end-of-file-fixer
99
exclude: LICENSE
1010
- id: trailing-whitespace
1111

12-
- repo: local
12+
- repo: https://github.com/asottile/pyupgrade
13+
rev: v3.15.0
1314
hooks:
14-
- id: isort
15-
name: isort
16-
entry: uvx run isort --settings-path pyproject.toml
17-
types: [python]
18-
language: system
15+
- id: pyupgrade
16+
args: [--py310-plus]
1917

20-
- repo: local
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.5.0
2120
hooks:
22-
- id: black
23-
name: black
24-
entry: uvx run black --config pyproject.toml
25-
types: [python]
26-
language: system
21+
- id: ruff
22+
args: [--fix, --exit-non-zero-on-fix]
23+
- id: ruff-format

0 commit comments

Comments
 (0)