Skip to content

Instantly share code, notes, and snippets.

@alreadydone
Last active January 13, 2026 00:07
Show Gist options
  • Select an option

  • Save alreadydone/bfb267648a51573d005a4fb690972956 to your computer and use it in GitHub Desktop.

Select an option

Save alreadydone/bfb267648a51573d005a4fb690972956 to your computer and use it in GitHub Desktop.
Copilot diagnosing CI hang on "lint mathlib" completion

Q: What is causing CI to hang after completing the "lint mathlib" step when run on branches of forks of @leanprover-community/mathlib4 ? Answer after browsing the repository thoroughly.

A: Upon reviewing the repository and its scripts, certain patterns and possible causes of CI hanging after the "lint mathlib" step when run on forks can be identified:

Probable Cause:

  1. Fork and Remote Configuration:

    • Functions like gh_get_all_forks, gh_find_mathlib_fork, and gh_get_mathlib_fork in scripts/githelper.py involve verifying remotes for forks. If these functions encounter errors or inconsistencies in how the forks are set up or synchronized, it might lead to issues in downstream processes during the CI pipeline.
  2. Error Handling in Fork Migration:

    • The scripts/migrate_to_fork.py facilitates migrating remotes to forks. If not correctly set up, remotes (origin and upstream) may cause the CI to operate on inaccessible branches or fail to find resources, potentially stalling the pipeline.
  3. Runaway Processes in CI Tasks:

    • In the CI scripts, multiple steps invoke benchmarking/linting processes (e.g., lake exe runLinter Mathlib in scripts/bench/lint/run). If these steps face misconfigured inputs, infinite loops, or unending subprocesses (e.g., runaway grind annotations in MathlibTest/grind/lint.lean), the process may stall indefinitely.
  4. Canceled Workflow Outcomes Confusion:

    • In scripts/lean-pr-testing-comments.sh, several conditions check for workflow outcomes like "success," "failure," or "cancelled." Gaps in handling "cancelled" scenarios might cause the CI workflow to hang.
  5. Toolchain Mismatch:

    • The function checkForToolchainMismatch in Cache/Requests.lean specifically validates if the toolchain matches. If mismatches occur, CI might be waiting indefinitely for a process to correct itself.

Keyed Failure Scenario:

  • In none of the code snippets provided did the logic seem to defensively handle the case where benchmarks or linters enter an infinite hanging state (e.g., as evidenced in scripts/bench/lint/run).
  • This may lead to incomplete termination or erroneous exit codes propagating incorrectly across scripts.

Suggested Focus Areas:

  1. Debug the script scripts/bench/lint for processes like lake exe runLinter Mathlib that could cause indefinite runtime behavior.
  2. Validate fork and branch consistency via helper scripts that interact with forks, like gh_* functions in scripts/githelper.py and their handling through the pipeline.
  3. Improve error-reporting mechanisms in scripts such as lean-pr-testing-comments.sh to ensure a more granular capture of stalled workflows or erroneous states.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment