ci: setup sccache (#3403)

This commit is contained in:
Boshen 2024-05-25 23:38:43 +08:00 committed by GitHub
parent 5c7041bd2a
commit 217594d21f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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