Skip to content

petprofile + homepage modified #85

petprofile + homepage modified

petprofile + homepage modified #85

Workflow file for this run

name: CI Backend + Frontend Workflow
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
backend-ci:
runs-on: self-hosted
defaults:
run:
working-directory: ./backend
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install backend dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint pytest requests
- name: Run pylint on backend
run: |
git fetch origin main
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
fi
- name: Start backend server (background)
run: |
python main.py &
for i in {1..10}; do
curl -s http://localhost:5000/api/pets && break || sleep 2
done
- name: Initialize database
run: |
python init_db.py
- name: Run pytest on backend (HTTP API tests)
run: |
pytest tests/
frontend-build:
runs-on: self-hosted
defaults:
run:
working-directory: ./frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install frontend dependencies
run: |
npm install
- name: Build frontend
run: |
npm run build