Skip to content

Commit e083f61

Browse files
authored
Merge pull request #294 from stanford-ssi/yiheng/fix-conditional-workflows
Migrated file path filtering into conditional job trigger to unblock doc-only updates.
2 parents 7d14c30 + dcf79b5 commit e083f61

4 files changed

Lines changed: 76 additions & 20 deletions

File tree

.github/workflows/c_build.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@ on:
1111
- ".bazelrc"
1212
- ".github/workflows/*.yaml"
1313
pull_request:
14-
paths:
15-
- "src/**"
16-
- "bzl/**"
17-
- "BUILD.bazel"
18-
- ".bazelrc"
19-
- ".github/workflows/*.yaml"
2014
workflow_dispatch:
2115

2216
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
should_build: ${{ github.event_name != 'pull_request' || steps.filter.outputs.build == 'true' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: dorny/paths-filter@v3
24+
id: filter
25+
with:
26+
filters: |
27+
build:
28+
- 'src/**'
29+
- 'bzl/**'
30+
- 'BUILD.bazel'
31+
- '.bazelrc'
32+
- '.github/workflows/*.yaml'
33+
2334
Build:
35+
needs: changes
36+
if: ${{ needs.changes.outputs.should_build == 'true' }}
2437
runs-on: ubuntu-latest
2538
strategy:
2639
matrix:

.github/workflows/c_lint.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@ on:
77
- "**.cpp"
88
- "**.h"
99
pull_request:
10-
paths:
11-
# only when a .c, .cpp, or .h file is changed
12-
- "**.c"
13-
- "**.cpp"
14-
- "**.h"
1510
workflow_dispatch:
1611

1712
jobs:
13+
changes:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
should_lint: ${{ github.event_name != 'pull_request' || steps.filter.outputs.lint == 'true' }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dorny/paths-filter@v3
20+
id: filter
21+
with:
22+
filters: |
23+
lint:
24+
- '**.c'
25+
- '**.cpp'
26+
- '**.h'
27+
1828
Lint-Check:
29+
needs: changes
30+
if: ${{ needs.changes.outputs.should_lint == 'true' }}
1931
runs-on: ubuntu-latest
2032
steps:
2133
- uses: actions/checkout@v4

.github/workflows/c_test.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@ on:
1111
- ".bazelrc"
1212
- ".github/workflows/*.yaml"
1313
pull_request:
14-
paths:
15-
- "src/**"
16-
- "bzl/**"
17-
- "BUILD.bazel"
18-
- ".bazelrc"
19-
- ".github/workflows/*.yaml"
2014
workflow_dispatch:
2115

2216
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
should_test: ${{ github.event_name != 'pull_request' || steps.filter.outputs.test == 'true' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: dorny/paths-filter@v3
24+
id: filter
25+
with:
26+
filters: |
27+
test:
28+
- 'src/**'
29+
- 'bzl/**'
30+
- 'BUILD.bazel'
31+
- '.bazelrc'
32+
- '.github/workflows/*.yaml'
33+
2334
Test:
35+
needs: changes
36+
if: ${{ needs.changes.outputs.should_test == 'true' }}
2437
runs-on: ubuntu-latest
2538
steps:
2639
- uses: actions/checkout@v4

.github/workflows/ground-station-tests.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,26 @@ on:
88
- 'ground_station/**'
99
- '.github/workflows/ground-station-tests.yml'
1010
pull_request:
11-
paths:
12-
- 'ground_station/**'
13-
- '.github/workflows/ground-station-tests.yml'
11+
workflow_dispatch:
1412

1513
jobs:
14+
changes:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
should_run: ${{ github.event_name != 'pull_request' || steps.filter.outputs.ground_station == 'true' }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: dorny/paths-filter@v3
21+
id: filter
22+
with:
23+
filters: |
24+
ground_station:
25+
- 'ground_station/**'
26+
- '.github/workflows/ground-station-tests.yml'
27+
1628
test:
29+
needs: changes
30+
if: ${{ needs.changes.outputs.should_run == 'true' }}
1731
name: Test Ground Station (${{ matrix.python-version }})
1832
runs-on: ${{ matrix.os }}
1933
strategy:
@@ -53,6 +67,8 @@ jobs:
5367
fail_ci_if_error: false
5468

5569
test-compatibility:
70+
needs: changes
71+
if: ${{ needs.changes.outputs.should_run == 'true' }}
5672
name: Platform Compatibility Tests
5773
runs-on: ubuntu-latest
5874

@@ -82,6 +98,8 @@ jobs:
8298
python -m pytest tests/test_filtering.py -v
8399
84100
lint:
101+
needs: changes
102+
if: ${{ needs.changes.outputs.should_run == 'true' }}
85103
name: Lint Ground Station Code
86104
runs-on: ubuntu-latest
87105

0 commit comments

Comments
 (0)