116 lines
No EOL
2.6 KiB
YAML
116 lines
No EOL
2.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
backend-test:
|
|
runs-on: [docker]
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
env:
|
|
POSTGRES_USER: test
|
|
POSTGRES_PASSWORD: test
|
|
POSTGRES_DB: test_db
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
container:
|
|
image: nikolaik/python-nodejs:python3.12-nodejs24-alpine
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Set up Python
|
|
run: |
|
|
python --version
|
|
|
|
- name: Cache pip packages
|
|
uses: actions/cache@v3
|
|
with:
|
|
# This path is on the runner, but we mounted it to the container
|
|
path: /tmp/pip-cache
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements/dev.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
cd backend
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements/dev.txt
|
|
|
|
- name: Lint with flake8
|
|
run: |
|
|
cd backend
|
|
flake8 app tests --count --max-complexity=10 --max-line-length=127 --statistics --show-source
|
|
|
|
- name: Run tests
|
|
env:
|
|
DATABASE_URL: postgresql://test:test@postgres:5432/test_db
|
|
SECRET_KEY: test-secret-key
|
|
JWT_SECRET_KEY: test-jwt-secret
|
|
FLASK_ENV: testing
|
|
run: |
|
|
cd backend
|
|
pytest --cov=app --cov-report=xml --cov-report=term
|
|
|
|
frontend-test:
|
|
runs-on: [docker]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Lint
|
|
run: |
|
|
cd frontend
|
|
npm run lint
|
|
|
|
- name: Run tests
|
|
run: |
|
|
cd frontend
|
|
npm test -- --run --coverage
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./frontend/coverage/coverage-final.json
|
|
flags: frontend
|
|
name: frontend-coverage
|
|
|
|
build:
|
|
runs-on: [docker]
|
|
needs: [backend-test, frontend-test]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Build backend
|
|
run: |
|
|
cd backend
|
|
docker build -t crafting-shop-backend:test .
|
|
|
|
- name: Build frontend
|
|
run: |
|
|
cd frontend
|
|
docker build -t crafting-shop-frontend:test . |