Repository navigation
122 lines (109 loc) · 4.21 KB
/
Copy pathtest.yaml
File metadata and controls
122 lines (109 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build and Test Julia Package
on:
# Every pull request, whatever its base, so a PR stacked on another feature branch
# is tested too; it is tested again once retargeted, when it syncs with develop.
pull_request:
merge_group:
types: [checks_requested]
push:
branches:
- main
- develop
permissions:
contents: read
concurrency:
# One in-flight run per branch/PR. Superseded pull request runs are cancelled;
# Push and queue runs finish independently on their own refs.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
changes:
name: Detect Julia changes
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
contents: read
pull-requests: read
outputs:
julia: ${{ steps.filter.outputs.julia }}
steps:
- name: Check whether the pull request touches Julia code
id: filter
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
EVENT_NAME: ${{ github.event_name }}
run: |
set -euo pipefail
# Report the decision to the job log as well as the run summary, so
# `why did/didn't this run?` is answerable from either one.
say() { echo "$1"; echo "$1" >> "$GITHUB_STEP_SUMMARY"; }
# Pushes and queue candidates always run the full battery.
if [ "$EVENT_NAME" != "pull_request" ]; then
echo "julia=true" >> "$GITHUB_OUTPUT"
say "Event $EVENT_NAME — running the full test suite."
exit 0
fi
files=$(gh api --paginate "repos/${REPO}/pulls/${PR_NUMBER}/files" --jq '.[].filename')
# Allowlist of what test/runtests.jl actually exercises: the package
# itself, the tests and their fixtures, the example decks the tests run
# end-to-end, the dependency set (declared in Project.toml and pinned in
# ci/manifests), and this workflow. Anything not listed here does not
# trigger a run, so new untested Julia (benchmarks, docs scripts, a
# future tools/ directory) is excluded by default rather than by
# remembering to exclude it.
tested='(^src/|^test/|^examples/|^ci/manifests/|^ci/local-julia-cache\.sh$|^Project\.toml$|^\.github/workflows/(test|julia-test-version)\.yaml$)'
relevant=$(printf '%s\n' "$files" | grep -E "$tested" || true)
say "### Julia change detection"
say ""
if [ -n "$relevant" ]; then
say "Running the test suite. Matched files:"
say '```'
say "$relevant"
say '```'
else
say "No Julia code, test data or example decks changed — skipping the test suite."
say ""
say "Files considered:"
say '```'
say "$files"
say '```'
fi
if [ -n "$relevant" ]; then
echo "julia=true" >> "$GITHUB_OUTPUT"
else
echo "julia=false" >> "$GITHUB_OUTPUT"
fi
test:
name: Julia ${{ matrix.version }}
needs: changes
if: needs.changes.outputs.julia == 'true'
strategy:
fail-fast: false
matrix:
version: ['1.11', '1.x']
uses: ./.github/workflows/julia-test-version.yaml
with:
version: ${{ matrix.version }}
# Stable check that is present on every pull request, whether or not the suite
# ran. Point branch protection at this job so skipped runs do not block merges.
test-status:
name: Tests
needs: [changes, test]
if: always()
runs-on: ubuntu-slim
timeout-minutes: 5
steps:
- name: Report suite result
run: |
set -euo pipefail
if [ "${{ needs.changes.result }}" != "success" ]; then
echo "Change detection failed; cannot tell whether tests were needed."
exit 1
fi
case "${{ needs.test.result }}" in
success) echo "Test suite passed." ;;
skipped) echo "No Julia code changed; test suite intentionally skipped." ;;
*) echo "Test suite result: ${{ needs.test.result }}"; exit 1 ;;
esac