Skip to content

Commit 79cd12f

Browse files
[Chore] Require changed-code mutation tests before review (#1479)
* feat(ci): add changed-code mutation gate * feat(ci): expand mutation gate coverage * test(ci): run Stryker integration smoke * test(ci): remove Stryker smoke fixture --------- Co-authored-by: Roomote <roomote@roomote.dev>
1 parent 4e8fa09 commit 79cd12f

8 files changed

Lines changed: 1957 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Changed-code mutation testing
2+
3+
on:
4+
pull_request:
5+
types: [edited, opened, reopened, ready_for_review, synchronize]
6+
merge_group:
7+
types: [checks_requested]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
mutation-diff:
18+
name: mutation-diff
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
steps:
22+
- name: Record merge-queue enforcement
23+
if: github.event_name == 'merge_group'
24+
run: |
25+
echo "## Changed-code mutation testing" >> "$GITHUB_STEP_SUMMARY"
26+
echo "Mutation testing was enforced on each pull request before it entered the merge queue." >> "$GITHUB_STEP_SUMMARY"
27+
28+
- name: Checkout pull request head
29+
if: github.event_name == 'pull_request'
30+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
31+
with:
32+
repository: ${{ github.event.pull_request.head.repo.full_name }}
33+
ref: ${{ github.event.pull_request.head.sha }}
34+
fetch-depth: 0
35+
persist-credentials: false
36+
37+
- name: Fetch pull request base
38+
if: github.event_name == 'pull_request'
39+
env:
40+
BASE_REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}.git
41+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
42+
run: git fetch --no-tags "$BASE_REPOSITORY_URL" "$BASE_SHA"
43+
44+
- name: Setup Node.js and pnpm
45+
if: github.event_name == 'pull_request'
46+
uses: ./.github/actions/setup-node-pnpm
47+
with:
48+
install-args: "--frozen-lockfile"
49+
50+
- name: Test mutation gate logic
51+
if: github.event_name == 'pull_request'
52+
run: pnpm test:mutation-ci
53+
54+
- name: Mutate changed executable lines
55+
if: github.event_name == 'pull_request'
56+
env:
57+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
58+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
59+
run: node scripts/stryker-diff.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"
60+
61+
- name: Upload mutation reports
62+
if: always() && github.event_name == 'pull_request'
63+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
64+
with:
65+
name: changed-code-mutation-report
66+
path: reports/mutation/
67+
if-no-files-found: ignore
68+
retention-days: 7

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ out-*
55
node_modules
66
package-lock.json
77
coverage/
8+
reports/mutation/
9+
.stryker-tmp/
810
mock/
911

1012
.DS_Store

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"lint": "turbo lint --log-order grouped --output-logs new-only",
1313
"check-types": "turbo check-types --log-order grouped --output-logs new-only",
1414
"test": "turbo test --log-order grouped --output-logs new-only",
15+
"test:mutation-ci": "node --test scripts/stryker-diff.test.mjs",
1516
"lifecycle:model-check": "tsx scripts/check-task-lifecycle.ts && tsx scripts/check-task-store-concurrency.ts",
1617
"test:coverage": "turbo test:coverage --log-order grouped --output-logs new-only",
1718
"format": "turbo format --log-order grouped --output-logs new-only",
@@ -28,6 +29,8 @@
2829
"devDependencies": {
2930
"@changesets/cli": "2.31.0",
3031
"@roo-code/config-typescript": "workspace:^",
32+
"@stryker-mutator/core": "10.0.0",
33+
"@stryker-mutator/vitest-runner": "10.0.0",
3134
"@types/node": "22.20.1",
3235
"@vscode/vsce": "3.9.2",
3336
"esbuild": "0.28.1",
@@ -60,6 +63,7 @@
6063
"form-data": ">=4.0.4",
6164
"bluebird": ">=3.7.2",
6265
"glob": "11.1.0",
66+
"qs": "6.15.2",
6367
"@types/react": "18.3.31",
6468
"@types/react-dom": "18.3.7",
6569
"csstype": "3.2.3",

0 commit comments

Comments
 (0)