-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (53 loc) · 1.66 KB
/
code-quality.yml
File metadata and controls
62 lines (53 loc) · 1.66 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
name: Code Quality Checks
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
code-quality:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint pytest
- name: Run flake8
run: |
if [ -f .flake8 ]; then
flake8 --config=.flake8 gravity_simulator/
else
flake8 gravity_simulator/
fi
- name: Run pylint
run: |
python_files=$(git ls-files 'gravity_simulator/*.py')
if [ -z "$python_files" ]; then
echo "No Python files found in gravity_simulator/"
exit 0
fi
pylint_output=$(pylint --fail-under=8.0 $python_files 2>&1)
echo "$pylint_output"
score=$(echo "$pylint_output" | grep 'rated at' | awk '{print $4}' | cut -d'/' -f1)
if [ -n "$score" ]; then
echo "Pylint score: $score"
if [ "$(echo "$score < 8.0" | awk '{print ($1 < 8.0)}')" = "1" ]; then
echo "Error: Pylint score $score is below minimum 8.0"
exit 1
fi
else
echo "Warning: Could not extract pylint score"
fi
- name: Run pytest
run: |
if [ -d "tests" ]; then
python -m pytest tests/ -v
else
echo "Tests directory not found, skipping pytest"
fi