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 23, 2025
1 parent ef20f8e commit 03cf790
Showing 1 changed file with 49 additions and 20 deletions.
69 changes: 49 additions & 20 deletions backend/.github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,68 @@
name: Backend CI
name: Backend CI Pipeline

# Trigger workflow on push or pull request to develop and main branches
on:
push:
paths:
- 'backend/**'
branches:
- develop
- main
pull_request:
paths:
- 'backend/**'
branches:
- develop
- main

jobs:
backend-ci:
runs-on: ubuntu-latest
lint:
runs-on: self-hosted

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v2
with:
python-version: '3.11' # Adjust Python version if needed

- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
pip install -r backend/requirements.txt
- name: Run pylint on Python code
run: |
source venv/bin/activate
pylint backend/main.py backend/db.py backend/init_db.py # Add more files as needed
test:
runs-on: self-hosted
needs: lint # Ensure this job runs after linting

steps:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Install dependencies
working-directory: ./backend
run: |
pip install -r requirements.txt
python -m venv venv
source venv/bin/activate
pip install -r backend/requirements.txt
- name: Run pylint on backend
working-directory: ./backend
- name: Start the API server
run: |
pylint main.py db.py init_db.py
# Start the API server in the background
nohup python backend/main.py & # Replace with the command to start your API
sleep 5 # Wait for the server to be ready (adjust this if needed)
- name: Run Pytest
working-directory: ./backend
- name: Run tests with pytest
env:
BASE_URL: http://127.0.0.1:5000 # Assuming your API is running on this address
run: |
python main.py & # Run server
sleep 5 # Give it time to start
pytest tests/
source venv/bin/activate
pytest backend/tests --maxfail=1 --disable-warnings -q

0 comments on commit 03cf790

Please sign in to comment.