-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
54 lines (47 loc) · 1.55 KB
/
.pre-commit-config.yaml
File metadata and controls
54 lines (47 loc) · 1.55 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
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
- repo: local
hooks:
- id: code-smell-check
name: Check code smells in pytest tests
entry: bash
language: system
pass_filenames: false
args:
- "-c"
- |
# Run analysis
output=$(python utils/code_smells.py --dir=tests)
echo "$output"
percentage=$(echo "$output" | grep "Percentage of 'smelly' tests: " | awk '{print $5}' | sed 's/%//')
# Check if percentage is numeric
if ! [[ "$percentage" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
echo "Failed to determine the percentage of 'smelly' tests. Make sure the output contains the expected line."
exit 1
fi
# Now safely compare - if percentage is 50% or higher, block the commit
result=$(echo "$percentage >= 50" | bc)
if [ "$result" -eq 1 ]; then
echo "Too many 'smelly' tests (${percentage}%). Commit blocked!"
exit 1
else
echo "Acceptable level of 'smelly' tests (${percentage}%). Commit allowed."
fi
always_run: true
verbose: true
- id: framework-unit-tests
name: Run framework unit tests
entry: pytest
language: system
pass_filenames: false
args: [
"-m unit",
"-v"
]
always_run: true
verbose: true