-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci.sh
More file actions
executable file
·45 lines (38 loc) · 1.85 KB
/
Copy pathci.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.85 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
#!/bin/bash
# set -euxo pipefail
(ruff check . && ruff format --check .) && { echo "Ruff check successful"; true; } || { echo "Ruff check failed, skipping the rest of the pipeline" && exit 1; } &&
mypy . && { echo "Mypy check successful"; true; } || { echo "Mypy check failed, skipping the rest of the pipeline" && exit 1; } &&
# Regular tests (exclude all *_fuzz.py files)
COVERAGE_FILE=.coverage.regular python -m pytest \
--cov=src --cov-branch --cov-fail-under=80 \
--ignore-glob='*_fuzz.py' \
&& { echo "Regular tests passed"; true; } || { echo "Regular tests failed" && exit 1; } &&
# Fuzz tests only (collect only *_fuzz.py files)
COVERAGE_FILE=.coverage.fuzz python -m pytest \
--cov=src --cov-branch --cov-fail-under=50 \
--override-ini="python_files=*_fuzz.py" \
&& { echo "Fuzz tests passed"; true; } || { echo "Fuzz tests failed" && exit 1; } &&
# Separate reports
echo "=== Regular Test Coverage ===" &&
coverage report --data-file=.coverage.regular &&
echo "=== Fuzz Test Coverage ===" &&
coverage report --data-file=.coverage.fuzz &&
# Combined report
coverage combine --keep .coverage.regular .coverage.fuzz &&
echo "=== Combined Coverage ===" &&
coverage report && { echo "Pytest check successful"; true; } || { echo "Pytest check failed, skipping the rest of the pipeline" && exit 1; } &&
# Mutation testing (regular tests only)
MUTATION_THRESHOLD=40
echo "=== Mutation Testing ===" &&
mutmut run --no-progress 2>&1;
mutmut results &&
TOTAL=$(mutmut junitxml | grep -oP 'tests="\K\d+') &&
SURVIVED=$(mutmut junitxml | grep -oP 'failures="\K\d+') &&
KILLED=$((TOTAL - SURVIVED)) &&
SCORE=$((KILLED * 100 / TOTAL)) &&
echo "Mutation score: ${SCORE}% (${KILLED}/${TOTAL} killed)" &&
if [ "$SCORE" -lt "$MUTATION_THRESHOLD" ]; then
echo "Mutation score ${SCORE}% is below threshold of ${MUTATION_THRESHOLD}%" && exit 1
else
echo "Mutation testing passed"
fi