Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/mutation-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ concurrency:
jobs:
mutation-diff:
name: mutation-diff
if: github.event_name == 'merge_group' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down
32 changes: 31 additions & 1 deletion scripts/stryker-diff.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ import {
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")

describe("mutation testing workflow", () => {
const readWorkflow = () =>
fs.readFileSync(path.join(repositoryRoot, ".github/workflows/mutation-testing.yml"), "utf8")
const shouldRun = ({ eventName, draft }) => eventName === "merge_group" || draft === false

it("checks out the pull request merge result from the base repository", () => {
const workflow = fs.readFileSync(path.join(repositoryRoot, ".github/workflows/mutation-testing.yml"), "utf8")
const workflow = readWorkflow()

assert.ok(workflow.includes(" pull_request:"))
assert.ok(!workflow.includes("pull_request_target:"))
Expand All @@ -61,6 +65,32 @@ describe("mutation testing workflow", () => {
const script = fs.readFileSync(path.join(repositoryRoot, "scripts/stryker-diff.mjs"), "utf8")
assert.ok(script.includes("appendSummary([], manifest.advisories, manifest)"))
})

it("waits until a draft pull request is ready before emitting mutation annotations", () => {
const workflow = readWorkflow()

assert.ok(workflow.includes("types: [edited, opened, reopened, ready_for_review, synchronize]"))
assert.ok(
workflow.includes("if: github.event_name == 'merge_group' || github.event.pull_request.draft == false"),
)

const draftToReadyRuns = [
{ eventName: "pull_request", action: "opened", draft: true },
{ eventName: "pull_request", action: "ready_for_review", draft: false },
].filter(shouldRun)

assert.deepEqual(
draftToReadyRuns.map(({ action }) => action),
["ready_for_review"],
)
})

it("retains mutation testing for reviewable pull request updates and the merge queue", () => {
for (const action of ["opened", "ready_for_review", "synchronize", "reopened"]) {
assert.equal(shouldRun({ eventName: "pull_request", draft: false }), true, action)
}
assert.equal(shouldRun({ eventName: "merge_group" }), true, "merge queue")
})
})

describe("parseNameStatus", () => {
Expand Down
Loading