From eb8b610ee6aa7053a5628f75610a7e9b32eb2278 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 25 Aug 2022 13:14:23 +0000 Subject: [PATCH] Add zstd workaround to README. Add yaml formatting to code blocks. Move Cache segment restore to Known Practices section. --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cbace0..a5bb1b8 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit #### Update a cache A cache today is immutable and cannot be updated. But some use cases require the cache to be saved even though there was a "hit" during restore. To do so, use a `key` which is unique for every run and use `restore-keys` to restore the nearest cache. For example: - ``` + ```yaml - name: update cache on every commit uses: actions/cache@v3 with: @@ -248,6 +248,23 @@ A cache today is immutable and cannot be updated. But some use cases require the #### Use cache across feature branches Reusing cache across feature branches is not allowed today to provide cache [isolation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache). However if both feature branches are from the default branch, a good way to achieve this is to ensure that the default branch has a cache. This cache will then be consumable by both feature branches. +#### Improving cache restore performance on Windows +Currently, cache restore is slow on Windows due to both tar being slow and the compression algorithm being used is `gzip`. Zstd was disabled on windows due to issues with bsd tar(libarchive) which is the tar implementation in use on Windows. To improve cache restore performance, we can re-enable `zstd` as the compression algorithm using the following workaround by using GNU tar instead. + +Add the following step to your workflow before the cache step: + +```yaml + - if: ${{ runner.os == 'Windows' }} + name: Use GNU tar + shell: cmd + run: | + echo "Adding GNU tar to PATH" + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" +``` + +This should work on all Github Hosted runners as it is. For self-hosted runners, please ensure you have GNU tar and `zstd` installed. + + ## Contributing We would love for you to contribute to `actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.