Skip to content

Commit 471fb0c

Browse files
committed
Move workarounds to a different file
1 parent c38f55d commit 471fb0c

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

README.md

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -227,44 +227,10 @@ jobs:
227227
## Known practices and workarounds
228228
Following are some of the known practices/workarounds which community has used to fulfill specific requirements. You may choose to use them if suits your use case. Note these are not necessarily the only or the recommended solution.
229229

230-
#### Cache segment restore timeout
231-
A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.8` of `actions/cache` introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.
232-
233-
Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
234-
235-
#### Update a cache
236-
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:
237-
```yaml
238-
- name: update cache on every commit
239-
uses: actions/cache@v3
240-
with:
241-
path: prime-numbers
242-
key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well
243-
restore-keys: |
244-
primes-${{ runner.os }}
245-
```
246-
Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits).
247-
248-
#### Use cache across feature branches
249-
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.
250-
251-
#### Improving cache restore performance on Windows/Using cross-os caching
252-
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.
253-
254-
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:
255-
256-
```yaml
257-
- if: ${{ runner.os == 'Windows' }}
258-
name: Use GNU tar
259-
shell: cmd
260-
run: |
261-
echo "Adding GNU tar to PATH"
262-
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
263-
```
264-
265-
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.
266-
267-
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.
230+
- [Cache segment restore timeout](./workarounds.md#cache-segment-restore-timeout)
231+
- [Update a cache](./workarounds.md#update-a-cache)
232+
- [Use cache across feature branches](./workarounds.md#use-cache-across-feature-branches)
233+
- [Improving cache restore performance on Windows/Using cross-os caching](./workarounds.md#improving-cache-restore-performance-on-windows-using-cross-os-caching)
268234

269235
## Contributing
270236
We would love for you to contribute to `actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

workarounds.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#### Cache segment restore timeout
2+
A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.8` of `actions/cache` introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.
3+
4+
Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
5+
6+
#### Update a cache
7+
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:
8+
```yaml
9+
- name: update cache on every commit
10+
uses: actions/cache@v3
11+
with:
12+
path: prime-numbers
13+
key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well
14+
restore-keys: |
15+
primes-${{ runner.os }}
16+
```
17+
Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits).
18+
19+
#### Use cache across feature branches
20+
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.
21+
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.

0 commit comments

Comments
 (0)