-
Notifications
You must be signed in to change notification settings - Fork 7
218 lines (197 loc) · 7.67 KB
/
Copy pathmutation.yml
File metadata and controls
218 lines (197 loc) · 7.67 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
206
207
208
209
210
211
212
213
214
215
216
217
218
# ============================================================
# WorldScript Studio – Mutation Testing (Stryker) — Parallel + Incremental
# QNBS-v3: Matrix-parallel Stryker with per-module caches and fail-safe aggregation.
# Run manually via workflow_dispatch. Each matrix job targets one curated module;
# runtime and score remain measured outputs rather than undocumented promises.
# ============================================================
name: 🧬 Mutation Tests (Stryker)
on:
workflow_dispatch:
inputs:
mode:
description: 'Run mode'
required: true
default: 'incremental'
type: choice
options:
- incremental
- force
module:
description: 'Scope selector: all, tier-a, or one module name'
required: false
default: 'all'
per_job_concurrency:
description: 'Concurrency per job (default: 2)'
required: false
default: '2'
concurrency:
group: mutation-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
scope:
name: 🧬 Validate Stryker Scope
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.scope.outputs.matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: scope
shell: bash
env:
SELECTOR: ${{ github.event.inputs.module || 'all' }}
run: |
node scripts/stryker-scope.mjs --selector "$SELECTOR"
printf 'matrix=%s\n' \
"$(node scripts/stryker-scope.mjs --matrix --selector "$SELECTOR")" \
>> "$GITHUB_OUTPUT"
# ============================================
# PARALLEL MATRIX JOBS (one per module)
# ============================================
stryker:
name: 🧬 Stryker ${{ matrix.name }}
runs-on: ubuntu-latest
timeout-minutes: 45
needs: scope
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.scope.outputs.matrix) }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/setup
# === Incremental cache (per module) ===
- name: Restore Stryker incremental cache
id: cache-incremental
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: reports/stryker-incremental-${{ matrix.name }}.json
key: stryker-incremental-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
stryker-incremental-${{ matrix.name }}-
- name: Prepare incremental file
env:
MATRIX_NAME: ${{ matrix.name }}
MODE_INPUT: ${{ github.event.inputs.mode || 'incremental' }}
run: |
if [[ ! "$MATRIX_NAME" =~ ^[a-z0-9-]+$ ]]; then
echo "Invalid Stryker module name: $MATRIX_NAME" >&2
exit 1
fi
INCREMENTAL_FILE="reports/stryker-incremental-${MATRIX_NAME}.json"
mkdir -p reports
MODE="$MODE_INPUT"
if [[ "$MODE" != "incremental" && "$MODE" != "force" ]]; then
echo "Invalid Stryker mode: $MODE" >&2
exit 1
fi
if [ "$MODE" = "force" ]; then
echo "🧹 Force mode → clearing incremental cache for $MATRIX_NAME"
rm -f "$INCREMENTAL_FILE"
elif [ -f "$INCREMENTAL_FILE" ]; then
echo "♻️ Using existing incremental cache for $MATRIX_NAME"
else
echo "🆕 No incremental cache found — will create new one"
fi
- name: Run Stryker (${{ matrix.name }})
env:
MATRIX_NAME: ${{ matrix.name }}
MATRIX_MUTATE: ${{ matrix.mutate }}
MATRIX_TEST_FILES: ${{ join(matrix.testFiles, ',') }}
MODE_INPUT: ${{ github.event.inputs.mode || 'incremental' }}
CONCURRENCY_INPUT: ${{ github.event.inputs.per_job_concurrency || '2' }}
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
run: |
if [[ ! "$MATRIX_NAME" =~ ^[a-z0-9-]+$ ]]; then
echo "Invalid Stryker module name: $MATRIX_NAME" >&2
exit 1
fi
MODE="$MODE_INPUT"
if [[ "$MODE" != "incremental" && "$MODE" != "force" ]]; then
echo "Invalid Stryker mode: $MODE" >&2
exit 1
fi
FORCE_FLAG=""
if [ "$MODE" = "force" ]; then
FORCE_FLAG="--force"
fi
CONCURRENCY="$CONCURRENCY_INPUT"
if [[ ! "$CONCURRENCY" =~ ^[0-9]+%?$ ]]; then
echo "Invalid Stryker concurrency: $CONCURRENCY" >&2
exit 1
fi
echo "▶️ Module: $MATRIX_NAME"
echo " Pattern: $MATRIX_MUTATE"
TEST_FILES="$MATRIX_TEST_FILES"
if [ -n "$TEST_FILES" ]; then
echo " Test files: $TEST_FILES"
else
echo " Test files: Vitest related selection"
fi
echo " Concurrency: $CONCURRENCY"
echo " Mode: $MODE"
# QNBS-v3: pass the supported CLI option; arbitrary env vars are not Stryker config.
INCREMENTAL_FILE="reports/stryker-incremental-${MATRIX_NAME}.json"
TEST_FILE_ARGS=()
if [ -n "$TEST_FILES" ]; then
TEST_FILE_ARGS+=(--testFiles "$TEST_FILES")
fi
pnpm exec stryker run \
stryker.config.mjs \
--incremental \
--incrementalFile "$INCREMENTAL_FILE" \
$FORCE_FLAG \
--concurrency "$CONCURRENCY" \
--mutate "$MATRIX_MUTATE" \
"${TEST_FILE_ARGS[@]}" \
--reporters progress,json,html
- name: Upload Stryker report
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: stryker-report-${{ matrix.name }}
path: reports/mutation/
if-no-files-found: error
retention-days: 30
# ============================================
# AGGREGATE JOB — combined summary
# ============================================
aggregate:
name: 📊 Stryker Aggregate Report
runs-on: ubuntu-latest
needs: [scope, stryker]
if: always()
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Download all Stryker reports
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: all-reports
pattern: stryker-report-*
merge-multiple: false
- name: Build combined summary
env:
SELECTOR: ${{ github.event.inputs.module || 'all' }}
run: |
set -o pipefail
if [ "${{ needs.stryker.result }}" != "success" ]; then
echo "Stryker matrix completed with: ${{ needs.stryker.result }}; the summary remains informational and this job will fail closed." >&2
fi
node scripts/aggregate-stryker-reports.mjs all-reports --selector "$SELECTOR" | tee -a "$GITHUB_STEP_SUMMARY"
if [ "${{ needs.stryker.result }}" != "success" ]; then
exit 1
fi
echo "> Mode: \`${{ github.event.inputs.mode || 'incremental' }}\` | Concurrency: \`${{ github.event.inputs.per_job_concurrency || '2' }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "> Threshold: break ≥ 75 | low ≥ 70 | high ≥ 85" >> "$GITHUB_STEP_SUMMARY"
echo "> Individual HTML/JSON reports are available as artifacts." >> "$GITHUB_STEP_SUMMARY"