Skip to main content

github_annotations

Function github_annotations 

Source
pub fn github_annotations(compare: &CompareReceipt) -> Vec<String>
Expand description

Produce GitHub Actions annotation strings from a CompareReceipt.

Only failing/warning metrics generate annotations; passing metrics are skipped.

let compare = CompareReceipt {
    schema: COMPARE_SCHEMA_V1.to_string(),
    tool: ToolInfo { name: "perfgate".into(), version: "0.1.0".into() },
    bench: BenchMeta {
        name: "my-bench".into(), cwd: None,
        command: vec!["echo".into()], repeat: 3, warmup: 0,
        work_units: None, timeout_ms: None,
    },
    baseline_ref: CompareRef { path: None, run_id: None },
    current_ref: CompareRef { path: None, run_id: None },
    budgets: BTreeMap::new(),
    deltas: BTreeMap::from([(Metric::WallMs, Delta {
        baseline: 100.0, current: 130.0, ratio: 1.3, pct: 0.3,
        regression: 0.3, statistic: MetricStatistic::Median,
        significance: None, status: MetricStatus::Fail,
    })]),
    verdict: Verdict {
        status: VerdictStatus::Fail,
        counts: VerdictCounts { pass: 0, warn: 0, fail: 1 },
        reasons: vec![],
    },
};
let annotations = perfgate_render::github_annotations(&compare);
assert_eq!(annotations.len(), 1);
assert!(annotations[0].starts_with("::error::"));