Skip to content

Commit 6079465

Browse files
committed
local cache
1 parent b0616e0 commit 6079465

File tree

1 file changed

+70
-131
lines changed

1 file changed

+70
-131
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
CARGO_TERM_COLOR: always
1717
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
1818
RUSTFLAGS: -C link-arg=-fuse-ld=mold
19-
19+
LOCAL_CACHE_BASE_PATH: /gha-local-cache
2020

2121
jobs:
2222
fmt:
@@ -27,20 +27,16 @@ jobs:
2727
submodules: recursive
2828
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
2929

30-
- uses: Swatinem/rust-cache@v2
30+
- name: Restore local Rust cache
31+
uses: khj809/github-action-cache-local-fs/restore@v1
3132
with:
32-
shared-key: rust-ci-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
33-
add-job-id-key: false
34-
add-rust-environment-hash-key: false
35-
workspaces: |
36-
. -> target
37-
test-integration -> target
38-
cache-targets: false
39-
cache-all-crates: false
40-
cache-workspace-crates: false
41-
cache-bin: false
42-
cache-on-failure: true
43-
save-if: false
33+
path: |
34+
/cargo-home/registry
35+
/cargo-home/git
36+
target
37+
test-integration/target
38+
key: rust-ci-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
39+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
4440

4541
- name: Format check
4642
run: make ci-fmt
@@ -58,20 +54,16 @@ jobs:
5854
submodules: recursive
5955
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
6056

61-
- uses: Swatinem/rust-cache@v2
57+
- name: Restore local Rust cache
58+
uses: khj809/github-action-cache-local-fs/restore@v1
6259
with:
63-
shared-key: rust-ci-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
64-
add-job-id-key: false
65-
add-rust-environment-hash-key: false
66-
workspaces: |
67-
. -> target
68-
test-integration -> target
69-
cache-targets: true
70-
cache-all-crates: false
71-
cache-workspace-crates: true
72-
cache-bin: false
73-
cache-on-failure: true
74-
save-if: false
60+
path: |
61+
/cargo-home/registry
62+
/cargo-home/git
63+
target
64+
test-integration/target
65+
key: rust-ci-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
66+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
7567

7668
- name: Lint
7769
run: make ci-lint
@@ -89,24 +81,33 @@ jobs:
8981
submodules: recursive
9082
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
9183

92-
- uses: Swatinem/rust-cache@v2
84+
- name: Restore local Rust cache
85+
id: rust-cache-restore
86+
uses: khj809/github-action-cache-local-fs/restore@v1
9387
with:
94-
shared-key: rust-ci-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
95-
add-job-id-key: false
96-
add-rust-environment-hash-key: false
97-
workspaces: |
98-
. -> target
99-
test-integration -> target
100-
cache-targets: true
101-
cache-all-crates: false
102-
cache-workspace-crates: true
103-
cache-bin: false
104-
cache-on-failure: true
105-
save-if: true
88+
path: |
89+
/cargo-home/registry
90+
/cargo-home/git
91+
target
92+
test-integration/target
93+
key: rust-ci-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
94+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
10695

10796
- name: Unit tests
10897
run: make ci-test-unit
10998

99+
- name: Save local Rust cache
100+
if: success()
101+
uses: khj809/github-action-cache-local-fs/save@v1
102+
with:
103+
path: |
104+
/cargo-home/registry
105+
/cargo-home/git
106+
target
107+
test-integration/target
108+
key: ${{ steps.rust-cache-restore.outputs.cache-primary-key }}
109+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
110+
110111
build:
111112
needs: [fmt, lint, unit-tests]
112113
runs-on: self-hosted
@@ -116,20 +117,17 @@ jobs:
116117
submodules: recursive
117118
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
118119

119-
- uses: Swatinem/rust-cache@v2
120+
- name: Restore local Rust cache
121+
id: rust-cache-restore
122+
uses: khj809/github-action-cache-local-fs/restore@v1
120123
with:
121-
shared-key: integration-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
122-
add-job-id-key: false
123-
add-rust-environment-hash-key: false
124-
workspaces: |
125-
. -> target
126-
test-integration -> target
127-
cache-targets: true
128-
cache-all-crates: false
129-
cache-workspace-crates: true
130-
cache-bin: false
131-
cache-on-failure: true
132-
save-if: true
124+
path: |
125+
/cargo-home/registry
126+
/cargo-home/git
127+
target
128+
test-integration/target
129+
key: integration-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
130+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
133131

