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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- save the GitHub cache after testing and linting so their build artifacts can be reused, preserving caching after test or lint failures and skipping saves on an exact cache hit

## v1.6.1 - 2026-10-02

### Changed
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ however if you encounter an issue when using a different runner, please still op

## Caching `.lake` directory with GitHub's `actions\cache`
By default, `lean-action` uses [`actions\cache`](https://github.com/actions/cache) to cache the `.lake` directory and speed up builds.
The cache is saved after building, testing, and linting, so it includes artifacts produced by all three steps.
A test or lint failure still allows completed build artifacts to be cached; setup or build failures do not.
Saving is skipped when the exact cache key was restored.

> [!NOTE]
GitHub caching is distinct from Mathlib caching with `lake exe cache get`
Expand Down
18 changes: 12 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ runs:
working-directory: ${{ inputs.lake-package-directory }}

- uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5
id: cache-restore
if: ${{ inputs.use-github-cache == 'true' }}
with:
path: ${{ inputs.lake-package-directory }}/.lake
Expand Down Expand Up @@ -302,12 +303,6 @@ runs:
shell: bash
working-directory: ${{ inputs.lake-package-directory }}

- uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5
if: ${{ inputs.use-github-cache == 'true' }}
with:
path: ${{ inputs.lake-package-directory }}/.lake
key: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles(format('{0}/lean-toolchain', inputs.lake-package-directory)) }}-${{ hashFiles(format('{0}/lake-manifest.json', inputs.lake-package-directory)) }}-${{ github.sha }}

- name: test ${{ github.repository }}
id: test
if: ${{ steps.config.outputs.run-lake-test == 'true'}}
Expand All @@ -331,6 +326,17 @@ runs:
shell: bash
working-directory: ${{ inputs.lake-package-directory }}

- uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5
# Keep successful build artifacts even when tests or linting fail.
# Failures before those steps must still prevent saving the cache.
if: >-
${{ !cancelled() && inputs.use-github-cache == 'true' &&
steps.cache-restore.outputs.cache-hit != 'true' &&
(success() || steps.test.outcome == 'failure' || steps.lint.outcome == 'failure') }}
with:
path: ${{ inputs.lake-package-directory }}/.lake
key: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles(format('{0}/lean-toolchain', inputs.lake-package-directory)) }}-${{ hashFiles(format('{0}/lake-manifest.json', inputs.lake-package-directory)) }}-${{ github.sha }}

- name: check reservoir eligibility
if: ${{ inputs.check-reservoir-eligibility == 'true' }}
# Passes in the private status, number of stars, and license id of the repository to check_reservoir_eligibility.sh script
Expand Down
Loading