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 078c4cb commit 2674710
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions backend/.github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ jobs:
working-directory: backend

steps:
- name: Checkout code without submodules
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
pip install -r requirements.txt
pip install -r requirements.txt # Ensure all dependencies are installed, including requests
- name: Cache Python dependencies
uses: actions/cache@v2
uses: actions/cache@v2 # Using v2 for actions/cache
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -36,43 +41,42 @@ jobs:
- name: Run pylint (backend only on changed files)
run: |
source venv/bin/activate
changed_files=$(git diff --name-only HEAD^..HEAD | grep '\.py$' || true)
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 # Exit with status 0 (success) if no Python files changed
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)"
test:
runs-on: self-hosted
needs: lint

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code without submodules
uses: actions/checkout@v2 # Using v2 for actions/checkout
with:
submodules: false
clean: true
fetch-depth: 0
persist-credentials: false
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
pip install -r backend/requirements.txt
pip install -r backend/requirements.txt # Ensure all dependencies are installed, including requests
pip install pytest-html
- name: Cache Python dependencies
uses: actions/cache@v2
uses: actions/cache@v2 # Using v2 for actions/cache
with:
path: venv
key: ${{ runner.os }}-python-${{ hashFiles('backend/requirements.txt') }}
Expand All @@ -95,11 +99,11 @@ jobs:
env:
BASE_URL: http://127.0.0.1:5000
run: |
source venv/bin/activate
source venv/bin/activate # Activate the virtual environment before running tests
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 @@ -113,21 +117,18 @@ jobs:
needs: [lint, test]

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository without submodules
uses: actions/checkout@v2 # Using v2 for actions/checkout
with:
submodules: false
clean: true
fetch-depth: 0
persist-credentials: false
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@v2
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 2674710

Please sign in to comment.