134132
- name: Build project
135133
run: cargo build --locked
@@ -145,38 +143,17 @@ jobs:
145143
make -C test-integration programs
146144
make chainlink-prep-programs -C test-integration/test-chainlink
147145
148-
- name: Pack only SBF artifacts
149-
run: |
150-
set -euo pipefail
151-
152-
mkdir -p ci-artifacts/test-integration-deploy
153-
mkdir -p ci-artifacts/root-deploy
154-
mkdir -p ci-artifacts/chainlink-artifacts
155-
156-
if [ -d "test-integration/target/deploy" ]; then
157-
find test-integration/target/deploy -mindepth 1 -maxdepth 1 -exec cp -r {} ci-artifacts/test-integration-deploy/ \;
158-
else
159-
echo "::warning::test-integration/target/deploy not found"
160-
fi
161-
162-
if [ -d "target/deploy" ]; then
163-
find target/deploy -mindepth 1 -maxdepth 1 -exec cp -r {} ci-artifacts/root-deploy/ \;
164-
else
165-
echo "::warning::target/deploy not found"
166-
fi
167-
168-
if [ -d "test-integration/test-chainlink/target/deploy" ]; then
169-
find test-integration/test-chainlink/target/deploy -mindepth 1 -maxdepth 1 -exec cp -r {} ci-artifacts/chainlink-artifacts/ \;
170-
else
171-
echo "::warning::test-integration/test-chainlink/target/deploy not found"
172-
fi
173-
174-
- uses: actions/upload-artifact@v4
146+
- name: Save local Rust cache
147+
if: success()
148+
uses: khj809/github-action-cache-local-fs/save@v1
175149
with:
176-
name: sbf-artifacts-${{ github.sha }}
177-
path: ci-artifacts
178-
if-no-files-found: warn
179-
retention-days: 3
150+
path: |
151+
/cargo-home/registry
152+
/cargo-home/git
153+
target
154+
test-integration/target
155+
key: ${{ steps.rust-cache-restore.outputs.cache-primary-key }}
156+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
180157

181158
integration-tests:
182159
needs: build
@@ -203,54 +180,16 @@ jobs:
203180
submodules: recursive
204181
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
205182

206-
- uses: Swatinem/rust-cache@v2
183+
- name: Restore local Rust cache
184+
uses: khj809/github-action-cache-local-fs/restore@v1
207185
with:
208-
shared-key: integration-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
209-
add-job-id-key: false
210-
add-rust-environment-hash-key: false
211-
workspaces: |
212-
. -> target
213-
test-integration -> target
214-
cache-targets: true
215-
cache-all-crates: false
216-
cache-workspace-crates: true
217-
cache-bin: false
218-
cache-on-failure: true
219-
save-if: false
220-
221-
- uses: actions/download-artifact@v4
222-
with:
223-
name: sbf-artifacts-${{ github.sha }}
224-
path: ci-artifacts
225-
226-
- name: Restore SBF artifacts only
227-
run: |
228-
set -euo pipefail
229-
230-
mkdir -p test-integration/target/deploy
231-
mkdir -p target/deploy
232-
mkdir -p test-integration/test-chainlink/target/deploy
233-
234-
if [ -d "ci-artifacts/test-integration-deploy" ]; then
235-
find ci-artifacts/test-integration-deploy -mindepth 1 -maxdepth 1 -exec cp -r {} test-integration/target/deploy/ \;
236-
find test-integration/target/deploy -type f -exec touch {} +
237-
else
238-
echo "::warning::No cached test-integration deploy artifacts found"
239-
fi
240-
241-
if [ -d "ci-artifacts/root-deploy" ]; then
242-
find ci-artifacts/root-deploy -mindepth 1 -maxdepth 1 -exec cp -r {} target/deploy/ \;
243-
find target/deploy -type f -exec touch {} +
244-
else
245-
echo "::warning::No cached root deploy artifacts found"
246-
fi
247-
248-
if [ -d "ci-artifacts/chainlink-artifacts" ]; then
249-
find ci-artifacts/chainlink-artifacts -mindepth 1 -maxdepth 1 -exec cp -r {} test-integration/test-chainlink/target/deploy/ \;
250-
find test-integration/test-chainlink/target/deploy -type f -exec touch {} +
251-
else
252-
echo "::warning::No cached chainlink deploy artifacts found"
253-
fi
186+
path: |
187+
/cargo-home/registry
188+
/cargo-home/git
189+
target
190+
test-integration/target
191+
key: integration-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'test-integration/Cargo.lock', 'rust-toolchain.toml', 'test-integration/rust-toolchain.toml') }}
192+
cache-base-path: ${{ env.LOCAL_CACHE_BASE_PATH }}
254193

255194
- name: Run integration test
256195
env:

0 commit comments

Comments
 (0)