Skip to content

Adopt setup + post-step cache pattern (don't run commands in the action) #154

@javier-pm

Description

@javier-pm

Problem

The action currently runs Lake commands (build, lint, mathlib cache) and saves the cache during its own execution, before any user-defined steps run. This means artifacts produced by subsequent steps (the user's own lake build, tests, etc.) are never cached.

Users who set build: false and run their own commands get no benefit from the cache — every CI run rebuilds from scratch.

Precedent: Gradle Actions

gradle/actions had the exact same problem. The original action ran Gradle commands and cached before user steps. They redesigned it into setup-gradle:

  • Setup step: Install Gradle + restore cache
  • Post step: Save cache (after all user steps complete)

This ensures the cache always reflects the final build state.

Proposal

The action's core responsibilities should be:

  1. Setup step: Install the Lean toolchain + restore cache
  2. Post step: Save cache after all user steps have run

Everything else — lake build, lake lint — should be the user's own workflow steps.

- uses: leanprover/lean-action@v2
  with:
    lake-package-directory: packages

# User controls what runs
- run: make build
- run: make lint
- run: make test

# Post step (automatic): lean-action saves the cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions