From 217594d21f03e1d397bfb9c02dfbdfce2bd2deb2 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 25 May 2024 23:38:43 +0800 Subject: [PATCH] ci: setup sccache (#3403) --- .github/workflows/ci.yml | 61 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14e8a42d4..0a5120adb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,8 @@ env: RUSTFLAGS: "-D warnings" jobs: - cache: # Warm cache factory for all other CI jobs - name: Check and Build + test: + name: Test strategy: fail-fast: false matrix: @@ -38,21 +38,29 @@ jobs: - os: ubuntu-latest - os: macos-14 runs-on: ${{ matrix.os }} + env: + # https://github.com/mozilla/sccache/blob/main/docs/S3.md + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }} + SCCACHE_ENDPOINT: ${{ secrets.SCCACHE_ENDPOINT }} + SCCACHE_REGION: auto + RUSTC_WRAPPER: sccache + CARGO_INCREMENTAL: 0 + SCCACHE_LOCAL_RW_MODE: steps: - uses: taiki-e/checkout-action@v1 - - - name: Install Rust Toolchain - uses: ./.github/actions/rustup + - uses: ./.github/actions/rustup with: + # warm cache factory for all other CI jobs + # cache `target` directory to avoid download crates save-cache: ${{ github.ref_name == 'main' }} - - - name: Cargo check - run: cargo ck - - # Only need to build the test to create a warm cache on the main branch - - name: Build cache by Cargo Check and Cargo Test - if: ${{ github.ref_name == 'main' }} - run: cargo test --quiet --no-run + # cache build outputs to speed up compilation + - uses: mozilla-actions/sccache-action@v0.0.4 + if: ${{ vars.USE_SCCACHE == 'true' }} + - run: cargo ck + - run: cargo test --no-run + - run: cargo test wasm: name: Check Wasm @@ -186,25 +194,18 @@ jobs: - name: Run doc run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items - test: - name: Test - strategy: - fail-fast: false - matrix: - include: - - os: windows-latest - - os: ubuntu-latest - - os: macos-14 - runs-on: ${{ matrix.os }} - steps: - - uses: taiki-e/checkout-action@v1 - - name: Install Rust - uses: ./.github/actions/rustup - - run: cargo test --quiet - conformance: name: Conformance runs-on: ubuntu-latest + env: + # https://github.com/mozilla/sccache/blob/main/docs/S3.md + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }} + SCCACHE_ENDPOINT: ${{ secrets.SCCACHE_ENDPOINT }} + SCCACHE_REGION: auto + RUSTC_WRAPPER: sccache + CARGO_INCREMENTAL: 0 steps: - uses: taiki-e/checkout-action@v1 @@ -222,6 +223,8 @@ jobs: shared-key: 'conformance' save-cache: ${{ github.ref_name == 'main' }} + - uses: mozilla-actions/sccache-action@v0.0.4 + - name: Clone submodules if: steps.filter.outputs.src == 'true' uses: ./.github/actions/clone-submodules