Skip to content

Commit 179048b

Browse files
GuyStenpaulromano
andauthored
Skip tests on documentation-only changes (#3727)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 7861adf commit 179048b

1 file changed

Lines changed: 42 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Tests and Coverage
22

33
on:
44
# allows us to run workflows manually
@@ -21,7 +21,25 @@ env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222

2323
jobs:
24+
filter-changes:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
source_changed: ${{ steps.filter.outputs.source_changed }}
28+
steps:
29+
- name: Check out the repository
30+
uses: actions/checkout@v4
31+
- name: Examine changed files
32+
id: filter
33+
uses: dorny/paths-filter@668c092af3649c4b664c54e4b704aa46782f6f7c # latest master commit, not released yet
34+
with:
35+
filters: |
36+
source_changed:
37+
- '!docs/**'
38+
- '!**/*.md'
39+
predicate-quantifier: 'every'
2440
main:
41+
needs: filter-changes
42+
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
2543
runs-on: ubuntu-22.04
2644
strategy:
2745
matrix:
@@ -205,12 +223,33 @@ jobs:
205223
flag-name: C++ and Python
206224
path-to-lcov: coverage.lcov
207225

208-
finish:
209-
needs: main
226+
coverage:
227+
needs: [filter-changes, main]
228+
if: ${{ always() }}
210229
runs-on: ubuntu-latest
211230
steps:
212231
- name: Coveralls Finished
232+
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
213233
uses: coverallsapp/github-action@v2
214234
with:
215235
github-token: ${{ secrets.GITHUB_TOKEN }}
216236
parallel-finished: true
237+
238+
ci-pass:
239+
needs: [filter-changes, main, coverage]
240+
name: Check CI status
241+
if: ${{ always() }}
242+
runs-on: ubuntu-latest
243+
steps:
244+
- name: Check CI status
245+
run: |
246+
if [[ "${{ needs.filter-changes.outputs.source_changed }}" == "false" ]]; then
247+
echo "Documentation-only change - CI skipped successfully"
248+
exit 0
249+
fi
250+
if [[ "${{ needs.main.result }}" == "success" && "${{ needs.coverage.result }}" == "success" ]]; then
251+
echo "CI passed"
252+
exit 0
253+
fi
254+
echo "CI failed"
255+
exit 1

0 commit comments

Comments
 (0)