@@ -25,33 +25,14 @@ jobs:
2525 runs-on : ubuntu-latest
2626 if : github.repository == 'leanprover-community/mathlib4'
2727 strategy :
28+ fail-fast : false
2829 matrix :
2930 branch_type : [master, nightly]
3031 steps :
3132 # Checkout repository, so that we can fetch tags to decide which branch we want.
3233 - name : Checkout branch or tag
3334 uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3435
35- # this step needs to be run here while we have `mathlib4` checked out,
36- # or else `gh run view` will try to look for runs in `mathlib4-nightly-testing`
37- - name : Get URLs
38- id : urls
39- env :
40- GH_TOKEN : ${{ github.token }}
41- run : |
42- # adapted from https://cmbuckley.co.uk/blog/2024/04/09/deep-links-to-github-actions-job-logs/
43- lean4checker_url=$(gh run view ${{ github.run_id }} --json jobs --jq '
44- .jobs[] | select(.name == "check-lean4checker (${{ matrix.branch_type }})")
45- | (.url + (.steps[] | select(.name == "Check environments using lean4checker")
46- | "#step:\(.number):1"))')
47- echo "lean4checker_url=$lean4checker_url" | tee -a "$GITHUB_OUTPUT"
48-
49- mathlib_test_executable_url=$(gh run view ${{ github.run_id }} --json jobs --jq '
50- .jobs[] | select(.name == "check-lean4checker (${{ matrix.branch_type }})")
51- | (.url + (.steps[] | select(.name == "Run mathlib_test_executable")
52- | "#step:\(.number):1"))')
53- echo "mathlib_test_executable_url=$mathlib_test_executable_url" | tee -a "$GITHUB_OUTPUT"
54-
5536 - name : Fetch latest tags (if nightly)
5637 if : matrix.branch_type == 'nightly'
5738 run : |
8465 use-mathlib-cache : true
8566 reinstall-transient-toolchain : true
8667
87- - name : Check environments using lean4checker # make sure this name is consistent with "Get URLs"
68+ - name : Check environments using lean4checker # make sure this name is consistent with "Get job status and URLs" in the notify job
8869 id : lean4checker
8970 continue-on-error : true
9071 run : |
@@ -115,14 +96,51 @@ jobs:
11596 # so we explicitly check Batteries as well here.
11697 lake env lean4checker/.lake/build/bin/lean4checker Batteries Mathlib
11798
118- - name : Run mathlib_test_executable # make sure this name is consistent with "Get URLs"
119- id : mathlib-test
120- continue-on-error : true
99+ notify-lean4checker :
100+ runs-on : ubuntu-latest
101+ needs : check-lean4checker
102+ if : github.repository == 'leanprover-community/mathlib4' && always()
103+ strategy :
104+ fail-fast : false
105+ matrix :
106+ branch_type : [master, nightly]
107+ steps :
108+ - name : Checkout repository
109+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
110+
111+ - name : Get job status and URLs
112+ id : get-status
113+ env :
114+ GH_TOKEN : ${{ github.token }}
121115 run : |
122- lake exe mathlib_test_executable
116+ JOB_NAME="check-lean4checker (${{ matrix.branch_type }})"
117+
118+ # Get URL to the specific step
119+ LEAN4CHECKER_URL=$(gh run view ${{ github.run_id }} --json jobs --jq \
120+ ".jobs[] | select(.name == \"$JOB_NAME\") \
121+ | (.url + (.steps[] | select(.name == \"Check environments using lean4checker\") \
122+ | \"#step:\(.number):1\"))")
123+
124+ echo "lean4checker_url=${LEAN4CHECKER_URL}" | tee -a "$GITHUB_OUTPUT"
125+
126+ - name : Fetch latest tags (if nightly)
127+ if : matrix.branch_type == 'nightly'
128+ run : |
129+ git remote add nightly-testing https://github.com/leanprover-community/mathlib4-nightly-testing.git
130+ git fetch nightly-testing --tags
131+ LATEST_TAG=$(git tag | grep -E "${{ env.TAG_PATTERN }}" | sort -r | head -n 1)
132+ echo "LATEST_TAG=${LATEST_TAG}" | tee -a "$GITHUB_ENV"
133+
134+ - name : Set branch ref
135+ run : |
136+ if [ "${{ matrix.branch_type }}" == "master" ]; then
137+ echo "BRANCH_REF=${{ env.DEFAULT_BRANCH }}" >> "$GITHUB_ENV"
138+ else
139+ echo "BRANCH_REF=${{ env.LATEST_TAG }}" >> "$GITHUB_ENV"
140+ fi
123141
124142 - name : Post success message for lean4checker on Zulip
125- if : steps. lean4checker.outcome == 'success'
143+ if : needs.check- lean4checker.result == 'success'
126144 uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
127145 with :
128146 api-key : ${{ secrets.ZULIP_API_KEY }}
@@ -132,37 +150,129 @@ jobs:
132150 type : ' stream'
133151 topic : ' lean4checker'
134152 content : |
135- ✅ lean4checker [succeeded](${{ steps.urls .outputs.lean4checker_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
153+ ✅ lean4checker [succeeded](${{ steps.get-status .outputs.lean4checker_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
136154
137- - name : Post success message for mathlib_test_executable on Zulip
138- if : steps.mathlib-test.outcome = = 'success'
155+ - name : Post failure / cancelled message for lean4checker on Zulip
156+ if : needs.check-lean4checker.result ! = 'success'
139157 uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
140158 with :
141159 api-key : ${{ secrets.ZULIP_API_KEY }}
142160 email : ' github-mathlib4-bot@leanprover.zulipchat.com'
143161 organization-url : ' https://leanprover.zulipchat.com'
144162 to : ' nightly-testing'
145163 type : ' stream'
146- topic : ' mathlib test executable '
164+ topic : ' lean4checker failure '
147165 content : |
148- ✅ mathlib_test_executable [succeeded](${{ steps.urls.outputs.mathlib_test_executable_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
166+ ❌ lean4checker [${{ needs.check-lean4checker.result }}](${{ steps.get-status.outputs.lean4checker_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
167+
168+ check-mathlib_test_executable :
169+ runs-on : ubuntu-latest
170+ if : github.repository == 'leanprover-community/mathlib4'
171+ strategy :
172+ fail-fast : false
173+ matrix :
174+ branch_type : [master, nightly]
175+ steps :
176+ # Checkout repository, so that we can fetch tags to decide which branch we want.
177+ - name : Checkout branch or tag
178+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
179+
180+ - name : Fetch latest tags (if nightly)
181+ if : matrix.branch_type == 'nightly'
182+ run : |
183+ # When in nightly mode, fetch tags from the nightly-testing repository
184+ git remote add nightly-testing https://github.com/leanprover-community/mathlib4-nightly-testing.git
185+ git fetch nightly-testing --tags
186+ LATEST_TAG=$(git tag | grep -E "${{ env.TAG_PATTERN }}" | sort -r | head -n 1)
187+ echo "LATEST_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
188+
189+ - name : Set branch ref
190+ run : |
191+ if [ "${{ matrix.branch_type }}" == "master" ]; then
192+ echo "BRANCH_REF=${{ env.DEFAULT_BRANCH }}" >> "$GITHUB_ENV"
193+ else
194+ echo "BRANCH_REF=${{ env.LATEST_TAG }}" >> "$GITHUB_ENV"
195+ fi
196+
197+ # Checkout the branch or tag we want to test.
198+ - name : Checkout branch or tag
199+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
200+ with :
201+ repository : ${{ matrix.branch_type == 'nightly' && 'leanprover-community/mathlib4-nightly-testing' || github.repository }}
202+ ref : ${{ env.BRANCH_REF }}
203+
204+ - name : Configure Lean
205+ uses : leanprover/lean-action@434f25c2f80ded67bba02502ad3a86f25db50709 # v1.3.0
206+ with :
207+ auto-config : false
208+ use-github-cache : false
209+ use-mathlib-cache : true
210+ reinstall-transient-toolchain : true
211+
212+ - name : Run mathlib_test_executable # make sure this name is consistent with "Get job status and URLs" in the notify job
213+ id : mathlib-test
214+ continue-on-error : true
215+ run : |
216+ lake exe mathlib_test_executable
217+
218+ notify-mathlib_test_executable :
219+ runs-on : ubuntu-latest
220+ needs : check-mathlib_test_executable
221+ if : github.repository == 'leanprover-community/mathlib4' && always()
222+ strategy :
223+ fail-fast : false
224+ matrix :
225+ branch_type : [master, nightly]
226+ steps :
227+ - name : Checkout repository
228+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
229+
230+ - name : Get job status and URLs
231+ id : get-status
232+ env :
233+ GH_TOKEN : ${{ github.token }}
234+ run : |
235+ JOB_NAME="check-mathlib_test_executable (${{ matrix.branch_type }})"
236+
237+ # Get URL to the specific step
238+ MATHLIB_TEST_EXECUTABLE_URL=$(gh run view ${{ github.run_id }} --json jobs --jq \
239+ ".jobs[] | select(.name == \"$JOB_NAME\") \
240+ | (.url + (.steps[] | select(.name == \"Run mathlib_test_executable\") \
241+ | \"#step:\(.number):1\"))")
242+
243+ echo "mathlib_test_executable_url=${MATHLIB_TEST_EXECUTABLE_URL}" | tee -a "$GITHUB_OUTPUT"
244+
245+ - name : Fetch latest tags (if nightly)
246+ if : matrix.branch_type == 'nightly'
247+ run : |
248+ git remote add nightly-testing https://github.com/leanprover-community/mathlib4-nightly-testing.git
249+ git fetch nightly-testing --tags
250+ LATEST_TAG=$(git tag | grep -E "${{ env.TAG_PATTERN }}" | sort -r | head -n 1)
251+ echo "LATEST_TAG=${LATEST_TAG}" | tee -a "$GITHUB_ENV"
252+
253+ - name : Set branch ref
254+ run : |
255+ if [ "${{ matrix.branch_type }}" == "master" ]; then
256+ echo "BRANCH_REF=${{ env.DEFAULT_BRANCH }}" >> "$GITHUB_ENV"
257+ else
258+ echo "BRANCH_REF=${{ env.LATEST_TAG }}" >> "$GITHUB_ENV"
259+ fi
149260
150- - name : Post failure message for lean4checker on Zulip
151- if : steps.lean4checker.outcome == 'failure '
261+ - name : Post success message for mathlib_test_executable on Zulip
262+ if : needs.check-mathlib_test_executable.result == 'success '
152263 uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
153264 with :
154265 api-key : ${{ secrets.ZULIP_API_KEY }}
155266 email : ' github-mathlib4-bot@leanprover.zulipchat.com'
156267 organization-url : ' https://leanprover.zulipchat.com'
157268 to : ' nightly-testing'
158269 type : ' stream'
159- topic : ' lean4checker failure '
270+ topic : ' mathlib test executable '
160271 content : |
161- ❌ lean4checker [failed](${{ steps.urls.outputs.lean4checker_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
162- continue-on-error : true
272+ ✅ mathlib_test_executable [succeeded](${{ steps.get-status.outputs.mathlib_test_executable_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
163273
164- - name : Post failure message for mathlib_test_executable on Zulip
165- if : steps.mathlib-test.outcome == 'failure '
274+ - name : Post failure / cancelled message for mathlib_test_executable on Zulip
275+ if : needs.check-mathlib_test_executable.result != 'success '
166276 uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
167277 with :
168278 api-key : ${{ secrets.ZULIP_API_KEY }}
@@ -172,5 +282,4 @@ jobs:
172282 type : ' stream'
173283 topic : ' mathlib test executable failure'
174284 content : |
175- ❌ mathlib_test_executable [failed](${{ steps.urls.outputs.mathlib_test_executable_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
176- continue-on-error : true
285+ ❌ mathlib_test_executable [${{ needs.check-mathlib_test_executable.result }}](${{ steps.get-status.outputs.mathlib_test_executable_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
0 commit comments