Skip to content

Commit

Permalink
Update backend-ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
pdr21001 authored Apr 26, 2025
1 parent 1524e60 commit 896d9c1
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions backend/.github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,23 @@ jobs:
source venv/bin/activate
pip install -r requirements.txt
- name: Run pylint (backend only)
- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-
- name: Run pylint (backend only on changed files)
run: |
source venv/bin/activate
pylint . --exit-zero | tee pylint.log
changed_files=$(git diff --name-only HEAD^..HEAD | grep '\.py$' || true)
if [ -n "$changed_files" ]; then
pylint $changed_files --exit-zero | tee pylint.log
else
echo "No Python files changed, skipping pylint."
fi
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)"
Expand Down Expand Up @@ -58,6 +71,14 @@ jobs:
pip install -r backend/requirements.txt
pip install pytest-html
- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-
- name: Start Flask API server
run: |
nohup python backend/main.py > flask.log 2>&1 &
Expand All @@ -67,7 +88,7 @@ jobs:
break
fi
echo "Waiting for Flask... Attempt $i/10"
sleep 3
sleep 5
done
- name: Run backend tests with pytest
Expand All @@ -89,7 +110,7 @@ jobs:
build-frontend:
runs-on: self-hosted
needs: lint
needs: [lint, test]

steps:
- name: Checkout repository
Expand All @@ -105,6 +126,14 @@ jobs:
with:
node-version: '20'

- name: Cache node modules
uses: actions/cache@v2
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install frontend dependencies
working-directory: frontend
run: npm install
Expand Down

0 comments on commit 896d9c1

Please sign in to comment.