@avi2dg/checks 0.63.1 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/docs/bins.md +2 -3
- package/docs/gates/checks-night-run.md +25 -19
- package/package.json +1 -1
- package/src/testing/night-run-findings.ts +7 -4
- package/src/testing/night-run.ts +43 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of `@avi2dg/checks`, newest first, written by the release from its conventional commits.
|
|
4
4
|
|
|
5
|
+
## 0.64.0
|
|
6
|
+
|
|
7
|
+
Released 2026-11-03.
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **testing:** shard the night mutation run and file each missing report [#27](https://github.com/avi2d/checks/pull/27)
|
|
12
|
+
|
|
5
13
|
## 0.63.1
|
|
6
14
|
|
|
7
15
|
Released 2026-11-03.
|
package/docs/bins.md
CHANGED
|
@@ -50,9 +50,8 @@ These bins run on their own:
|
|
|
50
50
|
- [`checks-mutation-baseline`](gates/checks-mutation-baseline.md) restores the newest mutation baseline from `main`, saves it on a self-hosted runner's disk in place of an artifact, and deletes superseded baselines after a `main` run.
|
|
51
51
|
- [`checks-mutation-scope`](gates/checks-mutation-scope.md) turns a branch's diff into the files its mutation runs mutate.
|
|
52
52
|
- [`checks-subsumed-tests`](gates/checks-subsumed-tests.md) lists each test another test subsumes in a mutation run.
|
|
53
|
-
- [`checks-night-run`](gates/checks-night-run.md) opens or comments on one GitHub issue per finding of a night run on `main`, each file whose mutation score fell, each failing test,
|
|
54
|
-
It closes the issue of a test
|
|
55
|
-
It comments on a mutation issue a later night no longer reports, and leaves it open.
|
|
53
|
+
- [`checks-night-run`](gates/checks-night-run.md) opens or comments on one GitHub issue per finding of a night run on `main`, each file whose mutation score fell, each failing test, each failed nightly gate, and each missing mutation report.
|
|
54
|
+
It closes the issue of a test, a gate or a missing mutation report that a later night no longer reports, and it comments on a mutation issue it no longer reports without closing it, but only when a previous night exists and every requested mutation report is present.
|
|
56
55
|
- [`checks-changelog`](gates/checks-changelog.md) writes the pending release into `CHANGELOG.md` from the conventional commits since the last release.
|
|
57
56
|
- [`checks-release-notes`](gates/checks-release-notes.md) writes one `CHANGELOG.md` section to a file for a GitHub release.
|
|
58
57
|
- [`checks-release-report`](gates/checks-release-report.md) tells whether the history holds unreleased features or fixes since the last tag.
|
|
@@ -4,13 +4,13 @@ audience: consumers
|
|
|
4
4
|
---
|
|
5
5
|
# checks-night-run
|
|
6
6
|
|
|
7
|
-
`checks-night-run` turns a night run on `main` into GitHub
|
|
8
|
-
|
|
9
|
-
It
|
|
7
|
+
`checks-night-run` turns each finding of a night run on `main` into a GitHub issue.
|
|
8
|
+
A finding is a file whose mutation score fell, a failing test, a failed nightly gate or a missing mutation report.
|
|
9
|
+
It closes the issue of a test, gate or missing mutation report that a later night no longer reports, and it comments on a mutation issue it no longer reports without closing it, but only when a previous night exists and every requested mutation report is present.
|
|
10
10
|
|
|
11
11
|
## What it checks
|
|
12
12
|
|
|
13
|
-
It scores each file of tonight's Stryker
|
|
13
|
+
It scores each file of tonight's Stryker reports as Stryker does, the `Killed` and `Timeout` mutants over every mutant but the `Ignored`, `CompileError`, `RuntimeError` and `Pending` ones.
|
|
14
14
|
It compares each file's score with the same file's score from the previous night.
|
|
15
15
|
A file whose score is lower than the previous night's is a finding.
|
|
16
16
|
A file only one night holds is no finding, since it lacks one of the two scores.
|
|
@@ -22,7 +22,10 @@ A log where every named gate is undecided files `checks-lint` itself, with no pe
|
|
|
22
22
|
A log with no passing run and no named gate files `checks-lint` itself, so a gate run that never finished still reaches an issue.
|
|
23
23
|
A file whose test worker crashed is one finding, since Bun reports none of its tests.
|
|
24
24
|
With no previous night it compares no score and still files each failing test.
|
|
25
|
+
Each mutation report `--mutation` names that does not exist is a finding, since the mutation job that writes it failed, timed out or was cancelled.
|
|
25
26
|
With no mutation report it compares and records no score and still files each failing test.
|
|
27
|
+
With some mutation reports missing it compares the files the others hold and records no score.
|
|
28
|
+
The next night then compares every file with the last night that scored them all.
|
|
26
29
|
|
|
27
30
|
Each finding has a key that stays the same from night to night:
|
|
28
31
|
|
|
@@ -32,6 +35,7 @@ Each finding has a key that stays the same from night to night:
|
|
|
32
35
|
| a failing test | `test:<file> > <describe> > <name>` |
|
|
33
36
|
| a file whose test worker crashed | `test:<file>` |
|
|
34
37
|
| a nightly gate that failed | `gates:<gate>` |
|
|
38
|
+
| a missing mutation report | `mutation-report:<path>` |
|
|
35
39
|
|
|
36
40
|
## How it files a finding
|
|
37
41
|
|
|
@@ -42,15 +46,14 @@ Any other finding opens one issue labelled `night-run`.
|
|
|
42
46
|
The issue and the comment name tonight's run, the file and the test, the score of both nights or the failed gate.
|
|
43
47
|
The body holds the file, the full test name or the failed gate, and the finding key.
|
|
44
48
|
A title longer than GitHub's 256 characters is cut to at most 256 and ends in `…`.
|
|
45
|
-
A night with no finding creates no label and
|
|
46
|
-
It still reads the open issues, to close or comment on each one whose finding is gone.
|
|
49
|
+
A night with no finding creates no label and writes no issue, and only reads the open issues to close any test, gate or mutation-report issue whose finding is gone and, when a previous night exists and every requested mutation report is present, to comment on any mutation issue whose finding is gone.
|
|
47
50
|
Closing an issue ends it, and the same finding on a later night opens a new one.
|
|
48
51
|
|
|
49
52
|
## How it closes an issue
|
|
50
53
|
|
|
51
|
-
An open test or
|
|
54
|
+
An open test, gate or mutation-report issue whose key tonight's findings lack gets one comment naming tonight's run and the key.
|
|
52
55
|
It then closes as completed.
|
|
53
|
-
|
|
56
|
+
When a previous night exists and every requested mutation report is present, an open mutation issue whose key tonight's findings lack gets one comment that names tonight's run and the key, and stays open.
|
|
54
57
|
A closed issue is no longer read, so a later night without the finding comments on it no more.
|
|
55
58
|
A comment that reports the finding carries a reported marker, and a note that a mutation finding is gone carries a noted marker.
|
|
56
59
|
A mutation issue whose latest marked comment already notes the finding gone gets no further note.
|
|
@@ -63,13 +66,14 @@ It judges a key only from a report it read tonight:
|
|
|
63
66
|
| `test:<file> > <describe> > <name>` | tonight read a JUnit report, the test is not failing, and `<file>`'s worker did not crash |
|
|
64
67
|
| `test:<file>` | tonight read a JUnit report and `<file>`'s worker did not crash |
|
|
65
68
|
| `gates:<gate>` | tonight read a lint log that passes or names its failed gates, and `<gate>` is not among them |
|
|
69
|
+
| `mutation-report:<path>` | tonight read the mutation report at `<path>` |
|
|
66
70
|
| `mutation:<file>` | never |
|
|
67
71
|
|
|
68
72
|
A crashed worker loses every result of its file, so the issue of a test in that file stays open.
|
|
69
73
|
A lint log that is undecided or never finished says nothing of any one gate, so every gate issue stays open.
|
|
70
74
|
A mutation finding is a fall from one night to the next.
|
|
71
75
|
A later night that does not fall again still holds the lower score.
|
|
72
|
-
|
|
76
|
+
Only a night that compared scores with every requested mutation report present comments on the mutation issue without closing it, since a score can recover and drop again.
|
|
73
77
|
So a person closes a mutation issue once the score is back.
|
|
74
78
|
An issue with no key in its body is never read, so a person's issue under the `night-run` label is never commented on or closed.
|
|
75
79
|
A run off `main` comments on and closes no issue.
|
|
@@ -78,24 +82,24 @@ A run on any ref but `refs/heads/main` files no issue and records no score, and
|
|
|
78
82
|
|
|
79
83
|
## What it reads
|
|
80
84
|
|
|
81
|
-
It reads tonight's Stryker `mutation.json`
|
|
85
|
+
It reads tonight's Stryker `mutation.json` reports and any number of JUnit reports, such as the ones `checks-test --junit=<file>` keeps, as [checks-test](checks-test.md#arguments) says.
|
|
82
86
|
It reads the lint log `--gates` names for the `gate(s) failed:` line `checks-lint --night` prints.
|
|
83
87
|
It scans the newest 30 successful runs of the same workflow on `main` from newest to oldest.
|
|
84
88
|
It takes the first run whose `night-run` artifact still exists as the previous night.
|
|
85
89
|
That artifact holds `night-run.json`, the scores the run recorded.
|
|
86
90
|
When no scanned run holds the artifact it compares no score.
|
|
87
91
|
A run on another branch never becomes the previous night.
|
|
88
|
-
On `main` with
|
|
92
|
+
On `main` with every mutation report present it writes tonight's scores to `reports/night-run.json`, and the workflow uploads that file as the `night-run` artifact.
|
|
89
93
|
It reads the run from `GITHUB_SERVER_URL`, `GITHUB_REPOSITORY`, `GITHUB_RUN_ID`, `GITHUB_WORKFLOW_REF` and `GITHUB_REF`, so it runs only inside a GitHub Actions job.
|
|
90
94
|
It calls `gh` with the job's `GH_TOKEN`, which needs `actions: read` for the previous night and `issues: write` for the issues.
|
|
91
95
|
|
|
92
96
|
## Arguments
|
|
93
97
|
|
|
94
98
|
```sh
|
|
95
|
-
checks-night-run [--mutation <mutation-report>] [--tests <junit-report>]... [--gates <lint-log>]
|
|
99
|
+
checks-night-run [--mutation <mutation-report>]... [--tests <junit-report>]... [--gates <lint-log>]
|
|
96
100
|
```
|
|
97
101
|
|
|
98
|
-
`--mutation` names tonight's Stryker
|
|
102
|
+
`--mutation` names one of tonight's Stryker reports and is given once per report the workflow's mutation jobs write, whether or not each job wrote it.
|
|
99
103
|
`--tests` names one JUnit report and is given once per report.
|
|
100
104
|
`--gates` names tonight's `checks-lint --night` log and is given at most once.
|
|
101
105
|
At least one report is given.
|
|
@@ -200,10 +204,9 @@ jobs:
|
|
|
200
204
|
with:
|
|
201
205
|
bun-version-file: .bun-version
|
|
202
206
|
- run: bun install --frozen-lockfile
|
|
203
|
-
-
|
|
204
|
-
uses: actions/download-artifact@v4
|
|
207
|
+
- uses: actions/download-artifact@v4
|
|
205
208
|
with:
|
|
206
|
-
|
|
209
|
+
pattern: night-run-mutation
|
|
207
210
|
path: reports/mutation
|
|
208
211
|
- if: needs.gates.result == 'success'
|
|
209
212
|
uses: actions/download-artifact@v4
|
|
@@ -216,7 +219,7 @@ jobs:
|
|
|
216
219
|
path: reports/night-run-tests
|
|
217
220
|
- env:
|
|
218
221
|
GH_TOKEN: ${{ github.token }}
|
|
219
|
-
run: bunx checks-night-run
|
|
222
|
+
run: bunx checks-night-run --mutation reports/mutation/night-run-mutation/mutation.json --tests reports/night-run-tests/live.xml --tests reports/night-run-tests/pixel.xml ${{ needs.gates.result == 'success' && '--gates reports/night-run-gates/gates.log' || '' }}
|
|
220
223
|
- uses: actions/upload-artifact@v4
|
|
221
224
|
with:
|
|
222
225
|
name: night-run
|
|
@@ -232,7 +235,10 @@ Each `|| true` lets the job go on to the upload after a failing test, since that
|
|
|
232
235
|
A tier that writes no report fails the report job, because `checks-night-run` cannot read it.
|
|
233
236
|
The gates job runs the nightly lint gates and keeps the log, since a failing gate becomes an issue.
|
|
234
237
|
The report job runs whenever the tests job succeeds, so a failing test that also stops Stryker still becomes an issue.
|
|
235
|
-
It passes `--mutation
|
|
238
|
+
It always passes `--mutation`, so a mutation job that failed or timed out leaves a missing report that becomes an issue.
|
|
239
|
+
The download names the artifact by `pattern`, which downloads nothing rather than failing when the artifact is missing.
|
|
240
|
+
A full run too long for one job splits into a matrix of shards.
|
|
241
|
+
Each shard uploads its own artifact under the one pattern, and each report gets its own `--mutation`.
|
|
236
242
|
It passes `--gates` only when the gates job succeeded, and the failed gates job still fails the run.
|
|
237
243
|
The concurrency group queues a run started by hand behind the scheduled one, so two runs never file the same finding twice.
|
|
238
244
|
A dispatch on a branch runs both jobs and lists its findings in the report job's log, and `if-no-files-found: ignore` lets that run upload no record.
|
|
@@ -240,7 +246,7 @@ A dispatch on a branch runs both jobs and lists its findings in the report job's
|
|
|
240
246
|
A public repository keeps `runs-on: ubuntu-latest` on every job.
|
|
241
247
|
A private repository sets `runs-on` on the mutation job to the labels declared under `checks.mutationRunner` in `package.json`, and [checks-ci-wiring](checks-ci-wiring.md#runners) refuses a mutation job that names `CI_RUNS_ON`.
|
|
242
248
|
A private repository sets `runs-on: ${{ vars.CI_RUNS_ON || 'ubuntu-latest' }}` on the tests, gates, and report jobs.
|
|
243
|
-
A successful run uploads `night-run`, so the next night compares with it, and a failed
|
|
249
|
+
A successful run with every mutation report present uploads `night-run`, so the next night compares with it, and a run that failed or missed a report uploads nothing a later night reads.
|
|
244
250
|
The artifact keeps 90 days, so a gap of nights still leaves a previous night to compare with.
|
|
245
251
|
|
|
246
252
|
## Related topics
|
package/package.json
CHANGED
|
@@ -20,7 +20,8 @@ export type Finding =
|
|
|
20
20
|
| { readonly kind: "mutation"; readonly file: string; readonly before: Score; readonly after: Score; readonly since: string }
|
|
21
21
|
| { readonly kind: "test"; readonly file: string; readonly name: string }
|
|
22
22
|
| { readonly kind: "crash"; readonly file: string }
|
|
23
|
-
| { readonly kind: "gates"; readonly file: string }
|
|
23
|
+
| { readonly kind: "gates"; readonly file: string }
|
|
24
|
+
| { readonly kind: "mutation-report"; readonly file: string };
|
|
24
25
|
|
|
25
26
|
function scoreOf(file: ReportFile): Score {
|
|
26
27
|
let detected = 0;
|
|
@@ -44,12 +45,13 @@ function fell(before: Score, after: Score): boolean {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// A night judges a key only from a report it read, since a report it lacks leaves every finding in it absent.
|
|
47
|
-
export type Observed = { readonly tests: boolean; readonly gates: boolean; readonly mutation: boolean };
|
|
48
|
+
export type Observed = { readonly tests: boolean; readonly gates: boolean; readonly mutation: boolean; readonly mutationReports: ReadonlySet<string> };
|
|
48
49
|
|
|
49
50
|
export function keyOf(finding: Finding): string {
|
|
50
51
|
if (finding.kind === "mutation") return `mutation:${finding.file}`;
|
|
51
52
|
if (finding.kind === "test") return `test:${finding.file}${NAME_SEPARATOR}${finding.name}`;
|
|
52
53
|
if (finding.kind === "gates") return `gates:${finding.file}`;
|
|
54
|
+
if (finding.kind === "mutation-report") return `mutation-report:${finding.file}`;
|
|
53
55
|
return `test:${finding.file}`;
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -70,8 +72,8 @@ function testFindings(reports: readonly TestReport[]): readonly Finding[] {
|
|
|
70
72
|
return [...new Map(failing.map((finding) => [keyOf(finding), finding])).values()];
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
export function findingsOf(previous: Option.Option<PreviousNight>, tonight: Tonight,
|
|
74
|
-
return [...scoreFindings(previous, tonight.scores), ...testFindings(tonight.tests), ...
|
|
75
|
+
export function findingsOf(previous: Option.Option<PreviousNight>, tonight: Tonight, others: readonly Finding[] = []): readonly Finding[] {
|
|
76
|
+
return [...scoreFindings(previous, tonight.scores), ...testFindings(tonight.tests), ...others].sort((one, other) =>
|
|
75
77
|
keyOf(one).localeCompare(keyOf(other)),
|
|
76
78
|
);
|
|
77
79
|
}
|
|
@@ -97,6 +99,7 @@ export function gatesDecided(log: string): boolean {
|
|
|
97
99
|
export function cleared(key: string, present: ReadonlySet<string>, observed: Observed): boolean {
|
|
98
100
|
if (present.has(key)) return false;
|
|
99
101
|
if (key.startsWith("gates:")) return observed.gates;
|
|
102
|
+
if (key.startsWith("mutation-report:")) return observed.mutationReports.has(key.slice("mutation-report:".length));
|
|
100
103
|
if (!key.startsWith("test:")) return false;
|
|
101
104
|
const [file] = key.slice("test:".length).split(NAME_SEPARATOR);
|
|
102
105
|
return observed.tests && !present.has(`test:${file}`);
|
package/src/testing/night-run.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { ChildProcessSpawner } from "effect/process";
|
|
|
4
4
|
import { DEFAULT_BRANCH } from "../core/gates.ts";
|
|
5
5
|
import { runMain, Usage } from "../core/main.ts";
|
|
6
6
|
import { gh, type GitHubFailure, gitHubJson, REPOSITORY } from "../delivery/github.ts";
|
|
7
|
-
import { parseReport as parseMutationReport } from "./mutation-compare.ts";
|
|
7
|
+
import { parseReport as parseMutationReport, type ReportFile } from "./mutation-compare.ts";
|
|
8
8
|
import { cleared, type Finding, findingsOf, gatesDecided, gatesOf, keyOf, NightRecordSchema, noted, type Observed, type NightRecord, percent, type PreviousNight, scoresOf, type TestReport } from "./night-run-findings.ts";
|
|
9
9
|
import { parseReport as parseTestReport } from "./test-report.ts";
|
|
10
10
|
|
|
11
11
|
const NAME = "checks-night-run";
|
|
12
|
-
const USAGE = `usage: ${NAME} [--mutation <mutation-report>] [--tests <junit-report>]... [--gates <lint-log>]`;
|
|
12
|
+
const USAGE = `usage: ${NAME} [--mutation <mutation-report>]... [--tests <junit-report>]... [--gates <lint-log>]`;
|
|
13
13
|
export const LABEL = "night-run";
|
|
14
14
|
const LABEL_COLOR = "5319e7";
|
|
15
15
|
const LABEL_DESCRIPTION = "A regression a night run on main found";
|
|
@@ -23,7 +23,7 @@ class NightRunFailure extends Schema.TaggedError<NightRunFailure>()("NightRunFai
|
|
|
23
23
|
message: Schema.String,
|
|
24
24
|
}) {}
|
|
25
25
|
|
|
26
|
-
export type Options = { readonly mutation:
|
|
26
|
+
export type Options = { readonly mutation: readonly string[]; readonly tests: readonly string[]; readonly gates: Option.Option<string> };
|
|
27
27
|
|
|
28
28
|
export const parseArgs = Effect.fnUntraced(function* (argv: readonly string[]): Effect.fn.Return<Options, Usage> {
|
|
29
29
|
const mutation: string[] = [];
|
|
@@ -35,10 +35,10 @@ export const parseArgs = Effect.fnUntraced(function* (argv: readonly string[]):
|
|
|
35
35
|
if (into === undefined || value === undefined || value.startsWith("--")) return yield* new Usage({ message: USAGE });
|
|
36
36
|
into.push(value);
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (gates.length > 1 || mutation.length + tests.length + gates.length === 0) {
|
|
39
39
|
return yield* new Usage({ message: USAGE });
|
|
40
40
|
}
|
|
41
|
-
return { mutation
|
|
41
|
+
return { mutation, tests, gates: Option.fromNullishOr(gates[0]) };
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
export type OpenIssue = { readonly number: number; readonly key: string };
|
|
@@ -120,6 +120,7 @@ function fullTitleOf(finding: Finding): string {
|
|
|
120
120
|
if (finding.kind === "mutation") return `Night run: mutation score fell in ${finding.file}`;
|
|
121
121
|
if (finding.kind === "test") return `Night run: ${finding.file} > ${finding.name} fails`;
|
|
122
122
|
if (finding.kind === "gates") return `Night run: nightly gate ${finding.file} failed`;
|
|
123
|
+
if (finding.kind === "mutation-report") return `Night run: no mutation report at ${finding.file}`;
|
|
123
124
|
return `Night run: ${finding.file} crashed its test worker`;
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -144,6 +145,7 @@ export function findingText(finding: Finding, run: string): string {
|
|
|
144
145
|
}
|
|
145
146
|
if (finding.kind === "test") return `The night run ${run} failed \`${finding.name}\` in \`${finding.file}\`.`;
|
|
146
147
|
if (finding.kind === "gates") return `The night run ${run} failed nightly gate \`${finding.file}\`.`;
|
|
148
|
+
if (finding.kind === "mutation-report") return `The night run ${run} found no mutation report at \`${finding.file}\`: the mutation job that writes it failed, timed out or was cancelled, so no file it mutates was scored.`;
|
|
147
149
|
return `The night run ${run} lost every result of \`${finding.file}\`, because the worker running it crashed.`;
|
|
148
150
|
}
|
|
149
151
|
|
|
@@ -264,13 +266,33 @@ const writeRecord = Effect.fn("writeRecord")(function* (record: NightRecord) {
|
|
|
264
266
|
yield* fs.writeFileString(RECORD, `${JSON.stringify(record, null, 2)}\n`);
|
|
265
267
|
});
|
|
266
268
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
type MutationReport = { readonly file: string; readonly files: Option.Option<ReadonlyMap<string, ReportFile>> };
|
|
270
|
+
|
|
271
|
+
// A mutation job that timed out or failed uploads no report, so a missing file is a finding rather than a failed read.
|
|
272
|
+
const mutationReport = Effect.fn("mutationReport")(function* (file: string) {
|
|
273
|
+
if (!(yield* (yield* FileSystem.FileSystem).exists(file).pipe(Effect.mapError(unreadable(file))))) return { file, files: Option.none() } satisfies MutationReport;
|
|
274
|
+
return { file, files: Option.some(yield* parseMutationReport(file, yield* readText(file))) } satisfies MutationReport;
|
|
269
275
|
});
|
|
270
276
|
|
|
277
|
+
function missingReports(reports: readonly MutationReport[]): readonly Finding[] {
|
|
278
|
+
return reports.flatMap(({ file, files }): readonly Finding[] => (Option.isNone(files) ? [{ kind: "mutation-report", file }] : []));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function readReports(reports: readonly MutationReport[]): ReadonlySet<string> {
|
|
282
|
+
return new Set(reports.flatMap(({ file, files }) => (Option.isSome(files) ? [file] : [])));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function tonightScores(reports: readonly MutationReport[]): Option.Option<NightRecord["scores"]> {
|
|
286
|
+
const read = reports.flatMap(({ files }) => (Option.isSome(files) ? [...files.value] : []));
|
|
287
|
+
return reports.some(({ files }) => Option.isSome(files)) ? Option.some(scoresOf(new Map(read))) : Option.none();
|
|
288
|
+
}
|
|
289
|
+
|
|
271
290
|
type Filing = { readonly onMain: true; readonly filed: readonly Filed[] } | { readonly onMain: false; readonly ref: string };
|
|
272
291
|
|
|
273
|
-
|
|
292
|
+
// A night missing one report records nothing, so the next night still compares every file with the last night that scored it.
|
|
293
|
+
type Scored = { readonly files: number; readonly missing: number };
|
|
294
|
+
|
|
295
|
+
export function report(run: string, scored: Option.Option<Scored>, previous: Option.Option<PreviousNight>, findings: readonly Finding[], filing: Filing): string {
|
|
274
296
|
const against = Option.isNone(scored)
|
|
275
297
|
? "had no mutation report, so it compared no score"
|
|
276
298
|
: Option.isSome(previous)
|
|
@@ -280,25 +302,30 @@ export function report(run: string, scored: Option.Option<number>, previous: Opt
|
|
|
280
302
|
const listed = filing.onMain ? filing.filed.map((one) => ` ${one.action} #${one.issue} for ${one.key}`) : findings.map((finding) => ` found ${keyOf(finding)}`);
|
|
281
303
|
const recorded = !filing.onMain
|
|
282
304
|
? `${NAME}: the run is on ${filing.ref}, not ${DEFAULT_BRANCH}, so it filed no issue and recorded no score`
|
|
283
|
-
: Option.
|
|
284
|
-
? `${NAME}: recorded
|
|
285
|
-
:
|
|
305
|
+
: Option.isNone(scored)
|
|
306
|
+
? `${NAME}: recorded no score, since it had no mutation report`
|
|
307
|
+
: scored.value.missing === 0
|
|
308
|
+
? `${NAME}: recorded ${scored.value.files} file score(s) in ${RECORD}`
|
|
309
|
+
: `${NAME}: recorded no score, since ${scored.value.missing} mutation report(s) were missing`;
|
|
286
310
|
return [`${NAME}: the night run ${run} ${against}; ${verdict}`, ...listed, recorded].join("\n");
|
|
287
311
|
}
|
|
288
312
|
|
|
289
313
|
const nightRun = Effect.gen(function* () {
|
|
290
314
|
const options = yield* parseArgs(process.argv.slice(2));
|
|
291
315
|
const actions = yield* actionsRun;
|
|
292
|
-
const
|
|
316
|
+
const reports = yield* Effect.forEach(options.mutation, mutationReport);
|
|
317
|
+
const missing = missingReports(reports);
|
|
318
|
+
const scores = tonightScores(reports);
|
|
293
319
|
const tests: TestReport[] = yield* Effect.forEach(options.tests, testReport);
|
|
294
320
|
const log = Option.isSome(options.gates) ? Option.some(yield* readText(options.gates.value)) : Option.none<string>();
|
|
295
321
|
const gates: readonly Finding[] = Option.isSome(log) ? gatesOf(log.value) : [];
|
|
296
322
|
const previous = Option.isSome(scores) ? yield* previousNight(actions) : Option.none<PreviousNight>();
|
|
297
|
-
const observed: Observed = { tests: options.tests.length > 0, gates: Option.isSome(log) && gatesDecided(log.value), mutation: Option.isSome(previous) };
|
|
298
|
-
const findings = findingsOf(previous, { scores: Option.getOrElse(scores, () => ({})), tests }, gates);
|
|
323
|
+
const observed: Observed = { tests: options.tests.length > 0, gates: Option.isSome(log) && gatesDecided(log.value), mutation: Option.isSome(previous) && missing.length === 0, mutationReports: readReports(reports) };
|
|
324
|
+
const findings = findingsOf(previous, { scores: Option.getOrElse(scores, () => ({})), tests }, [...missing, ...gates]);
|
|
299
325
|
const filing: Filing = actions.ref === `refs/heads/${DEFAULT_BRANCH}` ? { onMain: true, filed: yield* fileFindings(findings, observed, actions.run) } : { onMain: false, ref: actions.ref };
|
|
300
|
-
if (filing.onMain && Option.isSome(scores)) yield* writeRecord({ scores: scores.value });
|
|
301
|
-
|
|
326
|
+
if (filing.onMain && Option.isSome(scores) && missing.length === 0) yield* writeRecord({ scores: scores.value });
|
|
327
|
+
const scored = Option.map(scores, (tonight): Scored => ({ files: Object.keys(tonight).length, missing: missing.length }));
|
|
328
|
+
yield* Console.log(report(actions.run, scored, previous, findings, filing));
|
|
302
329
|
return true;
|
|
303
330
|
});
|
|
304
331
|
|