77 pull_request :
88 branches :
99 - master
10-
1110env :
1211 MAIN_PYTHON_VERSION : " 3.12"
1312
13+ concurrency :
14+ # Cancel previous workflow run when a new commit is pushed to a feature branch
15+ group : ${{ github.workflow }}-${{ github.ref }}
16+ cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
17+
1418jobs :
19+ changed-files :
20+ runs-on : ubuntu-latest
21+ name : Get changed files
22+ outputs :
23+ any_python_changed : ${{ steps.raw-changed-python-files.outputs.any_changed }}
24+ changed_python_files : ${{ steps.changed-python-files.outputs.all_changed_files }}
25+ steps :
26+ - uses : actions/checkout@v5
27+
28+ - name : Get changed python files
29+ id : raw-changed-python-files
30+ uses : tj-actions/changed-files@v46
31+ with :
32+ files : |
33+ **.py
34+ uv.lock
35+
36+ - name : Check changed python files
37+ id : changed-python-files
38+ env :
39+ CHANGED_PYTHON_FILES : ${{ steps.raw-changed-python-files.outputs.all_changed_files }}
40+ run : |
41+ if [[ " $CHANGED_PYTHON_FILES " == *" uv.lock "* ]]; then
42+ # if uv.lock is changed, we need to check everything
43+ CHANGED_PYTHON_FILES="."
44+ fi
45+ echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"
46+
1547 test :
48+ if : needs.changed-files.outputs.any_python_changed == 'true'
1649 name : " ${{ matrix.os }}: ${{ matrix.python-version }}"
1750 runs-on : ${{ matrix.os }}
1851 strategy :
@@ -23,34 +56,42 @@ jobs:
2356
2457 steps :
2558 - uses : actions/checkout@v5
26- - name : Set up Python ${{ matrix.python-version }}
27- uses : actions /setup-python@v5
59+ - name : Install uv and set the Python version
60+ uses : astral-sh /setup-uv@v6
2861 with :
2962 python-version : ${{ matrix.python-version }}
63+ enable-cache : true
3064 - name : Install dependencies
3165 run : |
32- python -m pip install --upgrade pip
33- pip install .[dev]
34-
35- - name : Run tests
66+ uv sync --frozen --all-extras --dev
67+ - name : Run tests with coverage
3668 run : |
37- pytest -v
69+ uv run poe test-with-coverage -v
70+ - name : Upload coverage reports
71+ if : matrix.os == 'ubuntu-24.04' && matrix.python-version == env.MAIN_PYTHON_VERSION
72+ uses : actions/upload-artifact@v4
73+ with :
74+ name : coverage-${{ github.run_id }}
75+ path : reports
76+ retention-days : 30
77+
3878 style :
3979 name : Style
80+ if : needs.changed-files.outputs.any_python_changed == 'true'
4081 runs-on : ubuntu-latest
4182 steps :
4283 - uses : actions/checkout@v5
43- - name : Set up Python ${{ env.MAIN_PYTHON_VERSION }}
44- uses : actions /setup-python@v5
84+ - name : Install uv and set the Python version
85+ uses : astral-sh /setup-uv@v6
4586 with :
4687 python-version : ${{ env.MAIN_PYTHON_VERSION }}
88+ enable-cache : true
4789 - name : Install dependencies
4890 run : |
49- python -m pip install --upgrade pip
50- pip install .[dev]
91+ uv sync --frozen --group dev
5192 - name : Check style with Ruff
5293 run : |
53- ruff check --output-format=github .
94+ uv run ruff check --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
5495 - name : Check format with Ruff
5596 run : |
56- ruff format --check .
97+ uv run ruff format --check ${{ needs.changed-files.outputs.changed_python_files }}
0 commit comments