diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3f53f6..ce5470a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -241,7 +241,7 @@ jobs: uses: ./ with: packages: bash-completion - package-cache-key: testing-cache + cache: enabled add-to-path: false - name: Delete Cygwin installation and cache run: | @@ -250,7 +250,7 @@ jobs: - name: Reinstall Cygwin only uses: ./ with: - package-cache-key: testing-cache + cache: enabled add-to-path: false - name: Find bash-completion in the package cache shell: C:\cygwin\bin\bash.exe --noprofile --norc -e -o pipefail -o igncr {0} diff --git a/README.md b/README.md index 2df1308..e8582b0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Parameters | site | http://mirrors.kernel.org/sourceware/cygwin/ | Mirror site to install from | check-sig | true | Whether to check the setup.ini signature | add-to-path | true | Whether to add Cygwin's `/bin` directory to the system `PATH` -| package-cache-key | '' | The key to use for caching downloaded packages. +| cache | disabled | Whether to cache the package downloads Line endings ------------ @@ -91,9 +91,8 @@ Caching If you're likely to do regular builds, you might want to store the packages locally rather than needing to download them from the Cygwin mirrors on every -build. Set `package-cache-key` to some string (e.g. `cygwin-package-cache`), -and the action will use [GitHub's dependency caching][0] to store downloaded -package files between runs. +build. Set `cache` to `enabled` and the action will use [GitHub's dependency +caching][0] to store downloaded package files between runs. [0]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows @@ -102,6 +101,25 @@ expense of taking slightly longer before and after the installation to check and potentially update the cache. The installer will still check for updated packages, and will download new packages if the cached ones are out of date +In certain circumstances you might want to ignore any existing caches but still +store a new one, or restore a cache but not write one. Do this by setting +`cache` to `saveonly` or `restoreonly` as appropriate. This is particularly +useful when calling the action multiple times in the same run, where you +probably want to restore the cache the first time the action is called, then +save it the last time it is called. + +You should make sure to clear these caches every so often. This action, like +the underlying Cygwin installer, doesn't remove old package files from its +download directory, so if you don't clear the caches occasionally (and you run +builds often enough that GitHub doesn't do it for you automatically) you'll +find the caches keep getting larger as they gain more and more outdated and +unused packages. Either [delete them manually][1], [use a separate action or +API call][2], or do occasional runs with `saveonly` to create a fresher small +cache. + +[1]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#deleting-cache-entries +[2]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#deleting-cache-entries + Mirrors and signatures ---------------------- diff --git a/action.yml b/action.yml index 8cef84c..34ffcbc 100644 --- a/action.yml +++ b/action.yml @@ -26,24 +26,26 @@ inputs: description: Should Cygwin's bin directory be added to the system PATH? required: false default: true - package-cache-key: - description: Key prefix to use for package caches + cache: + description: Cache package downloads for speed required: false - default: '' + default: disabled runs: using: "composite" steps: - uses: actions/cache/restore@v3 - if: inputs.package-cache-key != '' + if: inputs.cache == 'enabled' || inputs.cache == 'restoreonly' with: - key: ${{ inputs.package-cache-key }}-${{ github.run_id }}-${{ github.run_attempt }} + key: cygwin-install-action-packages-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ github.action }} path: C:\cygwin-packages restore-keys: - ${{ inputs.package-cache-key }}-${{ github.run_id }}- - ${{ inputs.package-cache-key }}- + cygwin-install-action-packages-${{ github.run_id }}-${{ github.job }}-${{ github.run_attempt }}- + cygwin-install-action-packages-${{ github.run_id }}-${{ github.job }}- + cygwin-install-action-packages-${{ github.run_id }}- + cygwin-install-action-packages- - - if: inputs.package-cache-key != '' + - if: inputs.cache == 'enabled' || inputs.cache == 'restoreonly' working-directory: C:\ shell: bash run: | @@ -105,7 +107,7 @@ runs: & C:\setup.exe $args | Out-Default shell: powershell - - if: inputs.package-cache-key != '' + - if: inputs.cache == 'enabled' || inputs.cache == 'saveonly' id: refresh-cache working-directory: C:\ shell: bash @@ -122,7 +124,7 @@ runs: - if: steps.refresh-cache.outputs.update_package_cache != '' uses: actions/cache/save@v3 with: - key: ${{ inputs.package-cache-key }}-${{ github.run_id }}-${{ github.run_attempt }} + key: cygwin-install-action-packages-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ github.action }} path: C:\cygwin-packages - if: ${{ inputs.add-to-path == 'true' }}