|
21 | 21 | // |
22 | 22 | // All I/O — reading files, resolving links, posting the comment — belongs to run.ts. |
23 | 23 |
|
24 | | -import type { RepoHealthSnapshot } from '../repo-health/model.ts'; |
| 24 | +import type { ArtifactStatus, RepoHealthSnapshot } from '../repo-health/model.ts'; |
25 | 25 | import { |
26 | 26 | MAX_COMMENT_LINES, |
27 | 27 | QUALITY_DELTA_METRICS, |
@@ -75,11 +75,21 @@ function formatSigned(value: number, format: MetricFormat): string { |
75 | 75 | return `${sign}${formatValue(Math.abs(value), format)}`; |
76 | 76 | } |
77 | 77 |
|
78 | | -function staleInputFlag(snapshot: RepoHealthSnapshot, spec: MetricSpec): boolean { |
| 78 | +function artifactStatus(snapshot: RepoHealthSnapshot, spec: MetricSpec): ArtifactStatus | null { |
79 | 79 | const inputs = snapshot.provenance.inputs; |
80 | | - if (spec.staleInput === 'sizeReport') return inputs.sizeReport?.stale === true; |
81 | | - if (spec.staleInput === 'coverageSummary') return inputs.coverageSummary?.stale === true; |
82 | | - return false; |
| 80 | + if (spec.staleInput === 'sizeReport') return inputs.sizeReport?.status ?? null; |
| 81 | + if (spec.staleInput === 'coverageSummary') return inputs.coverageSummary?.status ?? null; |
| 82 | + return null; |
| 83 | +} |
| 84 | + |
| 85 | +/** |
| 86 | + * Only a PROVEN stale artifact marks its row. #1423 reports `unknown` whenever the producer stamps |
| 87 | + * no commit, which is every artifact today, so marking that too would put a caveat on every size and |
| 88 | + * coverage row forever — the comment fatigue this issue exists to remove. `unknown` gets one job |
| 89 | + * summary note instead. |
| 90 | + */ |
| 91 | +function staleInputFlag(snapshot: RepoHealthSnapshot, spec: MetricSpec): boolean { |
| 92 | + return artifactStatus(snapshot, spec) === 'stale'; |
83 | 93 | } |
84 | 94 |
|
85 | 95 | function deltaRow(spec: MetricSpec, sources: DeltaSources): QualityDeltaRow | null { |
@@ -155,6 +165,15 @@ function missingInputNotes(sources: DeltaSources): string[] { |
155 | 165 | 'Slow-test report unavailable (the vitest reporter writes it during the coverage run).', |
156 | 166 | ); |
157 | 167 | } |
| 168 | + const unverified = QUALITY_DELTA_METRICS.filter( |
| 169 | + (spec) => artifactStatus(sources.head, spec) === 'unknown', |
| 170 | + ); |
| 171 | + if (unverified.length > 0) { |
| 172 | + notes.push( |
| 173 | + 'Size and coverage are read artifacts whose producers stamp no commit, so repo-health reports ' + |
| 174 | + 'their freshness as `unknown` (#1423): treat those rows as not provably current with the head tree.', |
| 175 | + ); |
| 176 | + } |
158 | 177 | return notes; |
159 | 178 | } |
160 | 179 |
|
|
0 commit comments