Repository navigation
205 lines (183 loc) · 7.39 KB
/
Copy pathmutation-affected.yml
File metadata and controls
205 lines (183 loc) · 7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Mutation Harness Canary
# PR-side half of the decision-kernel mutation lane (issue #1415).
#
# Advisory only — the lane reports and never gates (#1457). `scripts/mutation/run.ts`
# exits non-zero on a harness failure, never on a score.
#
# Cost control: the kernel report that pays is the weekly sweep, so this lane
# spends mutants on one thing only — proving the harness still runs end to end
# when the harness itself changes. `select` therefore returns an empty matrix
# unless the diff touches the lane's own sources (LANE_SOURCES). Selecting on
# derived kernel ownership instead would run the full sweep on 24 of the last 40
# merged PRs. A diff confined to LANE_DEPENDENCIES runs the self-test only; most
# such diffs are unrelated workspace edits. Dispatch on the branch to spend the
# canary (pass -f base=<parent> for a stacked branch):
# gh workflow run mutation-affected.yml --ref <branch>
#
# On a harness diff the matrix is the canary (`LANE_CANARY`, selected by
# observed end-to-end runtime within the job budget — lane sources own no kernel,
# so derivation alone would select nothing) plus any kernel that same diff
# owns (scripts/mutation/ownership.ts): a kernel source, or a test that
# imports one. Selected modules are sharded like the
# weekly sweep, so the PR's wall clock is one module rather than their sum.
on:
pull_request:
paths:
# Exactly `LANE_TOOLING` in scripts/mutation/run.ts, asserted both ways by
# scripts/mutation/workflow.test.ts. A kernel or test path here would only
# start a job that selects nothing.
- 'scripts/mutation/**'
- 'scripts/lib/**'
- 'stryker.config.json'
- 'vitest.mutation.config.ts'
- 'vitest.config.ts'
- '.github/workflows/mutation-weekly.yml'
- '.github/workflows/mutation-affected.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'packages/*/package.json'
workflow_dispatch:
inputs:
base:
description: Branch the diff is measured against
default: main
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MUTATION_BASE: origin/${{ github.event.pull_request.base.ref || inputs.base }}
MUTATION_SCOPE: ${{ github.event_name == 'workflow_dispatch' && '--with-dependencies' || '' }}
jobs:
select:
name: Select harness validation kernels
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
outputs:
modules: ${{ steps.select.outputs.result }}
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
with:
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/setup-node-pnpm
- name: Harness self-test
uses: ./.github/actions/run-gate
with: { gate: mutation-model }
- id: select
name: Derive the affected shard matrix
uses: ./.github/actions/run-gate
with:
gate: mutation-affected
args: |
--list-affected
--base
${{ env.MUTATION_BASE }}
${{ env.MUTATION_SCOPE }}
# The self-test and the derivation run before any mutant, so a failure here
# would leave the lane with no envelope at all (#1430).
- name: Record a failed lane envelope
if: failure() || cancelled()
run: |
pnpm gate mutation --affected --fail-envelope \
"affected selection failed before any mutant ran (run ${{ github.run_id }})" || true
- name: Upload selection envelope
if: failure() || cancelled()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: mutation-affected-select
include-hidden-files: true
path: .tmp/mutation/lane-envelope.json
if-no-files-found: warn
mutants:
name: Mutants (${{ matrix.name }})
needs: select
if: needs.select.outputs.modules != '[]'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.select.outputs.modules) }}
steps:
- name: Checkout
timeout-minutes: 1
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
- name: Setup toolchain
timeout-minutes: 2
uses: ./.github/actions/setup-node-pnpm
- name: Run mutants for ${{ matrix.name }}
timeout-minutes: 22
uses: ./.github/actions/run-gate
with:
gate: mutation
args: |
--modules
${{ matrix.module }}
${{ matrix.shard && '--shard' || '' }}
${{ matrix.shard || '' }}
- name: Record a failed shard envelope
if: failure() || cancelled()
run: |
pnpm gate mutation --affected --modules ${{ matrix.module }} --fail-envelope \
"shard ${{ matrix.name }} failed before producing a report (run ${{ github.run_id }})" || true
- name: Upload shard report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: mutation-affected-shard-${{ matrix.name }}
include-hidden-files: true
path: |
.tmp/mutation/mutation.json
.tmp/mutation/mutation.html
.tmp/mutation/lane-envelope.json
if-no-files-found: warn
report:
name: Affected decision-kernel mutants
needs: [select, mutants]
if: ${{ !cancelled() && needs.select.result == 'success' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
with:
fetch-depth: 0
- name: Setup toolchain
uses: ./.github/actions/setup-node-pnpm
- name: Download shard reports
if: needs.select.outputs.modules != '[]'
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: mutation-affected-shard-*
path: .tmp/mutation/shards
# No shards means no affected kernel: run.ts reports "nothing to mutate"
# and still writes the envelope, so the lane is never silently absent.
# Either invocation writes the score table to $GITHUB_STEP_SUMMARY.
- name: Score the affected modules
run: |
if [ -d .tmp/mutation/shards ]; then
expected=$(echo '${{ needs.select.outputs.modules }}' | jq length)
pnpm gate mutation-check --report-dir .tmp/mutation/shards --affected \
--expect-shards "$expected" \
--base "$MUTATION_BASE" $MUTATION_SCOPE
else
pnpm gate mutation-affected --base "$MUTATION_BASE" $MUTATION_SCOPE
fi
- name: Record a failed lane envelope
if: failure() || cancelled()
run: |
pnpm gate mutation --affected --fail-envelope \
"affected report failed before producing a score table (run ${{ github.run_id }})" || true
- name: Upload mutation report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: mutation-affected
include-hidden-files: true
path: |
.tmp/mutation/shards
.tmp/mutation/lane-envelope.json
if-no-files-found: ignore