on master help sign in
ci: configure restore-keys for caches (#1806)

`restore-keys` is a configuration option for the actions/cache action which specifies fallback behavior. The [docs][docs] say it best: > When a cache miss occurs, the action searches for alternate keys > called `restore-keys`. > > If you provide `restore-keys`, the `cache` action sequentially > searches for any caches that match the list of `restore-keys`. > ... If there are no exact matches, the action searches for partial > matches of the restore keys. When the action finds a partial match, > the most recent cache is restored to the `path` directory. So this improves caching when there's a miss. For example if I edit `.github/workflows/languages.toml`, the current behavior is that the cache for downloaded grammars will miss and all of them will need to be fetched again. With `restore-keys`, we use the latest published cache as 'good enough', we'll fetch whatever grammars changed, and then at the end we publish a new cache under the new hash. [docs]: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action

commit43fc073cb3de9cb007212e48c9e755a602bccaa2 authorMichael Davis <mcarsondavis@gmail.com> dateSun 13 Mar 2022, 21:44 (5 years ago) parentc94c0d9
1 file changed+13
.github/workflows/build.yml+13
.github/workflows/build.yml+13
@@ -27,18 +27,21 @@ jobs:
2727 with:
2828 path: ~/.cargo/registry
2929 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
30+ restore-keys: ${{ runner.os }}-v2-cargo-registry-
3031
3132 - name: Cache cargo index
3233 uses: actions/cache@v2.1.7
3334 with:
3435 path: ~/.cargo/git
3536 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
37+ restore-keys: ${{ runner.os }}-v2-cargo-index-
3638
3739 - name: Cache cargo target dir
3840 uses: actions/cache@v2.1.7
3941 with:
4042 path: target
4143 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
44+ restore-keys: ${{ runner.os }}-v2-cargo-build-target-
4245
4346 - name: Run cargo check
4447 uses: actions-rs/cargo@v1
@@ -64,18 +67,21 @@ jobs:
6467 with:
6568 path: ~/.cargo/registry
6669 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
70+ restore-keys: ${{ runner.os }}-v2-cargo-registry-
6771
6872 - name: Cache cargo index
6973 uses: actions/cache@v2.1.7
7074 with:
7175 path: ~/.cargo/git
7276 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
77+ restore-keys: ${{ runner.os }}-v2-cargo-index-
7378
7479 - name: Cache cargo target dir
7580 uses: actions/cache@v2.1.7
7681 with:
7782 path: target
7883 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
84+ restore-keys: ${{ runner.os }}-v2-cargo-build-target-
7985
8086 - name: Copy minimal languages config
8187 run: cp .github/workflows/languages.toml ./languages.toml
@@ -85,6 +91,7 @@ jobs:
8591 with:
8692 path: runtime/grammars
8793 key: ${{ runner.os }}-v2-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
94+ restore-keys: ${{ runner.os }}-v2-tree-sitter-grammars-
8895
8996 - name: Run cargo test
9097 uses: actions-rs/cargo@v1
@@ -117,18 +124,21 @@ jobs:
117124 with:
118125 path: ~/.cargo/registry
119126 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
127+ restore-keys: ${{ runner.os }}-v2-cargo-registry-
120128
121129 - name: Cache cargo index
122130 uses: actions/cache@v2.1.7
123131 with:
124132 path: ~/.cargo/git
125133 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
134+ restore-keys: ${{ runner.os }}-v2-cargo-index-
126135
127136 - name: Cache cargo target dir
128137 uses: actions/cache@v2.1.7
129138 with:
130139 path: target
131140 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
141+ restore-keys: ${{ runner.os }}-v2-cargo-build-target-
132142
133143 - name: Run cargo fmt
134144 uses: actions-rs/cargo@v1
@@ -161,18 +171,21 @@ jobs:
161171 with:
162172 path: ~/.cargo/registry
163173 key: ${{ runner.os }}-v2-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
174+ restore-keys: ${{ runner.os }}-v2-cargo-registry-
164175
165176 - name: Cache cargo index
166177 uses: actions/cache@v2.1.6
167178 with:
168179 path: ~/.cargo/git
169180 key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
181+ restore-keys: ${{ runner.os }}-v2-cargo-index-
170182
171183 - name: Cache cargo target dir
172184 uses: actions/cache@v2.1.6
173185 with:
174186 path: target
175187 key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
188+ restore-keys: ${{ runner.os }}-v2-cargo-build-target-
176189
177190 - name: Generate docs
178191 uses: actions-rs/cargo@v1