From 0eb21ae167a72f25890461351c22b5dd873fff76 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:04:56 -0600 Subject: [PATCH] chore: reuse CI cache on jobs --- .github/workflows/autofix.yml | 5 +++-- .github/workflows/release-fig.yml | 7 ++++--- .github/workflows/release-plz.yml | 7 ++++--- .github/workflows/release.yml | 1 + .github/workflows/test.yml | 14 +++++++++++--- src/config/mod.rs | 3 ++- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 8e081d5f41..6bd535cce5 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -27,9 +27,10 @@ jobs: timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 with: - { toolchain: nightly, components: "rustfmt, clippy", rustflags: "" } + shared-key: test-ubuntu-latest + save-if: false - run: | cargo build --all-features echo "$PWD/target/debug" >> "$GITHUB_PATH" diff --git a/.github/workflows/release-fig.yml b/.github/workflows/release-fig.yml index 11e3cff892..601b162de5 100644 --- a/.github/workflows/release-fig.yml +++ b/.github/workflows/release-fig.yml @@ -14,9 +14,10 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }} - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: { toolchain: nightly, components: rustfmt } - - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: test-ubuntu-latest + save-if: false - run: mkdir -p "$HOME/bin" && echo "$HOME/bin" >> "$GITHUB_PATH" - run: npm i - run: cargo build --all-features && cp target/debug/mise "$HOME"/bin diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 9ea998f985..7383f72b0f 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -34,9 +34,10 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true git_tag_gpgsign: true - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: { toolchain: nightly, components: rustfmt } - - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: test-ubuntu-latest + save-if: false - run: mkdir -p "$HOME/bin" && echo "$HOME/bin" >> "$GITHUB_PATH" - run: npm i - run: cargo build --all-features && cp target/debug/mise "$HOME"/bin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c750d4b618..d73d6c2f32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -334,6 +334,7 @@ jobs: container: ghcr.io/jdx/mise:alpine timeout-minutes: 30 needs: [release] + if: startsWith(github.event.ref, 'refs/tags/v') && endsWith(github.event.ref, '.0') steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bc4b1d73f..90b7457b97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,8 +39,10 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.head_ref }} token: ${{ secrets.RTX_GITHUB_BOT_TOKEN || github.token }} - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: { toolchain: stable, components: rustfmt } + - uses: Swatinem/rust-cache@v2 + with: + shared-key: test-${{ matrix.os }} + save-if: ${{ github.ref_name == 'main' }} - uses: taiki-e/install-action@v2 with: tool: nextest,cargo-deny,cargo-msrv,cargo-machete,usage-cli @@ -91,7 +93,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: shared-key: coverage - save-if: ${{ github.ref_name == 'main' && matrix.tranche == 0 }} + save-if: ${{ github.ref_name == 'main' && matrix.tranche == 3 }} - name: Install build and test dependencies run: | sudo apt-get update && sudo apt-get install \ @@ -157,6 +159,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 + with: + shared-key: test-windows-latest + save-if: ${{ github.ref_name == 'main' }} # TODO: enable when we can remove continue-on-error: # - name: cargo test # uses: nick-fields/retry@v3 @@ -173,6 +178,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 + with: + shared-key: test-windows-latest + save-if: false - run: cargo build - run: Add-Content $env:GITHUB_PATH "$PWD\target\debug" - name: e2e diff --git a/src/config/mod.rs b/src/config/mod.rs index 7fe677acdf..d51878b10c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -359,7 +359,8 @@ impl Config { fn load_task_file(&self, path: &Path) -> Result> { let raw = file::read_to_string(path)?; let mut tasks = toml::from_str::(&raw) - .wrap_err_with(|| format!("Error parsing task file: {}", display_path(path)))?.0; + .wrap_err_with(|| format!("Error parsing task file: {}", display_path(path)))? + .0; for (name, task) in &mut tasks { task.name = name.clone(); task.config_source = path.to_path_buf();