From 38642539f0337b75b99320c0850089a3d5d763a1 Mon Sep 17 00:00:00 2001 From: Nicola Busanello Date: Thu, 22 Feb 2024 23:53:41 +0100 Subject: [PATCH] add coverage to GH actions workflow --- .github/workflows/checks.yml | 64 ++++++++++++++++++++++++++++++++++++ .github/workflows/rust.yaml | 42 ----------------------- 2 files changed, 64 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/checks.yml delete mode 100644 .github/workflows/rust.yaml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..c860def --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,64 @@ +name: Code checks + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - name: Lint + run: cargo clippy --lib -- -D warnings + + format: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Format + run: cargo fmt --all -- --check + + test_and_coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: llvm-tools-preview + toolchain: stable + + - name: Install llvm-cov + env: + LLVM_COV_RELEASES: https://github.com/taiki-e/cargo-llvm-cov/releases + run: | + host=$(rustc -Vv | grep host | sed 's/host: //') + curl -fsSL $LLVM_COV_RELEASES/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C "$HOME/.cargo/bin" + + - name: Generate coverage report + run: cargo llvm-cov --lcov --output-path coverage.lcov + + - name: Upload coverage report + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + file: coverage.lcov + flags: rust + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml deleted file mode 100644 index 492f216..0000000 --- a/.github/workflows/rust.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Rust - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -env: - CARGO_TERM_COLOR: always - -jobs: - lint: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v3 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy - - name: Lint - run: cargo clippy --lib -- -D warnings - - format: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v3 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: rustfmt - - name: Format - run: cargo fmt --all -- --check - - test: - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v3 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Tests - run: cargo test