-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (91 loc) · 3.31 KB
/
mutation.yaml
File metadata and controls
107 lines (91 loc) · 3.31 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
name: Mutation Testing
on:
pull_request:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: mutation-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.26"
RAGCLI_MUTATION: "1"
MUTATION_ARTIFACT_DIR: .artifacts/mutation
MUTATION_OUTPUT: .artifacts/mutation/mutation-report.json
jobs:
mutation:
name: Gremlins
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Prepare mutation artifacts
run: mkdir -p "${MUTATION_ARTIFACT_DIR}"
- name: Run Gremlins on PR diff
id: gremlins_pr
if: github.event_name == 'pull_request'
continue-on-error: true
uses: go-gremlins/gremlins-action@v1
with:
version: v0.6.0
args: --output "${{ env.MUTATION_OUTPUT }}" --output-statuses lctv --diff "origin/${{ github.base_ref }}"
- name: Run Gremlins on full repository
id: gremlins_full
if: github.event_name != 'pull_request'
continue-on-error: true
uses: go-gremlins/gremlins-action@v1
with:
version: v0.6.0
args: --output "${{ env.MUTATION_OUTPUT }}" --output-statuses lctv
- name: Upload mutation report
if: always()
uses: actions/upload-artifact@v4
with:
name: mutation-report
path: ${{ env.MUTATION_ARTIFACT_DIR }}
if-no-files-found: ignore
- name: Write mutation summary
if: always()
env:
MUTATION_OUTPUT: ${{ env.MUTATION_OUTPUT }}
run: |
python3 - <<'PY'
import json
import os
from pathlib import Path
summary_path = os.environ["GITHUB_STEP_SUMMARY"]
report_path = Path(os.environ["MUTATION_OUTPUT"])
lines = ["## Mutation Testing", ""]
if not report_path.exists():
lines.append("Mutation report was not produced.")
else:
report = json.loads(report_path.read_text(encoding="utf-8"))
lines.extend([
f"- Test efficacy: {report.get('test_efficacy', 0):.2f}%",
f"- Mutations coverage: {report.get('mutations_coverage', 0):.2f}%",
f"- Mutants total: {report.get('mutants_total', 0)}",
f"- Killed: {report.get('mutants_killed', 0)}",
f"- Lived: {report.get('mutants_lived', 0)}",
f"- Not covered: {report.get('mutants_not_covered', 0)}",
f"- Not viable: {report.get('mutants_not_viable', 0)}",
f"- Elapsed time: {report.get('elapsed_time', 0):.3f}s",
])
with open(summary_path, "a", encoding="utf-8") as fh:
fh.write("\n".join(lines) + "\n")
PY
- name: Enforce mutation thresholds
if: always()
run: |
if [[ "${{ steps.gremlins_pr.outcome }}" == "failure" || "${{ steps.gremlins_full.outcome }}" == "failure" ]]; then
echo "Gremlins mutation thresholds were not met." >&2
exit 1
fi