diff --git a/CHANGELOG.md b/CHANGELOG.md index 6671708..16b1696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- restore the GitHub cache before automatic configuration and `mk_all-check`, so those steps can reuse cached dependencies and build artifacts + ## v1.7.0 - 2026-10-27 ### Changed diff --git a/README.md b/README.md index 6f66b53..4c2d082 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ 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 GitHub cache is restored before automatic configuration and `mk_all-check`, so those steps can reuse cached dependencies and build artifacts. 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. diff --git a/action.yml b/action.yml index ebf11cf..23c76bb 100644 --- a/action.yml +++ b/action.yml @@ -225,6 +225,16 @@ runs: shell: bash 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 + # cache key includes the operating system, the architecture (X86, X64, ARM, ARM64), the Lake manifest, and the git commit hash + 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 }} + # if no cache hit, fall back to the cache from previous commit + restore-keys: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles(format('{0}/lean-toolchain', inputs.lake-package-directory)) }}-${{ hashFiles(format('{0}/lake-manifest.json', inputs.lake-package-directory)) }} + - name: configure `lean-action` id: config env: @@ -260,16 +270,6 @@ runs: shell: bash 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 - # cache key includes the operating system, the architecture (X86, X64, ARM, ARM64), the Lake manifest, and the git commit hash - 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 }} - # if no cache hit, fall back to the cache from previous commit - restore-keys: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles(format('{0}/lean-toolchain', inputs.lake-package-directory)) }}-${{ hashFiles(format('{0}/lake-manifest.json', inputs.lake-package-directory)) }} - - name: detect mathlib # only detect Mathlib if the user did not provide the mathlib-cache input if: ${{ inputs.use-mathlib-cache == 'auto' }}