diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c85943..45036ac 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.6.1 - 2026-10-02 ### Changed diff --git a/README.md b/README.md index 9f6004f..45f533e 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. > [!NOTE] GitHub caching is distinct from Mathlib caching with `lake exe cache get` diff --git a/action.yml b/action.yml index b0bc7ed..08b4171 100644 --- a/action.yml +++ b/action.yml @@ -225,6 +225,15 @@ runs: shell: bash working-directory: ${{ inputs.lake-package-directory }} + - uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 + 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,15 +269,6 @@ runs: shell: bash working-directory: ${{ inputs.lake-package-directory }} - - uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5 - 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' }}