Skip to content

Commit 9b0be58

Browse files
authored
Release compression related changes for windows (#1039)
* Release compression related changes for windows * Update license
1 parent c17f4bf commit 9b0be58

File tree

10 files changed

+963
-423
lines changed

10 files changed

+963
-423
lines changed

.licenses/npm/@actions/cache.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
2828
* Fix zstd not working for windows on gnu tar in issues.
2929
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
3030
* Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml)
31+
* Add support for cross os caching. For example, a cache saved on windows can be restored on ubuntu and vice versa.
3132

3233
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
3334

RELEASES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@
5454
- Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache.
5555

5656
### 3.2.0
57-
- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache
57+
- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache
58+
59+
### 3.2.1
60+
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
61+
- Added support for fallback to gzip to restore old caches on windows.
62+
- Added logs for cache version in case of a cache miss.

dist/restore-only/index.js

Lines changed: 236 additions & 98 deletions
Large diffs are not rendered by default.

dist/restore/index.js

Lines changed: 236 additions & 98 deletions
Large diffs are not rendered by default.

dist/save-only/index.js

Lines changed: 236 additions & 98 deletions
Large diffs are not rendered by default.

dist/save/index.js

Lines changed: 236 additions & 98 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cache",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"private": true,
55
"description": "Cache dependencies and build outputs",
66
"main": "dist/restore/index.js",
@@ -23,7 +23,7 @@
2323
"author": "GitHub",
2424
"license": "MIT",
2525
"dependencies": {
26-
"@actions/cache": "^3.0.6",
26+
"@actions/cache": "^3.1.0",
2727
"@actions/core": "^1.10.0",
2828
"@actions/exec": "^1.1.1",
2929
"@actions/io": "^1.1.2"

tips-and-workarounds.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ A cache today is immutable and cannot be updated. But some use cases require the
1919
## Use cache across feature branches
2020
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.
2121
22-
## Improving cache restore performance on Windows/Using cross-os caching
23-
Currently, cache restore is slow on Windows due to tar being inherently slow and the compression algorithm `gzip` in use. `zstd` is the default algorithm in use on linux and macos. It was disabled on Windows due to issues with bsd tar(libarchive), the tar implementation in use on Windows.
24-
25-
To improve cache restore performance, we can re-enable `zstd` as the compression algorithm using the following workaround. Add the following step to your workflow before the cache step:
26-
27-
```yaml
28-
- if: ${{ runner.os == 'Windows' }}
29-
name: Use GNU tar
30-
shell: cmd
31-
run: |
32-
echo "Adding GNU tar to PATH"
33-
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
34-
```
35-
36-
The `cache` action will use GNU tar instead of bsd tar on Windows. This should work on all Github Hosted runners as it is. For self-hosted runners, please ensure you have GNU tar and `zstd` installed.
37-
38-
The above workaround is also needed if you wish to use cross-os caching since difference of compression algorithms will result in different cache versions for the same cache key. So the above workaround will ensure `zstd` is used for caching on all platforms thus resulting in the same cache version for the same cache key.
39-
4022
## Force deletion of caches overriding default cache eviction policy
4123
Caches have [branch scope restriction](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache) in place. This means that if caches for a specific branch are using a lot of storage quota, it may result into more frequently used caches from `default` branch getting thrashed. For example, if there are many pull requests happening on a repo and are creating caches, these cannot be used in default branch scope but will still occupy a lot of space till they get cleaned up by [eviction policy](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy). But sometime we want to clean them up on a faster cadence so as to ensure default branch is not thrashing. In order to achieve this, [gh-actions-cache cli](https://github.com/actions/gh-actions-cache/) can be used to delete caches for specific branches.
4224

0 commit comments

Comments
 (0)