4343 test-outcome : ${{ steps.test.outcome }}
4444 defaults : # On Hoskinson runners, landrun is already installed.
4545 run :
46- shell : landrun --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT -- bash -euxo pipefail {0}
46+ shell : landrun --rox /usr --ro /etc/timezone -- rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rox /home/lean/.cache/mathlib/ --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
4747 steps :
4848 - name : cleanup
4949 shell : bash # This *just* deletes old files, so is safe to run outside landrun.
@@ -181,7 +181,7 @@ jobs:
181181 # - we give --rox access to `~/.elan` and `~/actions-runner/_work` (GitHub CI needs this)
182182 # - we give --unrestricted-network as we need this to download dependencies
183183 # - git needs read only access to `/etc`.
184- shell : landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT -- bash -euxo pipefail {0}
184+ shell : landrun --unrestricted-network --rox /etc --rox /usr --rw /dev --rox /home/lean/.elan --rox /home/lean/actions-runner/_work --rw pr-branch/.lake/ --env PATH --env HOME --env GITHUB_OUTPUT --env CI -- bash -euxo pipefail {0}
185185 run : |
186186 cd pr-branch
187187 lake env
@@ -205,8 +205,8 @@ jobs:
205205 run : |
206206 cd pr-branch
207207
208- echo "Attempting: lake build --no-build Mathlib.Init (this runs under landrun)"
209- lake build --no-build Mathlib.Init
208+ echo "Attempting: lake build --no-build -v Mathlib.Init (this runs under landrun)"
209+ lake build --no-build -v Mathlib.Init
210210
211211 - name : get cache (3/3 - finalize cache operation)
212212 id : get
@@ -217,8 +217,11 @@ jobs:
217217 echo "Fetching all remaining cache..."
218218
219219 ../master-branch/.lake/build/bin/cache get
220+
221+ # Run again with --repo, to ensure we actually get the oleans.
222+ ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} get
220223 else
221- echo "WARNING: 'lake build --no-build Mathlib.Init' failed."
224+ echo "WARNING: 'lake build --no-build -v Mathlib.Init' failed."
222225 echo "No cache for 'Mathlib.Init' available or it could not be prepared."
223226 fi
224227
@@ -240,14 +243,17 @@ jobs:
240243 id : build
241244 run : |
242245 cd pr-branch
246+ echo "::group::{test curl}"
243247 # Test curl - should fail when landrun network isolation is working
244248 if curl --silent --head --fail https://www.example.com/ >/dev/null 2>&1; then
245249 echo "ERROR: curl to example.com succeeded, but it should fail when landrun is working correctly!"
246250 exit 1
247251 else
248252 echo "curl to example.com failed as expected - landrun network isolation is working"
249253 fi
250- bash -o pipefail -c "env LEAN_ABORT_ON_PANIC=1 lake build --wfail -KCI"
254+ echo "::endgroup::"
255+
256+ ../master-branch/scripts/lake-build-with-retry.sh Mathlib
251257 - name : end gh-problem-match-wrap for build step
252258 uses : leanprover-community/gh-problem-matcher-wrap@20007cb926a46aa324653a387363b52f07709845 # 2025-04-23
253259 with :
@@ -259,6 +265,17 @@ jobs:
259265 cd pr-branch
260266 du .lake/build/lib/lean/Mathlib || echo "This code should be unreachable"
261267
268+ - name : upload artifact containing contents of pr-branch
269+ # temporary measure for debugging no-build failures
270+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
271+ with :
272+ name : mathlib4_artifact
273+ include-hidden-files : true
274+ # we exclude .git since there may be secrets in there
275+ path : |
276+ pr-branch/
277+ !pr-branch/.git/
278+
262279 # The cache secrets are available here, so we must not run any untrusted code.
263280 - name : upload cache
264281 # We only upload the cache if the build started (whether succeeding, failing, or cancelled)
@@ -269,6 +286,10 @@ jobs:
269286 run : |
270287 cd pr-branch
271288
289+ # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
290+ export MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
291+ export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
292+
272293 # Use the trusted cache tool from master-branch
273294 # TODO: this is not doing anything currently, and needs to be integrated with put-unpacked
274295 # ../master-branch/.lake/build/bin/cache commit || true
@@ -277,8 +298,8 @@ jobs:
277298 # do not try to upload files just downloaded
278299 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put-unpacked
279300 env :
280- MATHLIB_CACHE_SAS : ${{ secrets.MATHLIB_CACHE_SAS }}
281- MATHLIB_CACHE_S3_TOKEN : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
301+ MATHLIB_CACHE_SAS_RAW : ${{ secrets.MATHLIB_CACHE_SAS }}
302+ MATHLIB_CACHE_S3_TOKEN_RAW : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
282303
283304 # Note: we should not be including `Archive` and `Counterexamples` in the cache.
284305 # We do this for now for the sake of not rebuilding them in every CI run
@@ -297,26 +318,44 @@ jobs:
297318
298319 - name : build archive
299320 id : archive
321+ continue-on-error : true
300322 run : |
301323 cd pr-branch
302- bash -o pipefail -c "env LEAN_ABORT_ON_PANIC=1 lake build Archive"
324+ ../master-branch/scripts/ lake- build-with-retry.sh Archive
303325
304326 - name : build counterexamples
305327 id : counterexamples
328+ continue-on-error : true
306329 run : |
307330 cd pr-branch
308- bash -o pipefail -c "env LEAN_ABORT_ON_PANIC=1 lake build Counterexamples"
331+ ../master-branch/scripts/lake-build-with-retry.sh Counterexamples
332+
333+ - name : Check if building Archive or Counterexamples failed
334+ if : steps.archive.outcome == 'failure' || steps.counterexamples.outcome == 'failure'
335+ run : |
336+ if [ "${{ steps.archive.outcome }}" == "failure" ]; then
337+ echo "❌ The \"build archive\" step above failed; please check its logs."
338+ fi
339+ if [ "${{ steps.counterexamples.outcome }}" == "failure" ]; then
340+ echo "❌ The \"build counterexamples\" step above failed; please check its logs."
341+ fi
342+ exit 1
309343
310344 # The cache secrets are available here, so we must not run any untrusted code.
311345 - name : put archive and counterexamples cache
312346 shell : bash
313347 run : |
314348 cd pr-branch
349+
350+ # Trim trailing whitespace from secrets to prevent issues with accidentally added spaces
351+ export MATHLIB_CACHE_SAS="${MATHLIB_CACHE_SAS_RAW%"${MATHLIB_CACHE_SAS_RAW##*[![:space:]]}"}"
352+ export MATHLIB_CACHE_S3_TOKEN="${MATHLIB_CACHE_S3_TOKEN_RAW%"${MATHLIB_CACHE_S3_TOKEN_RAW##*[![:space:]]}"}"
353+
315354 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Archive.lean
316355 ../master-branch/.lake/build/bin/cache --repo=${{ github.event.pull_request.head.repo.full_name || github.repository }} put Counterexamples.lean
317356 env :
318- MATHLIB_CACHE_SAS : ${{ secrets.MATHLIB_CACHE_SAS }}
319- MATHLIB_CACHE_S3_TOKEN : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
357+ MATHLIB_CACHE_SAS_RAW : ${{ secrets.MATHLIB_CACHE_SAS }}
358+ MATHLIB_CACHE_S3_TOKEN_RAW : ${{ secrets.MATHLIB_CACHE_S3_TOKEN }}
320359
321360 - name : Check {Mathlib, Tactic, Counterexamples, Archive}.lean
322361 if : always()
@@ -380,7 +419,7 @@ jobs:
380419 ## we filter out the output lines that begin with `✔ [xx/yy]`, where xx, yy
381420 ## are either numbers or ?, and the "Build completed successfully." message.
382421 ## We keep the rest, which are actual outputs of the files
383- awk '!($0 ~ "^\\s*✔ \\[[?0-9]*/[?0-9]*\\]" || $0 == " Build completed successfully. "){ print $0 }')"
422+ awk '!($0 ~ "^\\s*✔ \\[[?0-9]*/[?0-9]*\\]" || $0 ~ "^ Build completed successfully( \\([0-9]+ jobs\\))?\\.?$ "){ print $0 }')"
384423 if [ -n "${buildMsgs}" ]
385424 then
386425 printf $'%s\n' "${buildMsgs}"
@@ -442,9 +481,15 @@ jobs:
442481
443482 - name : verify that everything was available in the cache
444483 run : |
445- lake build --no-build Mathlib
446- lake build --no-build Archive
447- lake build --no-build Counterexamples
484+ echo "::group::{verify Mathlib cache}"
485+ lake build --no-build -v Mathlib
486+ echo "::endgroup::"
487+ echo "::group::{verify Archive cache}"
488+ lake build --no-build -v Archive
489+ echo "::endgroup::"
490+ echo "::group::{verify Counterexamples cache}"
491+ lake build --no-build -v Counterexamples
492+ echo "::endgroup::"
448493
449494 - name : check declarations in db files
450495 run : |
0 commit comments