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 6d0ea1a commit 4523bcc
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout code without submodules
uses: actions/checkout@v3 # Updated to v3
uses: actions/checkout@v3
with:
submodules: false # Skips submodule initialization

Expand All @@ -28,30 +28,29 @@ jobs:
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt # Ensure all dependencies are installed, including requests
pip install -r backend/requirements.txt # Ensure all dependencies are installed, including requests
- name: Cache Python dependencies
uses: actions/cache@v3 # Using the latest stable version
uses: actions/cache@v3
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-
- name: Run pylint (backend only on changed files)
run: |
source venv/bin/activate
# Compare against the remote main branch to handle the first commit
changed_files=$(git diff --name-only origin/main...HEAD | grep '\.py$' || true)
changed_files=$(git diff --name-only origin/main...HEAD | grep '^backend/' || true)
if [ -n "$changed_files" ]; then
pylint $changed_files --exit-zero | tee pylint.log
pylint backend --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 # Exit with status 0 (success) if no Python files changed
echo "No Python files changed in the backend, skipping pylint."
exit 0 # Exit with status 0 (success) if no Python files changed in the backend
fi
test:
Expand All @@ -60,7 +59,7 @@ jobs:

steps:
- name: Checkout code without submodules
uses: actions/checkout@v3 # Updated to v3
uses: actions/checkout@v3
with:
submodules: false # Skips submodule initialization

Expand All @@ -77,7 +76,7 @@ jobs:
pip install pytest-html
- name: Cache Python dependencies
uses: actions/cache@v3 # Using the latest stable version
uses: actions/cache@v3
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
Expand Down Expand Up @@ -119,7 +118,7 @@ jobs:

steps:
- name: Checkout repository without submodules
uses: actions/checkout@v3 # Updated to v3
uses: actions/checkout@v3
with:
submodules: false # Skips submodule initialization

Expand All @@ -129,7 +128,7 @@ jobs:
node-version: '20'

- name: Cache node modules
uses: actions/cache@v3 # Using the latest stable version
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('frontend/package-lock.json') }}
Expand Down

0 comments on commit 4523bcc

Please sign in to comment.