Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/challenge-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ name: Verify challenge solutions
# landrun is defence in depth on top of the ephemeral runner.

on:
# Deliberately not restricted to PRs targeting `main`. A solution lands
# wherever the work is happening — during a Lean/Mathlib bump, solution PRs
# stack on the bump branch — and whether a proof proves the challenge has
# nothing to do with which branch it is heading for. PR #301 (the first
# solution to the Odlyzko challenge) got no verification at all because it
# targeted `bump/v4.33.0-rc1`.
pull_request:
branches:
- main
paths:
- 'Challenge/**'
- 'Challenge.lean'
Expand Down Expand Up @@ -120,6 +124,37 @@ jobs:
if: steps.tools.outputs.cache-hit != 'true'
run: go install "github.com/zouuup/landrun/cmd/landrun@$LANDRUN_COMMIT"

# lean4export reads the oleans this repository's build produced, so its
# version has to track `lean-toolchain`. That coupling is invisible in a
# commit pin: a version bump that forgets it fails later, inside an
# export, with an error about the file format rather than the pin. Say
# it here instead, with the replacement SHA already resolved.
- name: Check the lean4export pin matches the toolchain
run: |
set -euo pipefail
toolchain="$(cut -d: -f2 lean-toolchain)"
# Annotated tags need the `^{}` dereference to reach the commit;
# lightweight ones (what lean4export uses today) answer only the
# plain query. Ask for both rather than depend on which it is.
expected="$(git ls-remote https://github.com/leanprover/lean4export \
"refs/tags/$toolchain^{}" | cut -f1)"
if [ -z "$expected" ]; then
expected="$(git ls-remote https://github.com/leanprover/lean4export \
"refs/tags/$toolchain" | cut -f1)"
fi
if [ -z "$expected" ]; then
echo "::warning::lean4export has no $toolchain tag; leaving the pin alone."
exit 0
fi
if [ "$expected" != "$LEAN4EXPORT_COMMIT" ]; then
echo "::error::LEAN4EXPORT_COMMIT is pinned to a lean4export that does"
echo "not match lean-toolchain ($toolchain). Comparator would fail"
echo "reading this repository's oleans. Set it in this workflow to:"
echo " LEAN4EXPORT_COMMIT: $expected"
exit 1
fi
echo "lean4export pin matches $toolchain."
Comment on lines +133 to +156

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Pin check runs unconditionally, including on cache hits

The git ls-remote call executes on every workflow run — even when the tools cache is a hit and no rebuild is needed. When the toolchain hasn't changed, the check will always pass (the cache key already includes both LEAN4EXPORT_COMMIT and hashFiles('lean-toolchain')), so it's essentially a no-op on cache hits while adding a synchronous network round-trip. Adding if: steps.tools.outputs.cache-hit != 'true' would eliminate the latency on warm cache runs without weakening correctness, since a stale pin would bust the cache and trigger a miss anyway. That said, the unconditional check does function as a final safety net against hand-edited LEAN4EXPORT_COMMIT values, so the trade-off is deliberate.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


- name: Build lean4export
if: steps.tools.outputs.cache-hit != 'true'
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lean_action_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ on:
pull_request:
branches:
- main
# Work stacks on the bump branch during a Lean/Mathlib migration, and
# a contribution that never builds is a contribution nobody can judge:
# PR #301 added a 210-file project onto `bump/v4.33.0-rc1` and got no
# build, no linters, and no quality checks at all.
- 'bump/**'
paths:
- '**/*.lean'
- 'lakefile.toml'
Expand Down
Loading