Skip to content

Commit 6bf82de

Browse files
Lee-Wbearomorphism
authored andcommitted
ci: run unittests only on python and dependency change
1 parent 1d89195 commit 6bf82de

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,63 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11+
detect_changes:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
relevant: ${{ steps.filter.outputs.relevant }}
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
fetch-depth: 0
19+
- id: filter
20+
uses: dorny/paths-filter@v3
21+
with:
22+
filters: |
23+
relevant:
24+
- "commitizen/**"
25+
- "tests/**"
26+
- ".github/workflows/**"
1127
python-check:
28+
needs: detect_changes
1229
strategy:
1330
matrix:
1431
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1532
platform: [ubuntu-22.04, macos-latest, windows-latest]
1633
runs-on: ${{ matrix.platform }}
1734
steps:
35+
- name: No relevant changes, fast-path success
36+
if: ${{ needs.detect_changes.outputs.relevant != 'true' }}
37+
run: echo "No relevant file changes; skipping tests and linters."
38+
1839
- uses: actions/checkout@v6
40+
if: ${{ needs.detect_changes.outputs.relevant == 'true' }}
1941
with:
2042
fetch-depth: 0
2143
- name: Set up Python ${{ matrix.python-version }}
2244
uses: astral-sh/setup-uv@v7
45+
if: ${{ needs.detect_changes.outputs.relevant == 'true' }}
2346
with:
2447
python-version: ${{ matrix.python-version }}
2548
- name: Install dependencies
49+
if: ${{ needs.detect_changes.outputs.relevant == 'true' }}
2650
run: |
2751
uv --version
2852
uv sync --frozen --group base --group test --group linters
2953
- name: Run tests and linters
54+
if: ${{ needs.detect_changes.outputs.relevant == 'true' }}
3055
run: |
3156
git config --global user.email "action@github.com"
3257
git config --global user.name "GitHub Action"
3358
uv run --no-sync poe ci
3459
shell: bash
3560
- name: Upload coverage to Codecov
3661
uses: codecov/codecov-action@v5
62+
if: ${{ needs.detect_changes.outputs.relevant == 'true' }}
3763
with:
3864
token: ${{ secrets.CODECOV_TOKEN }}
3965
- name: Upload test results to Codecov
4066
uses: codecov/codecov-action@v5
41-
if: ${{ !cancelled() }}
67+
if: ${{ needs.detect_changes.outputs.relevant == 'true' && !cancelled() }}
4268
with:
4369
token: ${{ secrets.CODECOV_TOKEN }}
4470
report_type: test_results

0 commit comments

Comments
 (0)