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