-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |