Skip to content

Commit

Permalink
wip(CI) start adding CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur VINCENT committed Dec 17, 2024
1 parent b17cdeb commit 212c41b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
conda create -n test_env python=3.8.13 libgdal=3.5.2 -c conda-forge -c defaults -y
conda activate test_env
PIP_NO_BINARY=rasterio pip install .
pip install pylint radon
pip install pylint mccabe
- name: code quality
shell: bash -l {0}
run: |
conda activate test_env
pylint --disable=all --fail-under=10 --enable=too-many-statements src/eolab/georastertools/
pylint --disable=all --fail-under=10 --enable=too-many-nested-blocks src/eolab/georastertools/
radon cc -s src/eolab/georastertools | awk '$1 ~ /^[A-Z]+/ && $2 > 25 { exit 1 }'
./continuous_integration/scripts/check_mccabe_complexity.sh 25 src/eolab/georastertools
- name: test
shell: bash -l {0}
run: |
Expand Down
36 changes: 36 additions & 0 deletions continuous_integration/scripts/check_mccabe_complexity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Error: You must specify a McCabe threshold and a directory to analyze."
echo "Usage: $0 <threshold> <directory>"
exit 1
fi

threshold=$1
directory=$2

if [ ! -d "$directory" ]; then
echo "Error: The directory '$directory' does not exist."
exit 1
fi

all_files_ok=true
for file in $(find "$directory" -name "*.py"); do
echo "Analyzing $file ..."
output=$(python -m mccabe --min "$threshold" "$file")

if [ -n "$output" ]; then
echo "Error: McCabe complexity too high in $file"
echo "$output"
all_files_ok=false
fi
done

if $all_files_ok; then
echo "✅ All files have McCabe scores less than or equal to $threshold. ✅"
else
echo "❌ Some files have a complexity higher than $threshold"
exit 1
fi

exit 0

0 comments on commit 212c41b

Please sign in to comment.