Skip to content

Commit a2c3e65

Browse files
authored
Unify CI caches (reduce total cache size by 75% ±) (#7610)
* Singular job for creating caches * Use shared cache
1 parent 8108b6a commit a2c3e65

File tree

2 files changed

+143
-26
lines changed

2 files changed

+143
-26
lines changed

.github/workflows/ci.yaml

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ env:
2929
X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR: C:\Program Files\OpenSSL\lib\VC\x64\MD
3030
X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR: C:\Program Files\OpenSSL\include
3131
CARGO_INCREMENTAL: 0
32+
CARGO_PROFILE_TEST_DEBUG: 0
33+
CARGO_PROFILE_DEV_DEBUG: 0
34+
CARGO_PROFILE_RELEASE_DEBUG: 0
3235
CARGO_TERM_COLOR: always
3336

3437
jobs:
@@ -52,9 +55,19 @@ jobs:
5255
with:
5356
components: clippy
5457

55-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
58+
- name: Restore cache
59+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
5660
with:
57-
save-if: ${{ github.ref == 'refs/heads/main' }}
61+
path: |
62+
~/.cargo/bin/
63+
~/.cargo/registry/index/
64+
~/.cargo/registry/cache/
65+
~/.cargo/git/db/
66+
target/
67+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
68+
restore-keys: |
69+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
70+
${{ runner.os }}-stable--
5871
5972
- name: Install macOS dependencies
6073
uses: ./.github/actions/install-macos-deps
@@ -154,7 +167,6 @@ jobs:
154167

155168
- name: Restore cache
156169
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
157-
if: ${{ github.ref != 'refs/heads/main' }} # Never restore on main
158170
with:
159171
path: |
160172
~/.cargo/bin/
@@ -163,9 +175,12 @@ jobs:
163175
~/.cargo/git/db/
164176
target/
165177
# key won't match, will rely on restore-keys
166-
key: cargo-check-${{ runner.os }}-${{ matrix.target }}
178+
key: ${{ runner.os }}-${{ matrix.target }}
167179
restore-keys: |
168-
cargo-check-${{ runner.os }}-${{ matrix.target }}-
180+
${{ runner.os }}-stable-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-
181+
${{ runner.os }}-stable-${{ matrix.target }}-
182+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
183+
${{ runner.os }}-stable--
169184
170185
- uses: dtolnay/rust-toolchain@stable
171186
with:
@@ -194,18 +209,6 @@ jobs:
194209
AR_aarch64_linux_android: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
195210
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
196211

197-
- name: Save cache
198-
if: ${{ github.ref == 'refs/heads/main' }} # only save on main
199-
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
200-
with:
201-
path: |
202-
~/.cargo/bin/
203-
~/.cargo/registry/index/
204-
~/.cargo/registry/cache/
205-
~/.cargo/git/db/
206-
target/
207-
key: cargo-check-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
208-
209212
snippets_cpython:
210213
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
211214
env:
@@ -252,9 +255,19 @@ jobs:
252255

253256
- uses: dtolnay/rust-toolchain@stable
254257

255-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
258+
- name: Restore cache
259+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
256260
with:
257-
save-if: ${{ github.ref == 'refs/heads/main' }}
261+
path: |
262+
~/.cargo/bin/
263+
~/.cargo/registry/index/
264+
~/.cargo/registry/cache/
265+
~/.cargo/git/db/
266+
target/
267+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
268+
restore-keys: |
269+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
270+
${{ runner.os }}-stable--
258271
259272
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
260273

@@ -377,7 +390,6 @@ jobs:
377390
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
378391

379392
- name: restore prek cache
380-
if: ${{ github.ref != 'refs/heads/main' }} # never restore on main
381393
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
382394
with:
383395
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}
@@ -422,9 +434,18 @@ jobs:
422434
toolchain: ${{ env.NIGHTLY_CHANNEL }}
423435
components: miri
424436

