@@ -0,0 +1,96 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
pull_request:
|
||||
branches: ['**']
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_USER: steakhouse
|
||||
POSTGRES_PASSWORD: steakhouse
|
||||
POSTGRES_DB: steakhouse
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U steakhouse"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
|
||||
env:
|
||||
DATABASE_URL: postgres://steakhouse:steakhouse@localhost:5432/steakhouse
|
||||
BETTER_AUTH_SECRET: ci-only-secret-not-used-in-production
|
||||
BETTER_AUTH_URL: http://localhost:4173
|
||||
STAFF_SEED_EMAIL: admin@example.com
|
||||
STAFF_SEED_PASSWORD: ci-only-password-not-used-in-production
|
||||
RESEND_API_KEY: re_ci_dummy_key
|
||||
RESERVATIONS_FROM_EMAIL: 'Steakhaus bei Mirko <onboarding@resend.dev>'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Type check
|
||||
run: npx tsc --noEmit
|
||||
|
||||
- name: Check that Drizzle migrations are up to date
|
||||
run: |
|
||||
npx drizzle-kit generate
|
||||
if [ -n "$(git status --porcelain drizzle)" ]; then
|
||||
echo "::error::src/db/schema.ts changed without a matching migration. Run 'npm run db:generate' and commit the result."
|
||||
git status --porcelain drizzle
|
||||
git diff drizzle
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Apply migrations
|
||||
run: npm run db:migrate
|
||||
|
||||
- name: Seed baseline data
|
||||
run: npm run db:seed
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Smoke test the production build
|
||||
run: |
|
||||
npx vite preview --port 4173 &
|
||||
PREVIEW_PID=$!
|
||||
|
||||
for i in $(seq 1 30); do
|
||||
curl -sf http://localhost:4173/ >/dev/null 2>&1 && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
check() {
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:4173$1")
|
||||
if [ "$code" != "$2" ]; then
|
||||
echo "::error::GET $1 returned $code, expected $2"
|
||||
kill "$PREVIEW_PID"
|
||||
exit 1
|
||||
fi
|
||||
echo "GET $1 -> $code"
|
||||
}
|
||||
|
||||
check / 200
|
||||
check /staff/login 200
|
||||
check /impressum 200
|
||||
|
||||
kill "$PREVIEW_PID"
|
||||
Reference in New Issue
Block a user