From 84d74e4bca74b18bf8b884eb36655526d6c9c061 Mon Sep 17 00:00:00 2001 From: Shahar Naveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Wed, 15 Apr 2026 07:19:17 +0200 Subject: [PATCH] =?UTF-8?q?Unify=20CI=20caches=20(reduce=20total=20cache?= =?UTF-8?q?=20size=20by=2075%=20=C2=B1)=20(#7610)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Singular job for creating caches * Use shared cache --- .github/workflows/ci.yaml | 96 +++++++++++++++++++++-------- .github/workflows/update-caches.yml | 73 ++++++++++++++++++++++ 2 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/update-caches.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26e9b85dd..cab7428e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,6 +29,9 @@ env: X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR: C:\Program Files\OpenSSL\lib\VC\x64\MD X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR: C:\Program Files\OpenSSL\include CARGO_INCREMENTAL: 0 + CARGO_PROFILE_TEST_DEBUG: 0 + CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_PROFILE_RELEASE_DEBUG: 0 CARGO_TERM_COLOR: always jobs: @@ -52,9 +55,19 @@ jobs: with: components: clippy - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - name: Restore cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: - save-if: ${{ github.ref == 'refs/heads/main' }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}- + restore-keys: | + ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-- - name: Install macOS dependencies uses: ./.github/actions/install-macos-deps @@ -154,7 +167,6 @@ jobs: - name: Restore cache uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 - if: ${{ github.ref != 'refs/heads/main' }} # Never restore on main with: path: | ~/.cargo/bin/ @@ -163,9 +175,12 @@ jobs: ~/.cargo/git/db/ target/ # key won't match, will rely on restore-keys - key: cargo-check-${{ runner.os }}-${{ matrix.target }} + key: ${{ runner.os }}-${{ matrix.target }} restore-keys: | - cargo-check-${{ runner.os }}-${{ matrix.target }}- + ${{ runner.os }}-stable-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-${{ matrix.target }}- + ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-- - uses: dtolnay/rust-toolchain@stable with: @@ -194,18 +209,6 @@ jobs: AR_aarch64_linux_android: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang - - name: Save cache - if: ${{ github.ref == 'refs/heads/main' }} # only save on main - uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: cargo-check-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }} - snippets_cpython: if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }} env: @@ -252,9 +255,19 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - name: Restore cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: - save-if: ${{ github.ref == 'refs/heads/main' }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}- + restore-keys: | + ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-- - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 @@ -377,7 +390,6 @@ jobs: uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2 - name: restore prek cache - if: ${{ github.ref != 'refs/heads/main' }} # never restore on main uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: key: prek-${{ hashFiles('.pre-commit-config.yaml') }} @@ -422,9 +434,18 @@ jobs: toolchain: ${{ env.NIGHTLY_CHANNEL }} components: miri - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - name: Restore cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: - save-if: ${{ github.ref == 'refs/heads/main' }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}- - name: Run tests under miri run: cargo +${{ env.NIGHTLY_CHANNEL }} miri test -p rustpython-vm -- miri_test @@ -447,9 +468,20 @@ jobs: with: components: clippy - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - name: Restore cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: - save-if: ${{ github.ref == 'refs/heads/main' }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}- + restore-keys: | + ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-- + ${{ runner.os }}- - name: cargo clippy run: cargo clippy --manifest-path=crates/wasm/Cargo.toml -- -Dwarnings @@ -522,9 +554,21 @@ jobs: with: target: wasm32-wasip1 - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - name: Restore cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: - save-if: ${{ github.ref == 'refs/heads/main' }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}- + restore-keys: | + ${{ runner.os }}-stable-wasm32-wasip1-${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-wasm32-wasip1- + ${{ runner.os }}-stable--${{ hashFiles('**/Cargo.toml') }}- + ${{ runner.os }}-stable-- - name: Setup Wasmer uses: wasmerio/setup-wasmer@v3 diff --git a/.github/workflows/update-caches.yml b/.github/workflows/update-caches.yml new file mode 100644 index 000000000..73464d064 --- /dev/null +++ b/.github/workflows/update-caches.yml @@ -0,0 +1,73 @@ +name: Update Actions Caches + +permissions: + contents: read + +on: + workflow_dispatch: + push: + branches: + - main + +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + CARGO_PROFILE_TEST_DEBUG: 0 + CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_PROFILE_RELEASE_DEBUG: 0 + CARGO_ARGS: --no-default-features --features stdlib,importlib,stdio,encodings,sqlite,ssl-rustls,host_env,threading,jit + +jobs: + build-caches: + name: Build Caches + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: macos-latest + toolchain: stable + target: "" + - os: ubuntu-latest + toolchain: stable + target: "" + - os: windows-latest + toolchain: stable + target: "" + steps: + - name: Checkout RustPython main branch + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: RustPython/RustPython + ref: main + persist-credentials: false + + - name: Setup Rust + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 + with: + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.target }} + + - name: Install macos dependencies + uses: ./.github/actions/install-macos-deps + with: + openssl: true + + - name: Build dev cache # dev profile used by check & doc + run: cargo build --profile dev ${{ env.CARGO_ARGS }} + + - name: Build test cache + run: cargo build --profile test ${{ env.CARGO_ARGS }} + + - name: Build release cache + run: cargo build --profile release ${{ env.CARGO_ARGS }} + + - name: Save cache + uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}