Skip to content

Commit

Permalink
Enable coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 9, 2024
1 parent 1479fb3 commit bb434f3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
components: rustfmt,llvm-tools-preview
- name: Install dependencies
run: |
curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Expand All @@ -30,9 +30,24 @@ jobs:
target/
key: cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: cargo-
- name: Format check
run: cargo fmt --check
- name: Test
run: cargo test
env:
DATABASE_URL: postgres://postgres@localhost:5433/
- name: Format check
run: cargo fmt --check
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "${{ github.workspace }}/default_%m_%p.profraw"
- name: Collect coverage
run: |
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar -xjf-
#./grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --keep-only 'repology-*/*' --ignore '**/tests.rs' --ignore '*/tests/*.rs' -o coverage.lcov
./grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --keep-only 'repology-*/*' -o coverage.lcov
- name: Submit coverage
if: ${{ github.actor != 'dependabot[bot]' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions repology-webapp/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl FontMeasurer {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions repology-webapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#![feature(iterator_try_collect)]
#![feature(coverage_attribute)]

mod badges;
mod font;
Expand Down
1 change: 1 addition & 0 deletions repology-webapp/src/package/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ where
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions repology-webapp/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ where
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions repology-webapp/src/xmlwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ macro_rules! xml {
pub(crate) use xml;

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
3 changes: 3 additions & 0 deletions repology-webapp/tests/badges.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![feature(coverage_attribute)]
#![coverage(off)]

use anyhow::Error;
use axum::http::{header, Request, StatusCode};
use sqlx::PgPool;
Expand Down

0 comments on commit bb434f3

Please sign in to comment.