From 53769674e278411460bc532fb27ede8d6f16cc7e Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 27 Oct 2024 13:29:32 -0400 Subject: [PATCH] Cache artifacts in all GitHub Actions when testing locally. (#278) Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 118 +++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2a3702d0..2fd1fa27 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,6 +38,14 @@ jobs: with: go-version: '^1.16' + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod + key: licenses-${{ hashFiles('.github/workflows/rust.yml') }} + - name: Check licenses run: | go install github.com/google/addlicense@latest @@ -53,11 +61,6 @@ jobs: with: go-version: '^1.16' - - name: Install dependencies - if: ${{ env.ACT }} - run: | - go install github.com/bazelbuild/bazelisk@v1.19.0 - - name: Cache uses: actions/cache@v2 with: @@ -66,9 +69,16 @@ jobs: ~/.cache/bazelisk ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry - key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} + ~/go/pkg/mod + key: bazel-${{ hashFiles('BUILD', 'WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} + + - name: Install dependencies + if: ${{ env.ACT }} + run: | + go install github.com/bazelbuild/bazelisk@v1.19.0 - name: Build (wasm32-unknown-unknown) run: bazelisk --noworkspace_rc build --noenable_bzlmod --platforms=@rules_rust//rust/platform:wasm //... @@ -96,6 +106,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + **/target + key: msrv-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -145,6 +169,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + **/target + key: stable-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -193,6 +231,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + **/target + key: nightly-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -239,6 +291,19 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + key: outdated-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -259,6 +324,19 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + key: audit-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -298,6 +376,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + **/target + key: example-${{ matrix.example }}-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -364,6 +456,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + **/target + key: reactor-${{ matrix.example }}-${{ hashFiles('Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: |