From df4e836b90b0f1f83987356283d270bd5c0eff51 Mon Sep 17 00:00:00 2001 From: Prince D Rusweka Rwabongoya Date: Sun, 27 Apr 2025 23:11:17 -0400 Subject: [PATCH] Update backend-ci.yml --- .github/workflows/backend-ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index cd1a378..7f1bba1 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -47,11 +47,15 @@ jobs: - name: Run pylint on backend run: | - pylint --exit-zero --output-format=json $(git ls-files '*.py') > pylint_report.json - pylint_score=$(jq '[.[] | select(.score != null) | .score] | add / length' pylint_report.json) - echo "Pylint score: $pylint_score" - if (( $(echo "$pylint_score < 8.0" | bc -l) )); then - echo "Pylint score too low ($pylint_score)!" && exit 1 + changed_files=$(git diff --name-only origin/main...HEAD | grep '\.py$' || true) + if [ -n "$changed_files" ]; then + pylint $changed_files --exit-zero | tee pylint.log + SCORE=$(tail -n 2 pylint.log | grep -oP '[0-9]+\.[0-9]+(?=/10)') + echo "Pylint score: $SCORE" + python -c "import sys; sys.exit(0 if float('$SCORE') >= 8.0 else 1)" + else + echo "No Python files changed, skipping pylint." + exit 0 fi - name: Start backend server (background)