From 3c7665d1902d1be5a91480be0559c9996382c65a Mon Sep 17 00:00:00 2001 From: Maycon Amaro <131882788+mayconamaroCW@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:27:05 -0300 Subject: [PATCH] ci: refactor cache policy (#634) * include cargo toml in cache key * deprecate stable debug * create rocks cache * disable rust logs * fix: enable release for e2e --- .github/workflows/_setup-e2e.yml | 16 ++++++++++------ .github/workflows/doc-test.yml | 3 +-- .github/workflows/docs-release.yml | 3 +-- .github/workflows/e2e-contracts-postgres.yml | 5 ++--- .github/workflows/e2e-contracts-rocks.yml | 6 +++--- .github/workflows/e2e-contracts.yml | 5 ++--- .github/workflows/e2e-test.yml | 1 + .github/workflows/int-test.yml | 3 +-- .github/workflows/lint-check.yml | 3 +-- .github/workflows/unit-test.yml | 3 +-- 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/_setup-e2e.yml b/.github/workflows/_setup-e2e.yml index 0ecd3e86c..4355be647 100644 --- a/.github/workflows/_setup-e2e.yml +++ b/.github/workflows/_setup-e2e.yml @@ -10,6 +10,10 @@ on: required: false type: string default: '' + cache_key: + required: false + type: string + default: 'stable-release' jobs: setup_and_test: @@ -29,10 +33,10 @@ jobs: ~/.cargo/git ~/.cargo/bin target - key: ${{ runner.os }}-cargo-stable-debug-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-${{ inputs.cache_key }}-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | - ${{ runner.os }}-cargo-stable-debug- - ${{ runner.os }}-cargo-${{ github.workflow }}- + ${{ runner.os }}-cargo-${{ inputs.cache_key }}- + ${{ runner.os }}-cargo-stable-release- - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} @@ -59,6 +63,6 @@ jobs: - name: Run e2e tests run: ${{ inputs.justfile_env }} just ${{ inputs.justfile_recipe }} env: - RUST_BACKTRACE: 1 - RUST_LOG: debug - RELEASE: 0 \ No newline at end of file + CARGO_PROFILE_RELEASE_DEBUG: 0 + RUST_LOG: off + RELEASE: 1 \ No newline at end of file diff --git a/.github/workflows/doc-test.yml b/.github/workflows/doc-test.yml index 182771a21..2dea84d35 100644 --- a/.github/workflows/doc-test.yml +++ b/.github/workflows/doc-test.yml @@ -34,10 +34,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-test- - ${{ runner.os }}-cargo-${{ github.workflow }} - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} diff --git a/.github/workflows/docs-release.yml b/.github/workflows/docs-release.yml index e684fdfd5..6d4c06473 100644 --- a/.github/workflows/docs-release.yml +++ b/.github/workflows/docs-release.yml @@ -32,10 +32,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-nightly-debug-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-nightly-debug-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-nightly-debug- - ${{ runner.os }}-cargo-${{ github.workflow }} - name: Set up Rust Nightly and Rust Docs run: | diff --git a/.github/workflows/e2e-contracts-postgres.yml b/.github/workflows/e2e-contracts-postgres.yml index 02e2c0b77..f726d2139 100644 --- a/.github/workflows/e2e-contracts-postgres.yml +++ b/.github/workflows/e2e-contracts-postgres.yml @@ -39,10 +39,9 @@ jobs: ~/.cargo/git ~/.cargo/bin target - key: ${{ runner.os }}-cargo-stable-release-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-stable-release-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-stable-release- - ${{ runner.os }}-cargo-${{ github.workflow }}- - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} @@ -73,5 +72,5 @@ jobs: run: just contracts-test-stratus-postgres --${{ matrix.contract }} env: CARGO_PROFILE_RELEASE_DEBUG: 0 - RUST_LOG: debug + RUST_LOG: off RELEASE: 1 diff --git a/.github/workflows/e2e-contracts-rocks.yml b/.github/workflows/e2e-contracts-rocks.yml index 6ee104812..5d09bdfab 100644 --- a/.github/workflows/e2e-contracts-rocks.yml +++ b/.github/workflows/e2e-contracts-rocks.yml @@ -39,10 +39,10 @@ jobs: ~/.cargo/git ~/.cargo/bin target - key: ${{ runner.os }}-cargo-stable-release-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-stable-release-rocks-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | + ${{ runner.os }}-cargo-stable-release-rocks- ${{ runner.os }}-cargo-stable-release- - ${{ runner.os }}-cargo-${{ github.workflow }}- - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} @@ -73,5 +73,5 @@ jobs: run: just contracts-test-stratus-rocks --${{ matrix.contract }} env: CARGO_PROFILE_RELEASE_DEBUG: 0 - RUST_LOG: debug + RUST_LOG: off RELEASE: 1 diff --git a/.github/workflows/e2e-contracts.yml b/.github/workflows/e2e-contracts.yml index a93cbfed6..1448552d0 100644 --- a/.github/workflows/e2e-contracts.yml +++ b/.github/workflows/e2e-contracts.yml @@ -39,10 +39,9 @@ jobs: ~/.cargo/git ~/.cargo/bin target - key: ${{ runner.os }}-cargo-stable-release-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-stable-release-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-stable-release- - ${{ runner.os }}-cargo-${{ github.workflow }}- - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} @@ -73,5 +72,5 @@ jobs: run: just contracts-test-stratus --${{ matrix.contract }} env: CARGO_PROFILE_RELEASE_DEBUG: 0 - RUST_LOG: debug + RUST_LOG: off RELEASE: 1 diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 5deb296b3..480158b44 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -38,6 +38,7 @@ jobs: uses: ./.github/workflows/_setup-e2e.yml with: justfile_recipe: 'e2e-stratus-rocks' + cache_key: 'stable-release-rocks' concurrency: group: ${{ github.workflow }}-rocks-${{ github.ref || github.run_id }} diff --git a/.github/workflows/int-test.yml b/.github/workflows/int-test.yml index 58fa24343..7e56df692 100644 --- a/.github/workflows/int-test.yml +++ b/.github/workflows/int-test.yml @@ -34,10 +34,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-test- - ${{ runner.os }}-cargo-${{ github.workflow }} - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }} diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml index d958332fa..de2cc1b7a 100644 --- a/.github/workflows/lint-check.yml +++ b/.github/workflows/lint-check.yml @@ -34,10 +34,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-nightly-debug-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-nightly-debug-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-nightly-debug- - ${{ runner.os }}-cargo-${{ github.workflow }} - name: Set up Rust Nightly run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly-2024-01-01 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4d27ebf17..0306b33cc 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -34,10 +34,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-test-${{ hashFiles('Cargo.lock', 'Cargo.toml') }} restore-keys: | ${{ runner.os }}-cargo-test- - ${{ runner.os }}-cargo-${{ github.workflow }} - name: Set up Rust if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}