From ad8fed3bdd2eacc497cc59ce2e266a359bf9d2e2 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Wed, 23 Oct 2024 17:46:22 -0400 Subject: [PATCH 1/5] Cache all GitHub Actions when running locally. While there, remove unnecessary paths from cache for Bazel job. Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 114 +++++++++++++++++++++++++++++++++---- 1 file changed, 104 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 11de901a..955ab720 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,22 +61,19 @@ 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: path: | ~/.cache/bazel ~/.cache/bazelisk - ~/.cargo/.crates.toml - ~/.cargo/.crates2.json - ~/.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('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 //... @@ -97,6 +102,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/bin + ~/.cargo/registry + ~/.rustup + **/target + key: msrv-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -146,6 +164,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/bin + ~/.cargo/registry + ~/.rustup + **/target + key: stable-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -194,6 +225,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/bin + ~/.cargo/registry + ~/.rustup + **/target + key: nightly-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -240,6 +284,18 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + key: outdated-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -260,6 +316,18 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Cache + if: ${{ env.ACT }} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/bin + ~/.cargo/registry + ~/.rustup + key: audit-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -299,6 +367,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/bin + ~/.cargo/registry + ~/.rustup + **/target + key: example-${{ matrix.example }}-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | @@ -363,6 +444,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/bin + ~/.cargo/registry + ~/.rustup + **/target + key: reactor-${{ matrix.example }}-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + - name: Install dependencies if: ${{ env.ACT }} run: | From 51a8a35594349f83eb52f2991fbbc72f606420bd Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 27 Oct 2024 09:42:10 -0400 Subject: [PATCH 2/5] review: add ~/.cargo/advisory-db (from cargo audit) to the cache. Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 955ab720..56d4060b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -109,6 +109,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -171,6 +172,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -232,6 +234,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -291,6 +294,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -323,6 +327,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -374,6 +379,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup @@ -451,6 +457,7 @@ jobs: path: | ~/.cargo/.crates.toml ~/.cargo/.crates2.json + ~/.cargo/advisory-db ~/.cargo/bin ~/.cargo/registry ~/.rustup From 65bfefbdf7e7068a724e513bacfe9f6f8514977c Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 27 Oct 2024 09:43:23 -0400 Subject: [PATCH 3/5] review: re-add Cargo cache paths to Bazel job. It looks that those rules are not as hermetic as they should be. Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 56d4060b..7e3f5a18 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,6 +67,11 @@ jobs: path: | ~/.cache/bazel ~/.cache/bazelisk + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/advisory-db + ~/.cargo/bin + ~/.cargo/registry ~/go/pkg/mod key: bazel-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} From c7b904b67ea58bf5d4d0592d511c8aa96f68b78b Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 27 Oct 2024 11:02:57 -0400 Subject: [PATCH 4/5] review: add BUILD file to cache key. Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7e3f5a18..096d027f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -73,7 +73,7 @@ jobs: ~/.cargo/bin ~/.cargo/registry ~/go/pkg/mod - key: bazel-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} + key: bazel-${{ hashFiles('BUILD', 'WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }} - name: Install dependencies if: ${{ env.ACT }} From d3ced33e6cc43a35717e9e66e8c8af0acf213383 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Sun, 27 Oct 2024 13:18:41 -0400 Subject: [PATCH 5/5] review: remove .github/workflows/rust.yml from cache keys. Signed-off-by: Piotr Sikora --- .github/workflows/rust.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 096d027f..4559eb6a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -119,7 +119,7 @@ jobs: ~/.cargo/registry ~/.rustup **/target - key: msrv-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: msrv-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -182,7 +182,7 @@ jobs: ~/.cargo/registry ~/.rustup **/target - key: stable-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: stable-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -244,7 +244,7 @@ jobs: ~/.cargo/registry ~/.rustup **/target - key: nightly-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: nightly-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -303,7 +303,7 @@ jobs: ~/.cargo/bin ~/.cargo/registry ~/.rustup - key: outdated-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: outdated-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -336,7 +336,7 @@ jobs: ~/.cargo/bin ~/.cargo/registry ~/.rustup - key: audit-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: audit-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -389,7 +389,7 @@ jobs: ~/.cargo/registry ~/.rustup **/target - key: example-${{ matrix.example }}-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: example-${{ matrix.example }}-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }} @@ -467,7 +467,7 @@ jobs: ~/.cargo/registry ~/.rustup **/target - key: reactor-${{ matrix.example }}-${{ hashFiles('.github/workflows/rust.yml', 'Cargo.toml') }} + key: reactor-${{ matrix.example }}-${{ hashFiles('Cargo.toml') }} - name: Install dependencies if: ${{ env.ACT }}