ci: wrong comparison operator for coverage diff (#176)

This commit is contained in:
Benoît Cortier 2023-08-15 11:50:00 -04:00 committed by GitHub
parent 38b3b4887a
commit 0b408200a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -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'
@ -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

View file

@ -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");
@ -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")
@ -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