Skip to content

Commit 71684cd

Browse files
author
Arthur VINCENT
committed
CI: add ci
1 parent 228a43b commit 71684cd

2 files changed

Lines changed: 54 additions & 2 deletions

File tree

.github/workflows/build_and_test_app.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ permissions:
1010
env:
1111
OTB_RELEASE: 9.1.0
1212
jobs:
13+
quality:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: setup python 3.10
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: "3.10"
21+
- name: install quality deps
22+
run: |
23+
pip install pylint mccabe
24+
- name: code quality
25+
run: |
26+
pylint --disable=all --fail-under=10 --enable=too-many-statements .
27+
pylint --disable=all --fail-under=10 --enable=too-many-nested-blocks .
28+
./continuous_integration/scripts/check_mccabe_complexity.sh 25 .
1329
test:
1430
runs-on: ubuntu-22.04
1531
steps:
@@ -27,7 +43,7 @@ jobs:
2743
source /opt/otb/otbenv.profile
2844
sh /opt/otb/recompile_bindings.sh
2945
python -m pip install --upgrade pip
30-
pip install flake8 pytest
46+
pip install pytest pytest-cov
3147
if [ -f docker/requirements.txt ]; then pip install -r docker/requirements.txt; fi
3248
- name: pytest
3349
run: |
@@ -43,4 +59,4 @@ jobs:
4359
export OTB_INSTALL_DIR=/opt/otb
4460
export LC_NUMERIC=C
4561
46-
pytest -s
62+
pytest -s --cov-fail-under=65
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ] || [ -z "$2" ]; then
4+
echo "Error: You must specify a McCabe threshold and a directory to analyze."
5+
echo "Usage: $0 <threshold> <directory>"
6+
exit 1
7+
fi
8+
9+
threshold=$1
10+
directory=$2
11+
12+
if [ ! -d "$directory" ]; then
13+
echo "Error: The directory '$directory' does not exist."
14+
exit 1
15+
fi
16+
17+
all_files_ok=true
18+
for file in $(find "$directory" -name "*.py"); do
19+
echo "Analyzing $file ..."
20+
output=$(python -m mccabe --min "$threshold" "$file")
21+
22+
if [ -n "$output" ]; then
23+
echo "Error: McCabe complexity too high in $file"
24+
echo "$output"
25+
all_files_ok=false
26+
fi
27+
done
28+
29+
if $all_files_ok; then
30+
echo "✅ All files have McCabe scores less than or equal to $threshold. ✅"
31+
else
32+
echo "❌ Some files have a complexity higher than $threshold"
33+
exit 1
34+
fi
35+
36+
exit 0

0 commit comments

Comments
 (0)