forked from yuribodo/zksettle
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (93 loc) · 3.51 KB
/
Copy pathmutants.yml
File metadata and controls
111 lines (93 loc) · 3.51 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
name: Mutation Testing
on:
schedule:
- cron: "0 3 * * 1" # Monday 3am UTC
workflow_dispatch:
inputs:
packages:
description: "Comma-separated crate names (empty = all off-chain)"
required: false
type: string
extra_args:
description: "Extra cargo-mutants args (e.g. --shard 1/4)"
required: false
type: string
concurrency:
group: mutants-${{ github.ref }}
cancel-in-progress: true
jobs:
mutants:
name: cargo-mutants
runs-on: ubuntu-latest
timeout-minutes: 90
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
workspaces: backend -> target
- name: Install cargo-mutants
run: cargo install cargo-mutants@27.0.0 --locked
- name: Run mutation tests
env:
INPUT_PACKAGES: ${{ inputs.packages }}
INPUT_EXTRA_ARGS: ${{ inputs.extra_args }}
run: |
ARGS="--in-place"
if [ -n "$INPUT_PACKAGES" ]; then
IFS=',' read -ra PKGS <<< "$INPUT_PACKAGES"
for pkg in "${PKGS[@]}"; do
ARGS="$ARGS --package $(echo "$pkg" | xargs)"
done
else
for pkg in api-gateway indexer issuer-service sanctions-updater zksettle-crypto zksettle-types; do
ARGS="$ARGS --package $pkg"
done
fi
if [ -n "$INPUT_EXTRA_ARGS" ]; then
ARGS="$ARGS $INPUT_EXTRA_ARGS"
fi
cargo mutants $ARGS
- name: Generate summary
if: always()
run: |
OUTCOMES="mutants.out/outcomes.json"
if [ ! -f "$OUTCOMES" ]; then
echo "No outcomes.json found" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
CAUGHT=$(jq '[.outcomes[] | select(.scenario != "Baseline" and .summary == "CaughtMutant")] | length' "$OUTCOMES")
MISSED=$(jq '[.outcomes[] | select(.scenario != "Baseline" and .summary == "MissedMutant")] | length' "$OUTCOMES")
TIMEOUT=$(jq '[.outcomes[] | select(.scenario != "Baseline" and .summary == "Timeout")] | length' "$OUTCOMES")
UNVIABLE=$(jq '[.outcomes[] | select(.scenario != "Baseline" and .summary == "Unviable")] | length' "$OUTCOMES")
TESTED=$((CAUGHT + MISSED + TIMEOUT))
if [ "$TESTED" -gt 0 ]; then
SCORE=$(( (CAUGHT * 100) / TESTED ))
else
SCORE=0
fi
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Mutation Testing Results
| Metric | Count |
|--------|-------|
| Caught | $CAUGHT |
| Missed | $MISSED |
| Timeout | $TIMEOUT |
| Unviable | $UNVIABLE |
| **Score** | **${SCORE}%** |
EOF
if [ "$MISSED" -gt 0 ]; then
echo "### Surviving Mutants" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
jq -r '.outcomes[] | select(.summary == "MissedMutant") | "\(.scenario.Mutant.function) in \(.scenario.Mutant.source_file)"' "$OUTCOMES" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload mutation report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: mutation-report
path: backend/mutants.out/
retention-days: 30