200 lines
4.8 KiB
YAML
200 lines
4.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
jobs:
|
|
lint-and-format:
|
|
name: Lint & Format Check
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run Prettier check
|
|
run: npm run format:check
|
|
|
|
- name: Lint backend
|
|
run: npm run backend:lint --workspace=apps/backend
|
|
|
|
- name: Lint frontend
|
|
run: npm run frontend:lint --workspace=apps/frontend
|
|
|
|
test-backend:
|
|
name: Test Backend
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
env:
|
|
POSTGRES_USER: xpeditis_test
|
|
POSTGRES_PASSWORD: xpeditis_test
|
|
POSTGRES_DB: xpeditis_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 6379:6379
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run backend unit tests
|
|
working-directory: apps/backend
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_HOST: localhost
|
|
DATABASE_PORT: 5432
|
|
DATABASE_USER: xpeditis_test
|
|
DATABASE_PASSWORD: xpeditis_test
|
|
DATABASE_NAME: xpeditis_test
|
|
REDIS_HOST: localhost
|
|
REDIS_PORT: 6379
|
|
REDIS_PASSWORD: ''
|
|
JWT_SECRET: test-jwt-secret
|
|
run: npm run test
|
|
|
|
- name: Run backend E2E tests
|
|
working-directory: apps/backend
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_HOST: localhost
|
|
DATABASE_PORT: 5432
|
|
DATABASE_USER: xpeditis_test
|
|
DATABASE_PASSWORD: xpeditis_test
|
|
DATABASE_NAME: xpeditis_test
|
|
REDIS_HOST: localhost
|
|
REDIS_PORT: 6379
|
|
REDIS_PASSWORD: ''
|
|
JWT_SECRET: test-jwt-secret
|
|
run: npm run test:e2e
|
|
|
|
- name: Upload backend coverage
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./apps/backend/coverage/lcov.info
|
|
flags: backend
|
|
name: backend-coverage
|
|
|
|
test-frontend:
|
|
name: Test Frontend
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run frontend tests
|
|
working-directory: apps/frontend
|
|
run: npm run test
|
|
|
|
- name: Upload frontend coverage
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./apps/frontend/coverage/lcov.info
|
|
flags: frontend
|
|
name: frontend-coverage
|
|
|
|
build-backend:
|
|
name: Build Backend
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-and-format, test-backend]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build backend
|
|
working-directory: apps/backend
|
|
run: npm run build
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: backend-dist
|
|
path: apps/backend/dist
|
|
|
|
build-frontend:
|
|
name: Build Frontend
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-and-format, test-frontend]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build frontend
|
|
working-directory: apps/frontend
|
|
env:
|
|
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL || 'http://localhost:4000' }}
|
|
run: npm run build
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: frontend-build
|
|
path: apps/frontend/.next
|