Skip to content

Commit 971cf1f

Browse files
committed
ci: fix python skips
1 parent ae2fef4 commit 971cf1f

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/python-tests.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,39 @@ on:
66
branches:
77
- main
88
- release-*
9-
paths:
10-
- 'python/**'
11-
- 'protocol/**'
129
pull_request:
13-
# running for all, since github does not detect skipped on this when required for merging
14-
#paths:
15-
# - 'python/**'
16-
# - 'protocol/**'
10+
branches:
11+
- main
12+
- 'release-*'
1713
merge_group:
1814

1915
permissions:
2016
contents: read
2117
pull-requests: read
2218

2319
jobs:
20+
changes:
21+
if: github.repository_owner == 'jumpstarter-dev'
22+
runs-on: ubuntu-latest
23+
outputs:
24+
should_run: ${{ steps.filter.outputs.python }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- uses: dorny/paths-filter@v3
30+
id: filter
31+
with:
32+
base: ${{ github.base_ref || github.event.merge_group.base_ref || 'main' }}
33+
filters: |
34+
python:
35+
- 'python/**'
36+
- 'protocol/**'
37+
- '.github/workflows/python-tests.yaml'
38+
2439
pytest-matrix:
40+
needs: changes
41+
if: needs.changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
2542
runs-on: ${{ matrix.runs-on }}
2643
strategy:
2744
matrix:
@@ -89,13 +106,14 @@ jobs:
89106
# https://github.com/orgs/community/discussions/26822
90107
pytest:
91108
runs-on: ubuntu-latest
92-
needs: [pytest-matrix]
109+
needs: [changes, pytest-matrix]
93110
if: ${{ always() }}
94111
steps:
95112
- run: exit 1
113+
# Fail on failures or cancellations, but allow skips when no relevant changes
96114
if: >-
97115
${{
98116
contains(needs.*.result, 'failure')
99117
|| contains(needs.*.result, 'cancelled')
100-
|| contains(needs.*.result, 'skipped')
118+
|| (contains(needs.*.result, 'skipped') && needs.changes.outputs.should_run == 'true')
101119
}}

0 commit comments

Comments
 (0)