Skip to content

Commit e8de314

Browse files
fix(ci): tolerate a failed stacked-map upload and require a confirmed non-draft parent
- mutation-testing.yml: the map upload is continue-on-error. A failed upload used to fail stacked_map, which skipped mutation-diff entirely, so the download-side "missing artifact -> measure against the event base" fallback could never run. - stryker-diff.mjs: resolveStackedUnitBase requires pr.draft === false. An entry whose draft flag is missing or not a boolean (inline --stacked-map, older map) has not proven the parent was gated, so it keeps the event base instead of being accepted as a stacked base. - tests: stacked fixtures now carry draft: false explicitly, the map upload count assertion is 3, and a draft-less entry is pinned as keeping the event base.
1 parent 1833535 commit e8de314

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

‎.github/workflows/mutation-testing.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ jobs:
5454
esac
5555
printf '%s\n' "$STACKED_MAP" > stacked-map.json
5656
57+
# A failed upload must not skip the gate: the download side already treats a missing
58+
# artifact as "measure against the event base" (stricter, never looser), and that
59+
# fallback can only run if this job still succeeds.
5760
- name: Publish the stacked map
61+
continue-on-error: true
5862
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
5963
with:
6064
name: mutation-stacked-map

‎scripts/stryker-diff.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,12 @@ export function resolveStackedUnitBase(repoRoot, eventBaseSha, prHeadSha, openPu
321321
// measuring this unit against its head hides the parent's feature-branch delta from the changed-line
322322
// cap while merging this unit lands that delta on main. Without either base ref the comparison cannot
323323
// be made, and the unit keeps the event base.
324+
// The predicate requires draft === false rather than accepting anything that is not true: an
325+
// entry whose draft flag is missing or not a boolean (an inline --stacked-map entry, an older
326+
// map format) has not proven the parent was gated, so it keeps the event base.
324327
const parent = openPullRequests.find(
325328
(pr) =>
326-
pr.draft !== true &&
329+
pr.draft === false &&
327330
String(pr.headSha).toLowerCase() === parentSha &&
328331
Boolean(childBaseRef) &&
329332
(typeof pr.baseRef === "string" ? pr.baseRef : "") === childBaseRef,

‎scripts/stryker-diff.test.mjs‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ describe("mutation testing workflow", () => {
123123
// Both jobs need actions:write - one to publish the map, one to read it and publish the reports.
124124
assert.equal(workflow.match(/actions: write/g)?.length, 2)
125125
// A missing map artifact degrades to the event base inside the script, so the download step must
126-
// not fail the job; the report upload keeps its own tolerance.
127-
assert.equal(workflow.match(/continue-on-error: true/g)?.length, 2)
126+
// not fail the job. The upload that produces it is tolerant for the same reason: a failed upload
127+
// would otherwise fail this job and skip the gate entirely, so the fallback could never run. The
128+
// report upload keeps its own tolerance.
129+
assert.equal(workflow.match(/continue-on-error: true/g)?.length, 3)
128130
assert.equal(workflow.match(/Could not write the job summary/g)?.length, 2)
129131
const script = fs.readFileSync(path.join(repositoryRoot, "scripts/stryker-diff.mjs"), "utf8")
130132
assert.ok(script.includes("appendSummary([], manifest.advisories, manifest)"))
@@ -286,7 +288,7 @@ describe("stacked unit base resolution", () => {
286288
repository,
287289
eventBaseSha,
288290
childSha,
289-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
291+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
290292
"main",
291293
)
292294
assert.equal(resolved.baseSha, parentSha)
@@ -320,7 +322,7 @@ describe("stacked unit base resolution", () => {
320322
repository,
321323
advancedBase,
322324
childSha,
323-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
325+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
324326
"main",
325327
)
326328
assert.equal(resolved.baseSha, parentSha)
@@ -391,6 +393,18 @@ describe("stacked unit base resolution", () => {
391393
assert.equal(draft.baseSha, eventBaseSha)
392394
assert.equal(draft.stackedOn, null)
393395

396+
// An entry whose draft flag is missing proves nothing about gating, so it keeps the event
397+
// base like a known draft does.
398+
const unconfirmed = resolveStackedUnitBase(
399+
repository,
400+
eventBaseSha,
401+
childSha,
402+
[{ number: 1, headSha: parentSha, baseRef: "main", draft: undefined }],
403+
"main",
404+
)
405+
assert.equal(unconfirmed.baseSha, eventBaseSha)
406+
assert.equal(unconfirmed.stackedOn, null)
407+
394408
// The same entry, ready for review: the parent was gated, so it is the unit's base again.
395409
const ready = resolveStackedUnitBase(
396410
repository,
@@ -425,7 +439,7 @@ describe("stacked unit base resolution", () => {
425439
repository,
426440
eventBaseSha,
427441
childSha,
428-
[{ number: 1, headSha: parentSha, baseRef: "feature/other" }],
442+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "feature/other" }],
429443
"main",
430444
)
431445
assert.equal(featureBranchParent.baseSha, eventBaseSha)
@@ -436,7 +450,7 @@ describe("stacked unit base resolution", () => {
436450
repository,
437451
eventBaseSha,
438452
childSha,
439-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
453+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
440454
"main",
441455
)
442456
assert.equal(sameBase.baseSha, parentSha)
@@ -447,15 +461,15 @@ describe("stacked unit base resolution", () => {
447461
repository,
448462
eventBaseSha,
449463
childSha,
450-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
464+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
451465
undefined,
452466
)
453467
assert.equal(unknownUnitBase.stackedOn, null)
454468
const unknownParentBase = resolveStackedUnitBase(
455469
repository,
456470
eventBaseSha,
457471
childSha,
458-
[{ number: 1, headSha: parentSha }],
472+
[{ number: 1, headSha: parentSha, draft: false }],
459473
"main",
460474
)
461475
assert.equal(unknownParentBase.stackedOn, null)
@@ -479,8 +493,8 @@ describe("stacked unit base resolution", () => {
479493

480494
try {
481495
const map = [
482-
{ number: 9, headSha: parentSha, baseRef: "feature/other" },
483-
{ number: 1, headSha: parentSha, baseRef: "main" },
496+
{ number: 9, headSha: parentSha, draft: false, baseRef: "feature/other" },
497+
{ number: 1, headSha: parentSha, draft: false, baseRef: "main" },
484498
]
485499

486500
const unitOnMain = resolveStackedUnitBase(repository, eventBaseSha, childSha, map, "main")
@@ -621,7 +635,7 @@ describe("stacked unit base resolution", () => {
621635
advancedBase,
622636
mergeSha,
623637
childSha,
624-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
638+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
625639
"main",
626640
)
627641
assert.equal(stacked.baseSha, parentSha)
@@ -655,7 +669,7 @@ describe("stacked unit base resolution", () => {
655669
repository,
656670
advancedBase,
657671
multiParentHead,
658-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
672+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
659673
"main",
660674
)
661675
assert.equal(multi.baseSha, advancedBase)
@@ -666,7 +680,7 @@ describe("stacked unit base resolution", () => {
666680
advancedBase,
667681
multiParentHead,
668682
multiParentHead,
669-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
683+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
670684
"main",
671685
).stackedOn,
672686
null,
@@ -723,7 +737,7 @@ describe("stacked unit base resolution", () => {
723737
advancedBase,
724738
mergeSha,
725739
childSha,
726-
[{ number: 1, headSha: parentSha, baseRef: "main" }],
740+
[{ number: 1, headSha: parentSha, draft: false, baseRef: "main" }],
727741
"main",
728742
)
729743
assert.equal(invocation.diffHead, childSha)

0 commit comments

Comments
 (0)