81 lines
1.6 KiB
YAML
81 lines
1.6 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: [3.10]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install Backend Dependencies
|
|
run: |
|
|
cd backend
|
|
pip install -r requirements.txt
|
|
|
|
- name: Run Backend Tests
|
|
run: |
|
|
cd backend
|
|
pytest tests/ --verbose --cov=.
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
|
|
- name: Install Frontend Dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Run Frontend Tests & Build
|
|
run: |
|
|
cd frontend
|
|
npm test -- --watchAll=false
|
|
npm run build
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Backend Lint
|
|
run: |
|
|
cd backend
|
|
pip install black flake8
|
|
black --check .
|
|
flake8 .
|
|
|
|
- name: Frontend Lint
|
|
run: |
|
|
cd frontend
|
|
npm install --save-dev eslint
|
|
npm run lint
|
|
|
|
deploy:
|
|
needs: [test, lint]
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Deploy to Server (Placeholder)
|
|
run: echo "Deploy script here - e.g., rsync to server or trigger webhook"
|
|
|
|
- name: Notify on Success
|
|
run: echo "Pipeline passed! Ready for deployment."
|