From b47ab1384649deb53c1f32d4c3dd8bae8fe5919f Mon Sep 17 00:00:00 2001 From: Charlotte Smith Date: Thu, 20 Feb 2025 16:21:55 +0000 Subject: [PATCH 1/3] reuse rust cache --- .github/workflows/rust-cache.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/test.yml | 27 ++++++--------------------- 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/rust-cache.yml diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml new file mode 100644 index 0000000..fcb3ff6 --- /dev/null +++ b/.github/workflows/rust-cache.yml @@ -0,0 +1,31 @@ +name: rust-cache +on: + workflow_call: + inputs: + runner: + required: true + type: string + key: + required: true + type: string + restore-keys: + required: false + type: string + +jobs: + cache: + runs-on: ${{ inputs.runner }} + steps: + - name: "Cache cargo" + id: cache-cargo + uses: "actions/cache@v4" + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + lib/target/ + key: ${{ inputs.key }} + restore-keys: ${{ inputs.restore-keys }} + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7858035..e15c44b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,14 +16,9 @@ jobs: - run: rustup toolchain install stable --profile minimal - name: "Cache cargo" id: cache-cargo - uses: "actions/cache@v4" + uses: "./.github/workflows/rust-cache.yml" with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - lib/target/ + runner: ubuntu-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - uses: extractions/setup-just@v2 @@ -35,14 +30,9 @@ jobs: - run: rustup toolchain install stable --profile minimal - name: "Cache cargo" id: cache-cargo - uses: "actions/cache@v4" + uses: "./.github/workflows/rust-cache.yml" with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - lib/target/ + runner: macos-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - uses: extractions/setup-just@v2 @@ -53,14 +43,9 @@ jobs: - uses: actions/checkout@v4 - name: "Cache cargo" id: cache-cargo - uses: "actions/cache@v4" + uses: "./.github/workflows/rust-cache.yml" with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - lib/target/ + runner: windows-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - uses: extractions/setup-just@v2 From bb5a07fa8e5e846c5d51073fb514da24cf1d4c11 Mon Sep 17 00:00:00 2001 From: Charlotte Smith Date: Thu, 20 Feb 2025 16:23:28 +0000 Subject: [PATCH 2/3] git checkout --- .github/workflows/rust-cache.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml index fcb3ff6..1e41a94 100644 --- a/.github/workflows/rust-cache.yml +++ b/.github/workflows/rust-cache.yml @@ -16,6 +16,7 @@ jobs: cache: runs-on: ${{ inputs.runner }} steps: + - uses: actions/checkout@v4 - name: "Cache cargo" id: cache-cargo uses: "actions/cache@v4" From c8d39e89209187f72a2f7f220439508dd9f7e042 Mon Sep 17 00:00:00 2001 From: Charlotte Smith Date: Thu, 20 Feb 2025 16:26:58 +0000 Subject: [PATCH 3/3] fix call --- .github/workflows/test.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e15c44b..b235c20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,9 +11,7 @@ env: jobs: test-linux: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal + uses: - name: "Cache cargo" id: cache-cargo uses: "./.github/workflows/rust-cache.yml" @@ -21,13 +19,14 @@ jobs: runner: ubuntu-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install stable --profile minimal - uses: extractions/setup-just@v2 - run: just test test-macos: runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal + uses: - name: "Cache cargo" id: cache-cargo uses: "./.github/workflows/rust-cache.yml" @@ -35,12 +34,14 @@ jobs: runner: macos-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install stable --profile minimal - uses: extractions/setup-just@v2 - run: just test test-windows: runs-on: windows-latest - steps: - - uses: actions/checkout@v4 + uses: - name: "Cache cargo" id: cache-cargo uses: "./.github/workflows/rust-cache.yml" @@ -48,5 +49,7 @@ jobs: runner: windows-latest key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- + steps: + - uses: actions/checkout@v4 - uses: extractions/setup-just@v2 - run: just test