92 lines
2.3 KiB
YAML
92 lines
2.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
verify:
|
|
name: Typecheck, test & build
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 25
|
|
|
|
# Riktiga tjänster i CI: migrationer + seed körs mot Postgres 16 med
|
|
# sök-extensions, precis som i produktion (i18n M7).
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: app_user
|
|
POSTGRES_PASSWORD: app_ci_password
|
|
POSTGRES_DB: app
|
|
ports: ["5432:5432"]
|
|
options: >-
|
|
--health-cmd "pg_isready -U app_user -d app"
|
|
--health-interval 5s --health-timeout 5s --health-retries 10
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports: ["6379:6379"]
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 5s --health-timeout 5s --health-retries 10
|
|
|
|
env:
|
|
DATABASE_URL: postgres://app_user:app_ci_password@localhost:5432/app
|
|
REDIS_URL: redis://localhost:6379
|
|
AAMOS_MODE: mock
|
|
S3_MODE: mock
|
|
EMAIL_MODE: log
|
|
JWT_ACCESS_SECRET: ci-only-secret
|
|
JWT_REFRESH_SECRET: ci-only-secret-two
|
|
ENTITLEMENT_SIGNING_SECRET: ci-only-secret-three
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Varumärkesvakt (namnet lever endast i brand.config.json)
|
|
run: ./scripts/brand-guard.sh
|
|
|
|
- name: Prettier
|
|
run: pnpm format:check
|
|
|
|
- name: Typecheck
|
|
run: pnpm typecheck
|
|
|
|
- name: Test
|
|
run: pnpm test
|
|
|
|
- name: Build
|
|
run: pnpm build
|
|
|
|
- name: Migrera + seeda mot riktig Postgres
|
|
run: pnpm db:migrate && pnpm db:seed
|
|
|
|
- name: API-röktest (boot + healthz + readyz)
|
|
run: |
|
|
node apps/api/dist/index.js &
|
|
API_PID=$!
|
|
for i in $(seq 1 20); do
|
|
curl -fsS http://localhost:4000/healthz > /dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
curl -fsS http://localhost:4000/healthz
|
|
curl -fsS http://localhost:4000/readyz
|
|
kill $API_PID
|