Files
NextChair/.gitea/workflows/ci.yml
T
Stefan Lazic 51de4f4ef5 Database
Updated to just use DATABASE_* in everything other than local docker.
2026-08-07 17:30:12 +01:00

117 lines
3.5 KiB
YAML

# NextChair CI — lint, typecheck, unit + integration + E2E tests, and a
# production build, all against a real MySQL 8.0 service container (this
# app has no SQLite/mock-DB fallback — see docs/implementation-plan.md and
# the Phase 7 Postgres→MySQL migration notes in prisma/schema.prisma).
#
# Lives under .gitea/workflows/ because this repo's origin is a
# self-hosted Gitea instance (see `git remote -v`), and Gitea Actions only
# auto-discovers workflows there — not .github/workflows/. The YAML syntax
# itself is GitHub Actions-compatible, so this file works unchanged if the
# repo is ever pushed to GitHub too; only the directory matters for
# auto-discovery. If Gitea Actions isn't enabled for this instance, no
# harm — the workflow simply never triggers.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel a still-running CI run for the same branch/PR once a newer commit
# lands, instead of letting both finish.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# A throwaway, non-secret DB the mysql service creates for this run only
# — never a real deployment's database.
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: "3306"
DATABASE_NAME: nextchair
DATABASE_USER: root
DATABASE_PASSWORD: root
# Any fixed value works (see src/lib/booking-draft/sign.ts) — only needs
# to be consistent for the lifetime of this one CI run.
AUTH_SECRET: ci-run-secret-do-not-use-in-production
NEXT_PUBLIC_APP_URL: http://localhost:3000
CRON_SECRET: ci-run-cron-secret-do-not-use-in-production
# Explicit, even though these already default to "console" — CI must
# never attempt a real send regardless of what the environment defaults
# to (see src/services/notifications/providers/index.ts).
EMAIL_PROVIDER: console
PUSH_PROVIDER: console
jobs:
ci:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: nextchair
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Generate Prisma client
run: npx prisma generate
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Unit tests
run: npm run test
- name: Apply migrations
run: npx prisma migrate deploy
- name: Seed database
run: npm run prisma:seed
- name: Integration tests
run: npm run test:integration
- name: Production build
run: npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: E2E tests
run: npm run test:e2e
- name: Upload Playwright traces/screenshots on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-test-results
# playwright.config.ts uses the "list" reporter (no HTML report
# dir) but does keep a trace + screenshot per failed test here —
# see trace/screenshot settings in that file.
path: test-results/
retention-days: 7
if-no-files-found: ignore