@@ -15,10 +15,83 @@ permissions:
1515 actions : write
1616 contents : read
1717
18+ concurrency :
19+ # One in-flight run per branch/PR. Superseded pull request runs are cancelled;
20+ # runs on main/develop are allowed to finish so every merged commit is verified.
21+ group : ${{ github.workflow }}-${{ github.ref }}
22+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
23+
1824jobs :
25+ changes :
26+ name : Detect Julia changes
27+ runs-on : ubuntu-latest
28+ timeout-minutes : 5
29+ permissions :
30+ contents : read
31+ pull-requests : read
32+ outputs :
33+ julia : ${{ steps.filter.outputs.julia }}
34+ steps :
35+ - name : Check whether the pull request touches Julia code
36+ id : filter
37+ env :
38+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39+ REPO : ${{ github.repository }}
40+ PR_NUMBER : ${{ github.event.pull_request.number }}
41+ run : |
42+ set -euo pipefail
43+
44+ # Report the decision to the job log as well as the run summary, so
45+ # `why did/didn't this run?` is answerable from either one.
46+ say() { echo "$1"; echo "$1" >> "$GITHUB_STEP_SUMMARY"; }
47+
48+ # Pushes to main/develop always run: every merged commit gets verified.
49+ if [ "${{ github.event_name }}" != "pull_request" ]; then
50+ echo "julia=true" >> "$GITHUB_OUTPUT"
51+ say "Not a pull request — running the full test suite."
52+ exit 0
53+ fi
54+
55+ files=$(gh api --paginate "repos/${REPO}/pulls/${PR_NUMBER}/files" --jq '.[].filename')
56+
57+ # Allowlist of what test/runtests.jl actually exercises: the package
58+ # itself, the tests and their fixtures, the example decks the tests run
59+ # end-to-end, the dependency set, and this workflow. Anything not listed
60+ # here does not trigger a run, so new untested Julia (benchmarks, docs
61+ # scripts, a future tools/ directory) is excluded by default rather than
62+ # by remembering to exclude it.
63+ tested='(^src/|^test/|^examples/|^Project\.toml$|^\.github/workflows/test\.yaml$)'
64+
65+ relevant=$(printf '%s\n' "$files" | grep -E "$tested" || true)
66+
67+ say "### Julia change detection"
68+ say ""
69+ if [ -n "$relevant" ]; then
70+ say "Running the test suite. Matched files:"
71+ say '```'
72+ say "$relevant"
73+ say '```'
74+ else
75+ say "No Julia code, test data or example decks changed — skipping the test suite."
76+ say ""
77+ say "Files considered:"
78+ say '```'
79+ say "$files"
80+ say '```'
81+ fi
82+
83+ if [ -n "$relevant" ]; then
84+ echo "julia=true" >> "$GITHUB_OUTPUT"
85+ else
86+ echo "julia=false" >> "$GITHUB_OUTPUT"
87+ fi
88+
1989 test :
2090 name : runtests ${{ matrix.version }} - ${{ matrix.os }}
91+ needs : changes
92+ if : needs.changes.outputs.julia == 'true'
2193 runs-on : ${{ matrix.os }}
94+ timeout-minutes : 90
2295 strategy :
2396 fail-fast : false
2497 matrix :
@@ -43,5 +116,33 @@ jobs:
43116 - name : Build Julia packages
44117 uses : julia-actions/julia-buildpkg@v1
45118
119+ # Coverage instrumentation is off: nothing consumes the .cov files (they are
120+ # gitignored and never uploaded), and instrumenting slows compute-heavy
121+ # numerical code noticeably. Set coverage: true and add a Codecov upload
122+ # step together if coverage reporting is ever wanted.
46123 - name : Run tests
47124 uses : julia-actions/julia-runtest@v1
125+ with :
126+ coverage : false
127+
128+ # Stable check that is present on every pull request, whether or not the suite
129+ # ran. Point branch protection at this job so skipped runs do not block merges.
130+ test-status :
131+ name : Tests
132+ needs : [changes, test]
133+ if : always()
134+ runs-on : ubuntu-latest
135+ timeout-minutes : 5
136+ steps :
137+ - name : Report suite result
138+ run : |
139+ set -euo pipefail
140+ if [ "${{ needs.changes.result }}" != "success" ]; then
141+ echo "Change detection failed; cannot tell whether tests were needed."
142+ exit 1
143+ fi
144+ case "${{ needs.test.result }}" in
145+ success) echo "Test suite passed." ;;
146+ skipped) echo "No Julia code changed; test suite intentionally skipped." ;;
147+ *) echo "Test suite result: ${{ needs.test.result }}"; exit 1 ;;
148+ esac
0 commit comments