Skip to content

Commit 4723a57

Browse files
authored
Revert compression changes related to windows but keep version logging (#1049)
* Revert compression changes related to windows due to symlink issues * Added tips and workarounds for cross os
1 parent d1507cc commit 4723a57

File tree

10 files changed

+427
-878
lines changed

10 files changed

+427
-878
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ 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.
3231

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

@@ -245,6 +244,7 @@ Following are some of the known practices/workarounds which community has used t
245244
- [Cache segment restore timeout](./tips-and-workarounds.md#cache-segment-restore-timeout)
246245
- [Update a cache](./tips-and-workarounds.md#update-a-cache)
247246
- [Use cache across feature branches](./tips-and-workarounds.md#use-cache-across-feature-branches)
247+
- [Improving cache restore performance on Windows/Using cross-os caching](./tips-and-workarounds.md#improving-cache-restore-performance-on-windows-using-cross-os-caching)
248248
- [Force deletion of caches overriding default cache eviction policy](./tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy)
249249

250250
#### Windows environment variables

RELEASES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@
5959
### 3.2.1
6060
- 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))
6161
- Added support for fallback to gzip to restore old caches on windows.
62-
- Added logs for cache version in case of a cache miss.
62+
- Added logs for cache version in case of a cache miss.
63+
64+
### 3.2.2
65+
- Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows.

dist/restore-only/index.js

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

dist/restore/index.js

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

dist/save-only/index.js

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

dist/save/index.js

Lines changed: 98 additions & 216 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.1",
3+
"version": "3.2.2",
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.1.0",
26+
"@actions/cache": "^3.1.1",
2727
"@actions/core": "^1.10.0",
2828
"@actions/exec": "^1.1.1",
2929
"@actions/io": "^1.1.2"

tips-and-workarounds.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ 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+
2240
## Force deletion of caches overriding default cache eviction policy
2341
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.
2442

0 commit comments

Comments
 (0)