From 0cc321202410a89802f0b468fbf0d8f1124602ff Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Mon, 29 Apr 2024 11:10:42 -0400 Subject: [PATCH] Add rust-ci local github-action --- .github/actions/install-rust/action.yml | 21 +++++++++++++++++++ .github/workflows/rust-ci.yml | 28 ++++++++++++------------- 2 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 .github/actions/install-rust/action.yml 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..99b1049a26 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -17,16 +17,20 @@ jobs: fmt: runs-on: ubuntu-latest steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - name: Checkout uses: actions/checkout@v4 + - name: Install Rust + uses: ./.github/actions/install-rust + with: + cache: false - name: Run static analysis tests run: cargo fmt --all --check docs: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: @@ -34,18 +38,18 @@ 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 + cache: false - name: Run doc tests run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items --all clippy: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: @@ -53,12 +57,9 @@ 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 @@ -66,6 +67,8 @@ jobs: unit-tests: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: @@ -73,11 +76,8 @@ 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