ci: Only save cache from main (#2946)

This commit is contained in:
Jonas Platte 2024-09-29 21:15:49 +00:00 committed by GitHub
parent fb4b1899eb
commit 928d31d1d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,8 @@ jobs:
with: with:
components: clippy, rustfmt components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check - name: Check
run: cargo clippy --workspace --all-targets --all-features -- -D warnings run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: rustfmt - name: rustfmt
@ -31,6 +33,8 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo doc - name: cargo doc
env: env:
RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests" RUSTDOCFLAGS: "-D rustdoc::all -A rustdoc::private-doc-tests"
@ -43,6 +47,8 @@ jobs:
- uses: taiki-e/install-action@protoc - uses: taiki-e/install-action@protoc
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-hack - name: Install cargo-hack
run: | run: |
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
@ -61,6 +67,8 @@ jobs:
with: with:
toolchain: nightly-2024-06-06 toolchain: nightly-2024-06-06
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-public-api-crates - name: Install cargo-public-api-crates
run: | run: |
cargo install --git https://github.com/davidpdrsn/cargo-public-api-crates cargo install --git https://github.com/davidpdrsn/cargo-public-api-crates
@ -83,6 +91,8 @@ jobs:
with: with:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run tests - name: Run tests
run: cargo test --workspace --all-features --all-targets run: cargo test --workspace --all-features --all-targets
@ -99,6 +109,8 @@ jobs:
with: with:
toolchain: ${{ steps.rust-toolchain.outputs.version }} toolchain: ${{ steps.rust-toolchain.outputs.version }}
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run nightly tests - name: Run nightly tests
working-directory: axum-macros working-directory: axum-macros
run: cargo test run: cargo test
@ -116,6 +128,8 @@ jobs:
- name: "install Rust nightly" - name: "install Rust nightly"
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Select minimal version - name: Select minimal version
run: cargo +nightly update -Z minimal-versions run: cargo +nightly update -Z minimal-versions
- name: Fix up Cargo.lock - name: Fix up Cargo.lock
@ -148,6 +162,8 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run doc tests - name: Run doc tests
run: cargo test --all-features --doc run: cargo test --all-features --doc
@ -176,6 +192,8 @@ jobs:
with: with:
target: armv5te-unknown-linux-musleabi target: armv5te-unknown-linux-musleabi
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check - name: Check
env: env:
# Clang has native cross-compilation support # Clang has native cross-compilation support
@ -200,6 +218,8 @@ jobs:
with: with:
target: wasm32-unknown-unknown target: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check - name: Check
run: > run: >
cargo cargo
@ -213,6 +233,8 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@beta - uses: dtolnay/rust-toolchain@beta
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-sort - name: Install cargo-sort
run: | run: |
cargo install cargo-sort cargo install cargo-sort