Repository navigation
185 lines (173 loc) · 6.76 KB
/
Copy pathmutation.yml
File metadata and controls
185 lines (173 loc) · 6.76 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
name: Mutation Testing
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
test-group:
type: choice
options: [fast, full]
default: fast
test-selection:
type: choice
options: [coverage, full]
default: coverage
workflow_call:
inputs:
test-group:
type: string
default: fast
test-selection:
type: string
default: coverage
test-order:
type: string
default: component
full-source:
type: boolean
default: false
concurrency:
group: mutation-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}-${{ inputs.test-group || 'fast' }}-${{ inputs.test-selection || 'coverage' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
env:
MUTATION_TEST_GROUP: ${{ inputs.test-group || 'fast' }}
MUTATION_TEST_SELECTION: ${{ inputs.test-selection || 'coverage' }}
MUTATION_TEST_ORDER: ${{ inputs.test-order || 'component' }}
PYTHONHASHSEED: "0"
TRAILMARK_REQUIRE_BINARY_TOOLS: "1"
TRAILMARK_LLVM_OBJDUMP: /usr/bin/llvm-objdump
TRAILMARK_LLVM_SYMBOLIZER: /usr/bin/llvm-symbolizer
TRAILMARK_LLVM_READOBJ: /usr/bin/llvm-readobj
TRAILMARK_GNU_OBJDUMP: /usr/bin/objdump
TRAILMARK_GNU_SYMBOLIZER: /usr/bin/addr2line
jobs:
scope:
name: Select mutation scope
runs-on: ubuntu-latest
outputs:
reviewed: ${{ steps.scope.outputs.reviewed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Include the full campaign for runner changes
id: scope
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
FULL_SOURCE: ${{ inputs.full-source }}
run: |
reviewed=false
if [[ "$GITHUB_EVENT_NAME" == pull_request ]]; then
reviewed=true
changed=$(git diff --name-only "$PR_BASE_SHA" HEAD)
if grep -Eq '^(\.github/workflows/mutation\.yml$|tests/(run_mutations|mutation_[^/]+|test_mutation_[^/]+|conftest|parse_work|test_test_policy)\.py$|pyproject\.toml$|uv\.lock$)' <<< "$changed"; then
reviewed=false
fi
fi
if [[ "$FULL_SOURCE" == true ]]; then reviewed=false; fi
echo "reviewed=$reviewed" >> "$GITHUB_OUTPUT"
baselines:
name: Mutation baseline and coverage
needs: scope
runs-on: ubuntu-latest
env:
BASELINE_SHARD: 1/1
MUTATION_REVIEWED: ${{ needs.scope.outputs.reviewed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
version: "0.13.9"
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.13"
- run: sudo apt-get update && sudo apt-get install -y llvm binutils-multiarch
- run: npm ci
- run: uv sync --locked --all-groups --extra binary
- name: Validate baseline and collect test coverage
run: |
scope=()
if [[ "$MUTATION_REVIEWED" == true ]]; then scope+=(--reviewed); fi
uv run --locked --extra binary python -m tests.run_mutations "${scope[@]}" --test-group="$MUTATION_TEST_GROUP" --test-selection="$MUTATION_TEST_SELECTION" --test-order="$MUTATION_TEST_ORDER" --baseline-shard="$BASELINE_SHARD"
- name: Upload validated baselines
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mutation-baseline-${{ env.MUTATION_TEST_GROUP }}
overwrite: true
path: |
coverage/gremlins/baseline-*.json
coverage/gremlins/coverage-plan.json
if-no-files-found: error
gremlins:
name: Mutation shard ${{ matrix.shard }}/32
needs: [scope, baselines]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [
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,
]
env:
MUTATION_SHARD: ${{ matrix.shard }}/32
MUTATION_REVIEWED: ${{ needs.scope.outputs.reviewed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
version: "0.13.9"
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.13"
- run: sudo apt-get update && sudo apt-get install -y llvm binutils-multiarch
- run: npm ci
- run: uv sync --locked --all-groups --extra binary
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: mutation-baseline-${{ env.MUTATION_TEST_GROUP }}
path: coverage/gremlins/baselines
- name: Run mutation campaign with shared baselines
run: |
scope=()
if [[ "$MUTATION_REVIEWED" == true ]]; then scope+=(--reviewed); fi
uv run --locked --extra binary python -m tests.run_mutations "${scope[@]}" --test-group="$MUTATION_TEST_GROUP" --test-selection="$MUTATION_TEST_SELECTION" --test-order="$MUTATION_TEST_ORDER" --workers=4 --shard="$MUTATION_SHARD" --baselines=coverage/gremlins/baselines
- name: Enforce reviewed mutation baseline
run: uv run --locked --extra binary python -m tests.mutation_gate --shard="$MUTATION_SHARD"
- name: Record revision
if: always()
run: |
mkdir -p coverage/gremlins
git rev-parse HEAD > coverage/gremlins/revision.txt
- name: Upload mutation reports
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mutation-report-${{ github.sha }}-${{ env.MUTATION_TEST_GROUP }}-shard-${{ matrix.shard }}
overwrite: true
path: coverage/gremlins/
if-no-files-found: error
mutation-gate:
name: Mutation Testing
if: always()
needs: [scope, baselines, gremlins]
runs-on: ubuntu-latest
steps:
- name: Require all mutation shards to pass
env:
MUTATION_RESULT: ${{ needs.gremlins.result }}
BASELINE_RESULT: ${{ needs.baselines.result }}
SCOPE_RESULT: ${{ needs.scope.result }}
run: |
test "$SCOPE_RESULT" = success
test "$BASELINE_RESULT" = success
test "$MUTATION_RESULT" = success