From 2e6fe1239e1183a111e6dbca6badaee29b828d6e Mon Sep 17 00:00:00 2001 From: Cameron Garnham Date: Thu, 3 Aug 2023 10:00:53 +0100 Subject: [PATCH] ci: overhaul coverage workflow --- .github/workflows/codecov.yml | 44 ----------------------- .github/workflows/coverage.yaml | 63 +++++++++++++++++++++++++++++++++ codecov.yml | 6 ++++ project-words.txt | 10 ++++++ 4 files changed, 79 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/codecov.yml create mode 100644 .github/workflows/coverage.yaml create mode 100644 codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index 4f8fb02a..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Upload Code Coverage - -on: - push: - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly - components: rustfmt, llvm-tools-preview - - name: Build - run: cargo build --release - env: - CARGO_INCREMENTAL: "0" - RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" - - name: Install torrent edition tool (needed for testing) - run: cargo install imdl - - name: Test - run: cargo test --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 - - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - with: - files: ./coverage.lcov - flags: rust - fail_ci_if_error: true # optional (default = false) \ No newline at end of file diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 00000000..1a0dfeef --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,63 @@ +name: Coverage + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + report: + name: Report + runs-on: ubuntu-latest + env: + CARGO_INCREMENTAL: "0" + RUSTFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" + RUSTDOCFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" + + steps: + - id: checkout + name: Checkout Repository + uses: actions/checkout@v3 + + - id: setup + name: Setup Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + components: llvm-tools-preview + + - id: cache + name: Enable Workflow Cache + uses: Swatinem/rust-cache@v2 + + - id: tools + name: Install Tools + uses: taiki-e/install-action@v2 + with: + tool: grcov + + - id: imdl + name: Install Intermodal + run: cargo install imdl + + - id: check + name: Run Build Checks + run: cargo check --workspace --all-targets --all-features + + - id: test + name: Run Unit Tests + run: cargo test --workspace --all-targets --all-features + + - id: coverage + name: Generate Coverage Report + uses: alekitto/grcov@v0.2 + + - id: upload + name: Upload Coverage Report + uses: codecov/codecov-action@v3 + with: + files: ${{ steps.coverage.outputs.report }} + verbose: true + fail_ci_if_error: true diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..f0878195 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0.5% diff --git a/project-words.txt b/project-words.txt index 59fe8833..31530f59 100644 --- a/project-words.txt +++ b/project-words.txt @@ -1,5 +1,6 @@ actix addrs +alekitto AUTOINCREMENT bencode bencoded @@ -7,6 +8,8 @@ Benoit binascii btih chrono +codecov +codegen compatiblelicenses creativecommons creds @@ -16,6 +19,8 @@ datetime DATETIME Dont dotless +dtolnay +grcov Grünwald hasher Hasher @@ -27,6 +32,7 @@ imdl indexadmin indexmap infohash +Intermodal jsonwebtoken leechers Leechers @@ -49,6 +55,8 @@ reqwest Roadmap ROADMAP rowid +RUSTDOCFLAGS +RUSTFLAGS sgxj singlepart sqlx @@ -56,6 +64,8 @@ strftime sublicensable sublist subpoints +Swatinem +taiki tempdir tempfile thiserror