diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml new file mode 100644 index 0000000000..5943e6505e --- /dev/null +++ b/.github/actions/install-rust/action.yml @@ -0,0 +1,21 @@ +name: 'Install Rust toolchain and Cache' +description: 'Install a rust toolchain and cache' + +inputs: + targets: + description: 'pass targets to the rust-toolchain installer' + required: false + cache: + description: "to cache or not to cache, that is the question" + required: false + default: "true" + +runs: + using: composite + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ inputs.targets }} + - if: ${{ inputs.cache == 'true' }} + uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 9b97955110..923e8ea551 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -18,7 +18,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: ./.github/actions/install-rust + with: + cache: false - name: Checkout uses: actions/checkout@v4 - name: Run static analysis tests @@ -34,12 +36,12 @@ jobs: check-latest: true cache: true - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: ./.github/actions/install-rust with: targets: wasm32-unknown-unknown + cache: false - name: Checkout uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - name: Run doc tests run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items --all @@ -53,12 +55,11 @@ jobs: check-latest: true cache: true - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: ./.github/actions/install-rust with: targets: wasm32-unknown-unknown - name: Checkout uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - name: Run static analysis tests shell: bash run: cargo clippy --all --all-features --tests --benches --examples -- -D warnings @@ -73,11 +74,10 @@ jobs: check-latest: true cache: true - name: Install Rust - uses: dtolnay/rust-toolchain@stable + uses: ./.github/actions/install-rust with: targets: wasm32-unknown-unknown - name: Checkout uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v2 - name: Run unit tests run: cargo test --all-features --all