Skip to content

Commit 32556fb

Browse files
authored
Merge pull request #368 from OffchainLabs/jcolvin/ci-cache-restore-keys
Improve CI caching
2 parents 918026a + 1012e0c commit 32556fb

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

.github/actions/ci-setup/action.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ runs:
2121
uses: actions/setup-go@v6
2222
with:
2323
go-version-file: "go.mod"
24+
# The Go caches are managed by the explicit cache steps below.
25+
cache: false
2426

2527
- name: Install wasm-ld
2628
run: |
@@ -39,26 +41,40 @@ runs:
3941
version: v1.0.0
4042

4143
- name: Install cbindgen
42-
run: cargo install --force cbindgen
43-
shell: bash
44+
uses: taiki-e/install-action@0abfcd587b70a713fdaa7fb502c885e2112acb15 # v2
45+
with:
46+
tool: cbindgen@0.29
4447

4548
- name: Cache Go build
4649
uses: actions/cache@v5
4750
with:
4851
path: ~/.cache/go-build
49-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
52+
# github.sha prevents exact-key hits, which would skip the save and
53+
# let the cache go stale.
54+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ github.sha }}
55+
# Stale restores are safe: the build cache is content-addressed.
56+
restore-keys: |
57+
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-
58+
${{ runner.os }}-go-
59+
60+
- name: Cache Go modules
61+
uses: actions/cache@v5
62+
with:
63+
path: ~/go/pkg/mod
64+
# The module cache is determined by go.sum, so an exact key suffices.
65+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
66+
restore-keys: ${{ runner.os }}-go-mod-
5067

51-
- name: Cache Rust build
68+
# Crate sources are immutable, so stale restores are safe.
69+
- name: Cache Cargo registry
5270
uses: actions/cache@v5
5371
with:
5472
path: |
55-
~/.cargo/
56-
target/
57-
crates/wasm-libraries/target/
58-
crates/wasm-libraries/soft-float/
59-
target/etc/initial-machine-cache/
60-
/home/runner/.rustup/toolchains/
61-
key: ${{ runner.os }}-cargo-${{ steps.install-rust.outputs.version }}-${{ hashFiles('Cargo.lock') }}
73+
~/.cargo/registry/index/
74+
~/.cargo/registry/cache/
75+
~/.cargo/git/db/
76+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
77+
restore-keys: ${{ runner.os }}-cargo-registry-
6278

6379
- name: Cache cbrotli
6480
id: cache-cbrotli
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Ignored
2+
- Better cache key handling

0 commit comments

Comments
 (0)