Skip to content

Commit be498ae

Browse files
committed
ci: fix python skips
1 parent c1e4237 commit be498ae

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/python-tests.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,38 @@ 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+
- '.github/workflows/python-tests.yaml'
37+
2438
pytest-matrix:
39+
needs: changes
40+
if: needs.changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
2541
runs-on: ${{ matrix.runs-on }}
2642
strategy:
2743
matrix:
@@ -89,13 +105,14 @@ jobs:
89105
# https://github.com/orgs/community/discussions/26822
90106
pytest:
91107
runs-on: ubuntu-latest
92-
needs: [pytest-matrix]
108+
needs: [changes, pytest-matrix]
93109
if: ${{ always() }}
94110
steps:
95111
- run: exit 1
112+
# Fail on failures or cancellations, but allow skips when no relevant changes
96113
if: >-
97114
${{
98115
contains(needs.*.result, 'failure')
99116
|| contains(needs.*.result, 'cancelled')
100-
|| contains(needs.*.result, 'skipped')
117+
|| (contains(needs.*.result, 'skipped') && needs.changes.outputs.should_run == 'true')
101118
}}

0 commit comments

Comments
 (0)