From 924d34070b038deed2b9ebc62eef206638366c13 Mon Sep 17 00:00:00 2001 From: Tibor Schneider Date: Tue, 12 Nov 2024 09:20:24 +0100 Subject: [PATCH] Update workflow - Make it run in Parallel - Use cache - Specify coverage file --- .github/workflows/rust.yml | 188 ++++++++++++++++++++++++++----------- 1 file changed, 133 insertions(+), 55 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c936e5e..56549dd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,58 +3,136 @@ on: [push, pull_request] name: Continuous integration jobs: - build_and_test: - runs-on: ubuntu-latest - name: check and test - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Set up toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt, llvm-tools-preview, clippy - - name: Check - uses: actions-rs/cargo@v1 - with: - command: check - args: --all-features - - name: Clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-features -- --deny warnings - - name: Rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features - env: - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --no-fail-fast - env: - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" - - name: Install grcov - run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi - - name: Run grcov - run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov - - name: Coveralls upload - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: ${{ steps.coverage.outputs.report }} + check: + runs-on: ubuntu-latest + name: check + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Set up toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, llvm-tools-preview, clippy + - name: Check + uses: actions-rs/cargo@v1 + with: + command: check + args: --all-features + clippy: + runs-on: ubuntu-latest + name: clippy + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Set up toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, llvm-tools-preview, clippy + - name: Clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features -- --deny warnings + + rustfmt: + runs-on: ubuntu-latest + name: rustfmt + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Set up toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, llvm-tools-preview, clippy + - name: Rustfmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + coverage: + runs-on: ubuntu-latest + name: coverage + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Set up toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, llvm-tools-preview, clippy + - name: Install grcov + run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-features + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --no-fail-fast + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Cinstrument-coverage" + RUSTDOCFLAGS: "-Cinstrument-coverage" + - name: Run grcov + run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov + - name: Coveralls upload + uses: coverallsapp/github-action@master + with: + paths: ./coverage.lcov + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ${{ steps.coverage.outputs.report }}