From 36119cc5d164dfa6bb44319f10c6f8122bb3f981 Mon Sep 17 00:00:00 2001 From: Matthew Rodusek <7519129+bitwizeshift@users.noreply.github.com> Date: Sun, 10 Dec 2023 17:39:36 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A6=20Add=20composite=20action=20for?= =?UTF-8?q?=20caching=20cargo=20installs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `cargo install` commands are taking quite a while due to it producing long build-times. This adds a caching mechanism to keep the dependencies between builds so that installation times don't have to suffer. --- .github/actions/cargo-install/action.yaml | 29 +++++++++++++++++++++++ .github/workflows/build.yaml | 22 +++++++++++++---- .github/workflows/docs.yaml | 10 ++++++-- .gitignore | 1 + 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 .github/actions/cargo-install/action.yaml diff --git a/.github/actions/cargo-install/action.yaml b/.github/actions/cargo-install/action.yaml new file mode 100644 index 0000000..d30289a --- /dev/null +++ b/.github/actions/cargo-install/action.yaml @@ -0,0 +1,29 @@ +name: cargo-install +description: "Performs a cargo install for the specified component, with caching" + +inputs: + target: + required: true + description: "The component to install" + +runs: + using: "composite" + steps: + - name: Cache installation + id: cargo-install + uses: actions/cache@v3 + with: + path: .cargo/bin/${{ inputs.target }} + key: cargo-install-${{ inputs.target }} + + - name: Update git submodules + if: steps.cargo-install.outputs.cache-hit != 'true' + shell: bash + run: | + mkdir -p .cargo/bin + cargo install --locked ${{ inputs.target }} --root ./.cargo + + - name: Update PATH + shell: bash + run: | + echo "$(pwd)/.cargo/bin" >> "${GITHUB_PATH}" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index dacf91d..4387d64 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -61,8 +61,15 @@ jobs: - name: Install toolchain uses: ./.github/actions/rust-toolchain - - name: Install cargo-deny and cargo-about - run: cargo install --locked cargo-deny cargo-about + - name: Install cargo-deny + uses: ./.github/actions/cargo-install + with: + target: cargo-deny + + - name: Install cargo-about + uses: ./.github/actions/cargo-install + with: + target: cargo-about - name: Check cargo-deny run: cargo deny check @@ -98,8 +105,15 @@ jobs: with: components: clippy - - name: Install required cargo - run: cargo install clippy-sarif sarif-fmt + - name: Install clippy-sarif + uses: ./.github/actions/cargo-install + with: + target: clippy-sarif + + - name: Install sarif-fmt + uses: ./.github/actions/cargo-install + with: + target: sarif-fmt - name: Check clippy continue-on-error: true diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index a7e6e78..ba41f6b 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -21,8 +21,14 @@ jobs: rust: nightly - name: Install mdbook - run: | - cargo install --locked mdbook + uses: ./.github/actions/cargo-install + with: + target: mdbook + + - name: Install cargo-about + uses: ./.github/actions/cargo-install + with: + target: cargo-about - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov diff --git a/.gitignore b/.gitignore index 4fffb2f..3285428 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /Cargo.lock +/.cargo