@@ -283,3 +283,164 @@ jobs:
283283 topic : ' mathlib test executable failure'
284284 content : |
285285 ❌ mathlib_test_executable [${{ needs.check-mathlib_test_executable.result }}](${{ steps.get-status.outputs.mathlib_test_executable_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
286+
287+ check-nanoda :
288+ runs-on : ubuntu-latest
289+ if : github.repository == 'leanprover-community/mathlib4'
290+ strategy :
291+ fail-fast : false
292+ matrix :
293+ branch_type : [master, nightly]
294+ steps :
295+ # Checkout repository, so that we can fetch tags to decide which branch we want.
296+ - name : Checkout branch or tag
297+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
298+
299+ - name : Fetch latest tags (if nightly)
300+ if : matrix.branch_type == 'nightly'
301+ run : |
302+ # When in nightly mode, fetch tags from the nightly-testing repository
303+ git remote add nightly-testing https://github.com/leanprover-community/mathlib4-nightly-testing.git
304+ git fetch nightly-testing --tags
305+ LATEST_TAG=$(git tag | grep -E "${{ env.TAG_PATTERN }}" | sort -r | head -n 1)
306+ echo "LATEST_TAG=${LATEST_TAG}" >> "$GITHUB_ENV"
307+
308+ - name : Set branch ref
309+ run : |
310+ if [ "${{ matrix.branch_type }}" == "master" ]; then
311+ echo "BRANCH_REF=${{ env.DEFAULT_BRANCH }}" >> "$GITHUB_ENV"
312+ else
313+ echo "BRANCH_REF=${{ env.LATEST_TAG }}" >> "$GITHUB_ENV"
314+ fi
315+
316+ # Checkout the branch or tag we want to test.
317+ - name : Checkout branch or tag
318+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
319+ with :
320+ repository : ${{ matrix.branch_type == 'nightly' && 'leanprover-community/mathlib4-nightly-testing' || github.repository }}
321+ ref : ${{ env.BRANCH_REF }}
322+
323+ - name : Configure Lean
324+ uses : leanprover/lean-action@434f25c2f80ded67bba02502ad3a86f25db50709 # v1.3.0
325+ with :
326+ auto-config : false
327+ use-github-cache : false
328+ use-mathlib-cache : true
329+ reinstall-transient-toolchain : true
330+
331+ - name : Install Rust
332+ uses : dtolnay/rust-toolchain@stable
333+
334+ - name : Check Mathlib using nanoda # make sure this name is consistent with "Get job status and URLs" in the notify job
335+ id : nanoda
336+ continue-on-error : true
337+ run : |
338+ # Clone and build lean4export
339+ # TODO: Once https://github.com/leanprover/lean4export/pull/11 is merged,
340+ # switch to leanprover/lean4export and remove the `git checkout` line below.
341+ git clone https://github.com/kim-em/lean4export
342+ cd lean4export
343+ git checkout fix-nondep-normalization
344+ # Match toolchain to mathlib
345+ cp ../lean-toolchain .
346+ lake build
347+ cd ..
348+
349+ # Clone and build nanoda_lib
350+ git clone https://github.com/ammkrn/nanoda_lib
351+ cd nanoda_lib
352+ git checkout debug
353+ cargo build --release
354+ cd ..
355+
356+ # Export Mathlib
357+ lake env lean4export/.lake/build/bin/lean4export Mathlib > mathlib_export.txt
358+
359+ # Create config
360+ cat > nanoda_config.json << 'EOF'
361+ {
362+ "export_file_path": "mathlib_export.txt",
363+ "permitted_axioms": [
364+ "propext",
365+ "Classical.choice",
366+ "Quot.sound",
367+ "Lean.trustCompiler"
368+ ],
369+ "unpermitted_axiom_hard_error": false,
370+ "nat_extension": true,
371+ "string_extension": true,
372+ "print_success_message": true
373+ }
374+ EOF
375+
376+ # Run nanoda
377+ nanoda_lib/target/release/nanoda_bin nanoda_config.json
378+
379+ notify-nanoda :
380+ runs-on : ubuntu-latest
381+ needs : check-nanoda
382+ if : github.repository == 'leanprover-community/mathlib4' && always()
383+ strategy :
384+ fail-fast : false
385+ matrix :
386+ branch_type : [master, nightly]
387+ steps :
388+ - name : Checkout repository
389+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
390+
391+ - name : Get job status and URLs
392+ id : get-status
393+ env :
394+ GH_TOKEN : ${{ github.token }}
395+ run : |
396+ JOB_NAME="check-nanoda (${{ matrix.branch_type }})"
397+
398+ # Get URL to the specific step
399+ NANODA_URL=$(gh run view ${{ github.run_id }} --json jobs --jq \
400+ ".jobs[] | select(.name == \"$JOB_NAME\") \
401+ | (.url + (.steps[] | select(.name == \"Check Mathlib using nanoda\") \
402+ | \"#step:\(.number):1\"))")
403+
404+ echo "nanoda_url=${NANODA_URL}" | tee -a "$GITHUB_OUTPUT"
405+
406+ - name : Fetch latest tags (if nightly)
407+ if : matrix.branch_type == 'nightly'
408+ run : |
409+ git remote add nightly-testing https://github.com/leanprover-community/mathlib4-nightly-testing.git
410+ git fetch nightly-testing --tags
411+ LATEST_TAG=$(git tag | grep -E "${{ env.TAG_PATTERN }}" | sort -r | head -n 1)
412+ echo "LATEST_TAG=${LATEST_TAG}" | tee -a "$GITHUB_ENV"
413+
414+ - name : Set branch ref
415+ run : |
416+ if [ "${{ matrix.branch_type }}" == "master" ]; then
417+ echo "BRANCH_REF=${{ env.DEFAULT_BRANCH }}" >> "$GITHUB_ENV"
418+ else
419+ echo "BRANCH_REF=${{ env.LATEST_TAG }}" >> "$GITHUB_ENV"
420+ fi
421+
422+ - name : Post success message for nanoda on Zulip
423+ if : needs.check-nanoda.result == 'success'
424+ uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
425+ with :
426+ api-key : ${{ secrets.ZULIP_API_KEY }}
427+ email : ' github-mathlib4-bot@leanprover.zulipchat.com'
428+ organization-url : ' https://leanprover.zulipchat.com'
429+ to : ' nightly-testing'
430+ type : ' stream'
431+ topic : ' nanoda'
432+ content : |
433+ ✅ nanoda [succeeded](${{ steps.get-status.outputs.nanoda_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
434+
435+ - name : Post failure / cancelled message for nanoda on Zulip
436+ if : needs.check-nanoda.result != 'success'
437+ uses : zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
438+ with :
439+ api-key : ${{ secrets.ZULIP_API_KEY }}
440+ email : ' github-mathlib4-bot@leanprover.zulipchat.com'
441+ organization-url : ' https://leanprover.zulipchat.com'
442+ to : ' nightly-testing'
443+ type : ' stream'
444+ topic : ' nanoda failure'
445+ content : |
446+ ❌ nanoda [${{ needs.check-nanoda.result }}](${{ steps.get-status.outputs.nanoda_url }}) on ${{ github.sha }} (branch: ${{ env.BRANCH_REF }})
0 commit comments