workorder-desk/.github/workflows/ci.yml

91 lines
2.2 KiB
YAML

# Continuous integration — SPEC §12
# Node 20. Steps: lint → typecheck → test + coverage → build → docker build.
# Runs on every PR and on pushes to main.
name: CI
on:
push:
branches: ["master"]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run lint
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run typecheck
test:
name: Test (coverage)
runs-on: ubuntu-latest
services:
mongo:
image: mongo:7
ports:
- "27017:27017"
env:
# Backend integration tests run against the GitHub-hosted Mongo service
# (SPEC §11); falls back to mongodb-memory-server when unset.
MONGODB_URI: mongodb://127.0.0.1:27017/workorders
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: backend/coverage/lcov.info,frontend/coverage/lcov.info
flags: unittests
fail_ci_if_error: false
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, typecheck, test]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
docker:
name: Docker build
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Build backend image
run: docker build -f backend/Dockerfile --target prod -t workorders-api:ci .
- name: Build frontend/nginx image
run: docker build -f frontend/Dockerfile --target prod -t workorders-nginx:ci .