Skip to content

ci: incremental build on PRs — drop forced fresh elaboration (6m → 30s)#46

Merged
Xinze-Li-Moqian merged 1 commit into
mainfrom
ci/incremental-build
May 19, 2026
Merged

ci: incremental build on PRs — drop forced fresh elaboration (6m → 30s)#46
Xinze-Li-Moqian merged 1 commit into
mainfrom
ci/incremental-build

Conversation

@Xinze-Li-Moqian
Copy link
Copy Markdown
Contributor

Summary

PR Lake build was forcing rm -rf .lake/build/lib/lean/OpenGALib on every push to guarantee linter warnings reach build.log (Lean linters fire only during elaboration; cached .olean skips them). With all three linter baselines at 0, incremental build suffices: only re-elaborated files emit warnings, and any new violation in changed files (or transitive consumers) still fails CI.

Changes

  1. Drop the forced fresh elaboration step from PR builds. Lake's normal incremental behavior re-elaborates only changed files + transitive deps. Linter warnings on those files still reach build.log — caught by the unchanged baseline check.

  2. Improve cache key: include ${{ github.sha }} so each commit gets its own cache snapshot. restore-keys chain falls back to:

    • same Mathlib+toolchain version (most recent build) → typically warm
    • any prior build → fallback to anything available
  3. Add full-lint-on-main safety-net job: runs only on push to main, does fresh elaboration, re-checks linter baselines authoritatively. Catches any regression that incremental missed (rare — requires complex transitive dep effect).

Expected impact

Scenario Before After
PR with small change, warm cache ~6 min ~30 s
PR with big change (~50 files), warm cache ~6 min ~1–2 min
Cold cache (Mathlib bump) ~6 min ~6 min
Main push ~6 min ~6 min (full lint)

Safety analysis

The only way incremental misses a regression: a file's .olean cached cleanly (no warning), then later a OTHER file's change makes the cached file's docstring/code violate a linter — but the cached file isn't re-elaborated.

This can't happen because:

  • MathTag (docstring start): only depends on the file's own docstring text. Other files can't affect it.
  • AnchorPurity (which files contain Eng/Mixed decls): also self-contained.
  • Naming (forbidden initialisms in declaration names): self-contained.

If a file changes, its own linters re-run. If only transitive deps change, the file's linter state can't shift.

Even so, full-lint-on-main provides a safety net at merge time.

Test plan

  • Workflow YAML syntax valid
  • Local lake build clean (incremental works)
  • CI green on this PR (will demonstrate the speedup)
  • No false positives / false negatives on linter check

CI was forcing rm -rf .lake/build/lib/lean/OpenGALib on every PR to force
re-elaboration so all Lean linter warnings would reach build.log for the
baseline check. With all three linter baselines now at 0
(MathTag/AnchorPurity/Naming), incremental build is sufficient: only
re-elaborated files emit warnings, and any new violation in changed files
(or their transitive consumers) still fails CI.

Changes:
- Remove 'Force fresh OpenGALib elaboration' step from PR builds
- Improve cache key (include github.sha; restore-keys chain falls back
  to most-recent same-Mathlib-version build)
- Add 'full-lint-on-main' safety-net job: on main push only, force fresh
  elaboration and re-check linter baselines authoritatively.  Catches any
  regression that incremental missed.

Expected impact: PR Lake build time drops from ~6 min → ~30 s on warm
cache (90 % cache hit; only changed files + transitive consumers
re-elaborate).  Cold cache still ~6 min (one-time per Mathlib bump).
@Xinze-Li-Moqian Xinze-Li-Moqian merged commit e776f6d into main May 19, 2026
3 checks passed
@Xinze-Li-Moqian Xinze-Li-Moqian deleted the ci/incremental-build branch May 19, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant