Skip to content

Commit

Permalink
ci: wrong comparison operator for coverage diff (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
CBenoit authored Aug 15, 2023
1 parent 38b3b48 commit 0b40820
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
uses: Swatinem/rust-cache@v2.3.0

- name: Prepare runner
run: cargo xtask cov install
run: cargo xtask cov install -v

- name: Generate PR report
if: github.event.number != ''
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_TOKEN != '' && secrets.DEVOLUTIONSBOT_TOKEN || github.token }}
run: cargo xtask cov report-gh --repo "${{ github.repository }}" --pr "${{ github.event.number }}"
run: cargo xtask cov report-gh --repo "${{ github.repository }}" --pr "${{ github.event.number }}" -v

- name: Configure Git Identity
if: github.ref == 'refs/heads/master'
Expand All @@ -41,4 +41,4 @@ jobs:
if: github.ref == 'refs/heads/master'
env:
GH_TOKEN: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
run: cargo xtask cov update
run: cargo xtask cov update -v
6 changes: 4 additions & 2 deletions xtask/src/cov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub fn report_github(sh: &Shell, repo: &str, pr_id: u32) -> anyhow::Result<()> {
use std::fmt::Write as _;

const COMMENT_HEADER: &str = "## Coverage Report :robot: :gear:";
const DIFF_THRESHOLD: f64 = 0.005;

let _s = Section::new("COV-REPORT");

Expand All @@ -91,7 +92,7 @@ pub fn report_github(sh: &Shell, repo: &str, pr_id: u32) -> anyhow::Result<()> {

println!("Past:\n{past_report}");
println!("New:\n{report}");
println!("Diff: {:+.2}%", diff);
println!("Diff: {:+}%", diff);

let comments = cmd!(sh, "gh api")
.arg("-H")
Expand Down Expand Up @@ -137,7 +138,8 @@ pub fn report_github(sh: &Shell, repo: &str, pr_id: u32) -> anyhow::Result<()> {
.arg(format!("/repos/{repo}/issues/comments/{comment_id}"))
.ignore_stdout()
.run()?;
} else if diff.abs() < 0.01 {
} else if diff.abs() > DIFF_THRESHOLD {
trace!("Diff ({diff}) is greater than threshold ({DIFF_THRESHOLD})");
println!("Create new comment");

command
Expand Down

0 comments on commit 0b40820

Please sign in to comment.