From 54e3e1cf345ede3d0ecf631809af9de3116347f2 Mon Sep 17 00:00:00 2001 From: Martin Ball <98639962+benandez@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:06:41 +0100 Subject: [PATCH] CI: fix red SonarCloud on main (#6859) The coverage shards failed six tests on every main push: - three UI glyph tests: the Sonar job had no craft-fonts. Pass the same fonts-ref as ci.yml. - three layout linear-time tests: llvm-cov instrumentation pushes the 8x time ratio past 24 (24.2-31.2). Ignore them under cfg(coverage), which cargo llvm-cov sets; the gate CI still runs them. Claude-Session: https://claude.ai/code/session_01FypgCXtSjB6e5jmy9Uq7u8 Co-authored-by: Claude Opus 5.5 --- .github/workflows/sonarcloud.yml | 3 +++ Cargo.toml | 2 ++ crates/layout/src/tests.rs | 3 +++ 3 files changed, 8 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e78fe1ea3b..983bdf8ad5 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -18,4 +18,7 @@ jobs: sonarcloud: # Tracked at @main so org-wide CI improvements propagate without PR churn. uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main + with: + # Same craft-fonts commit as ci.yml: the UI glyph tests need its CJK and Arabic fonts. + fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 secrets: inherit diff --git a/Cargo.toml b/Cargo.toml index 63ca129867..f8f63c7812 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,6 +122,8 @@ arboard = { version = "3.7", default-features = false, features = ["wayland-data [workspace.lints.rust] unsafe_code = "forbid" +# cargo llvm-cov sets `--cfg coverage`; timing tests skip themselves under its instrumentation. +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(coverage)"] } [workspace.lints.clippy] cognitive_complexity = "deny" diff --git a/crates/layout/src/tests.rs b/crates/layout/src/tests.rs index 5218ad5c7f..40144d7f8e 100644 --- a/crates/layout/src/tests.rs +++ b/crates/layout/src/tests.rs @@ -914,6 +914,7 @@ fn long_word_beside_a_float(n: usize) -> Document { /// A word with no break opportunity in it: measuring the word for every line it takes scanned /// the whole paragraph each time, so the layout was quadratic in the word's length. #[test] +#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")] fn a_long_unbreakable_word_lays_out_in_linear_time() { let (t1, tk, ratio) = layout_time_ratio(long_word_beside_a_float, 50_000, &LayoutOptions::default()); eprintln!("t(n) {t1:.4} s, t(8n) {tk:.4} s, ratio {ratio:.1}"); @@ -1134,6 +1135,7 @@ fn long_word_with_alternating_advances_beside_a_float(n: usize) -> Document { /// A word whose advances alternate in sign lays out in linear time: the measurement that asks /// whether it would fit the full line must not walk the word again for every line it takes. #[test] +#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")] fn a_word_with_alternating_advances_lays_out_in_linear_time() { let (t1, tk, ratio) = layout_time_ratio(long_word_with_alternating_advances_beside_a_float, 50_000, &LayoutOptions::default()); eprintln!("t(n) {t1:.4} s, t(8n) {tk:.4} s, ratio {ratio:.1}"); @@ -7839,6 +7841,7 @@ fn a_no_break_space_before_a_slash_still_holds() { } #[test] +#[cfg_attr(coverage, ignore = "coverage instrumentation skews the time ratio")] fn unequal_formats_lay_out_in_linear_time() { crate::test_fonts(); // Runs whose formats never compare equal (NaN spacing from a hostile file) each get a style;