From 23d218be27518b96956aa773b8021a3dbe10346d Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Sun, 14 Aug 2022 14:35:33 +0530 Subject: [PATCH 1/3] Add section for good practices --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index d2aa0fa..6729fbb 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,23 @@ jobs: run: ./generate-primes -d prime-numbers ``` +## Good practices +These are some of the good practices which can be used to fulfill certain requirements and are not necessarily the only or the recommended solution. + +- **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: + ``` + - name: update cache on every commit + uses: actions/cache@v3 + with: + path: prime-numbers + key: primes-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well + restore-keys: | + primes-${{ runner.os }} + ``` + Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits). + +- **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 same base branch, a good way to achieve this is to ensure that the base branch has a cache. This cache will then be consumable by both feature branches. + ## 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. From fb1d96e3ff89aef0a0ff9728c18313205a8c3726 Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Tue, 23 Aug 2022 13:19:05 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6729fbb..1e1f042 100644 --- a/README.md +++ b/README.md @@ -219,10 +219,11 @@ jobs: run: ./generate-primes -d prime-numbers ``` -## Good practices -These are some of the good practices which can be used to fulfill certain requirements and are not necessarily the only or the recommended solution. +## Known practices and workarounds +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. -- **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: +#### 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: ``` - name: update cache on every commit uses: actions/cache@v3 @@ -234,7 +235,8 @@ These are some of the good practices which can be used to fulfill certain requir ``` Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits). -- **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 same base branch, a good way to achieve this is to ensure that the base branch has a cache. This cache will then be consumable by both feature branches. +#### 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 same base branch, a good way to achieve this is to ensure that the base branch has a cache. This cache will then be consumable by both feature branches. ## 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. From 8a9a57869fd43cc3d677f1a33c39d1da20ec875f Mon Sep 17 00:00:00 2001 From: Bishal Prasad Date: Tue, 23 Aug 2022 15:20:27 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e1f042..d3f1411 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ A cache today is immutable and cannot be updated. But some use cases require the Please note that this will create a new cache on every run and hence will consume the cache [quota](#cache-limits). #### 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 same base branch, a good way to achieve this is to ensure that the base branch has a cache. This cache will then be consumable by both 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. ## 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.