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 2674710 commit e7beee4
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ jobs:

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

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v2 # Using v2 for setup-python
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate # Ensure the virtual environment is activated
pip install -r backend/requirements.txt # Install all dependencies, including requests
source venv/bin/activate
pip install -r requirements.txt # Ensure all dependencies are installed, including requests
- name: Cache Python dependencies
uses: actions/cache@v3
uses: actions/cache@v2 # Using v2 for actions/cache
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
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 # Activate the virtual environment before running pylint
changed_files=$(git diff --name-only origin/main...HEAD | grep '^backend/' || true)
source venv/bin/activate
changed_files=$(git diff --name-only origin/main...HEAD | grep '\.py$' || true)
if [ -n "$changed_files" ]; then
pylint backend --exit-zero | tee pylint.log
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 in the backend, skipping pylint."
exit 0 # Exit with status 0 (success) if no Python files changed in the backend
echo "No Python files changed, skipping pylint."
exit 0 # Exit with status 0 (success) if no Python files changed
fi
test:
Expand All @@ -59,24 +59,24 @@ jobs:

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

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v2 # Using v2 for setup-python
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate # Ensure the virtual environment is activated
pip install -r backend/requirements.txt # Install dependencies, including requests
source venv/bin/activate
pip install -r backend/requirements.txt # Ensure all dependencies are installed, including requests
pip install pytest-html
- name: Cache Python dependencies
uses: actions/cache@v3
uses: actions/cache@v2 # Using v2 for actions/cache
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
Expand All @@ -103,7 +103,7 @@ jobs:
pytest backend/tests --html=backend/test-report.html --self-contained-html
- name: Upload test report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2 # Using v2 for actions/upload-artifact
with:
name: backend-test-report
path: backend/test-report.html
Expand All @@ -118,17 +118,17 @@ jobs:

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

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v3 # Using the latest stable version for Node.js
with:
node-version: '20'

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

0 comments on commit e7beee4

Please sign in to comment.