425-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
437+
- name: Restore cache
438+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
426439
with:
427-
save-if: ${{ github.ref == 'refs/heads/main' }}
440+
path: |
441+
~/.cargo/bin/
442+
~/.cargo/registry/index/
443+
~/.cargo/registry/cache/
444+
~/.cargo/git/db/
445+
target/
446+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}
447+
restore-keys: |
448+
${{ runner.os }}-
428449
429450
- name: Run tests under miri
430451
run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test -p rustpython-vm -- miri_test
@@ -447,9 +468,20 @@ jobs:
447468
with:
448469
components: clippy
449470

450-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
471+
- name: Restore cache
472+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
451473
with:
452-
save-if: ${{ github.ref == 'refs/heads/main' }}
474+
path: |
475+
~/.cargo/bin/
476+
~/.cargo/registry/index/
477+
~/.cargo/registry/cache/
478+
~/.cargo/git/db/
479+
target/
480+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
481+
restore-keys: |
482+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
483+
${{ runner.os }}-stable--
484+
${{ runner.os }}-
453485
454486
- name: cargo clippy
455487
run: cargo clippy --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings
@@ -522,9 +554,21 @@ jobs:
522554
with:
523555
target: wasm32-wasip1
524556

525-
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
557+
- name: Restore cache
558+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
526559
with:
527-
save-if: ${{ github.ref == 'refs/heads/main' }}
560+
path: |
561+
~/.cargo/bin/
562+
~/.cargo/registry/index/
563+
~/.cargo/registry/cache/
564+
~/.cargo/git/db/
565+
target/
566+
key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
567+
restore-keys: |
568+
${{ runner.os }}-stable-wasm32-wasip1-${{ hashFiles('**/Cargo.toml') }}-
569+
${{ runner.os }}-stable-wasm32-wasip1-
570+
${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}-
571+
${{ runner.os }}-stable--
528572
529573
- name: Setup Wasmer
530574
uses: wasmerio/setup-wasmer@v3
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Update Actions Caches
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
12+
env:
13+
CARGO_INCREMENTAL: 0
14+
CARGO_TERM_COLOR: always
15+
CARGO_PROFILE_TEST_DEBUG: 0
16+
CARGO_PROFILE_DEV_DEBUG: 0
17+
CARGO_PROFILE_RELEASE_DEBUG: 0
18+
CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls,host_env,threading,jit
19+
20+
jobs:
21+
build-caches:
22+
name: Build Caches
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
include:
27+
- os: macos-latest
28+
toolchain: stable
29+
target: ""
30+
- os: ubuntu-latest
31+
toolchain: stable
32+
target: ""
33+
- os: windows-latest
34+
toolchain: stable
35+
target: ""
36+
steps:
37+
- name: Checkout RustPython main branch
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
39+
with:
40+
repository: RustPython/RustPython
41+
ref: main
42+
persist-credentials: false
43+
44+
- name: Setup Rust
45+
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
46+
with:
47+
toolchain: ${{ matrix.toolchain }}
48+
target: ${{ matrix.target }}
49+
50+
- name: Install macos dependencies
51+
uses: ./.github/actions/install-macos-deps
52+
with:
53+
openssl: true
54+
55+
- name: Build dev cache # dev profile used by check & doc
56+
run: cargo build --profile dev ${{ env.CARGO_ARGS }}
57+
58+
- name: Build test cache
59+
run: cargo build --profile test ${{ env.CARGO_ARGS }}
60+
61+
- name: Build release cache
62+
run: cargo build --profile release ${{ env.CARGO_ARGS }}
63+
64+
- name: Save cache
65+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
66+
with:
67+
path: |
68+
~/.cargo/bin/
69+
~/.cargo/registry/index/
70+
~/.cargo/registry/cache/
71+
~/.cargo/git/db/
72+
target/
73+
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}

0 commit comments

Comments
 (0)