* fix(setup): write .env.local not .env, fix npm->pnpm in completion message
setup.mjs was writing AUTH_SECRET to the git-tracked .env file instead of
.env.local, creating a security risk for users who commit their fork.
Also fixes the completion message which incorrectly instructed users to run
npm run dev instead of pnpm dev (project uses pnpm@9).
* ci: add multi-OS matrix for pnpm setup, fix stale action versions
Adds ubuntu/windows/macos matrix to test-setup job so the install
instructions are verified on all three platforms on every PR. Fixes
actions/checkout, pnpm/action-setup, and actions/setup-node all
pointing at non-existent @v6. Splits into two jobs: test-setup
(3 OS) and test-dev (ubuntu-only, needs Docker).
* fix(ci): use pnpm run setup not pnpm setup
pnpm setup is pnpm's built-in shell config command (writes to .bashrc).
pnpm run setup runs the project script. All three occurrences fixed.
* fix(dev): load .env.local in dev.mjs before spawning workers
Turbopack workers inherit process.env at spawn time, before Next.js
completes its own .env.local loading. If ENCRYPTION_MASTER_KEY is not
already in process.env when concurrently spawns next dev, the
instrumentation.ts startup check sees it as unset and crashes the server.
Fix: loadEnv('.env.local') in dev.mjs after loading .env so all secrets
are present in process.env before any child processes are spawned.
Also fix CI idempotency test: pnpm setup calls pnpm's built-in shell
config command, not the project setup script. Changed to pnpm run setup.
129 lines
3.7 KiB
YAML
129 lines
3.7 KiB
YAML
name: Test Local Dev Environment
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- "scripts/setup.mjs"
|
|
- ".env.example"
|
|
- "package.json"
|
|
- ".github/workflows/test-local-dev.yml"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# Runs on all 3 OS — tests the actual pnpm setup command users run
|
|
test-setup:
|
|
name: pnpm setup (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Run pnpm setup
|
|
run: pnpm run setup
|
|
|
|
- name: Verify .env.local was created (not .env)
|
|
shell: bash
|
|
run: |
|
|
if [ ! -f .env.local ]; then
|
|
echo "FAIL: .env.local was not created by pnpm setup"
|
|
exit 1
|
|
fi
|
|
echo "PASS: .env.local exists"
|
|
|
|
# Regression guard: AUTH_SECRET must NOT be in the git-tracked .env
|
|
if [ -f .env ] && grep -qE "^AUTH_SECRET=[a-f0-9]{10}" .env; then
|
|
echo "FAIL: AUTH_SECRET was written to .env (git-tracked) instead of .env.local"
|
|
exit 1
|
|
fi
|
|
echo "PASS: .env does not contain a generated AUTH_SECRET"
|
|
|
|
- name: Verify AUTH_SECRET generated correctly
|
|
shell: bash
|
|
run: |
|
|
if ! grep -qE "^AUTH_SECRET=[a-f0-9]{64}$" .env.local; then
|
|
echo "FAIL: AUTH_SECRET missing or wrong format in .env.local"
|
|
grep "AUTH_SECRET" .env.local || echo "(AUTH_SECRET line not found)"
|
|
exit 1
|
|
fi
|
|
echo "PASS: AUTH_SECRET is 64-char hex"
|
|
|
|
- name: Verify ENCRYPTION_MASTER_KEY generated correctly
|
|
shell: bash
|
|
run: |
|
|
if ! grep -qE "^ENCRYPTION_MASTER_KEY=[a-f0-9]{64}$" .env.local; then
|
|
echo "FAIL: ENCRYPTION_MASTER_KEY missing or wrong format in .env.local"
|
|
exit 1
|
|
fi
|
|
echo "PASS: ENCRYPTION_MASTER_KEY is 64-char hex"
|
|
|
|
- name: Verify idempotency (re-run must skip gracefully)
|
|
shell: bash
|
|
run: |
|
|
output=$(pnpm run setup 2>&1)
|
|
echo "$output"
|
|
if echo "$output" | grep -q "already exists"; then
|
|
echo "PASS: second run skipped gracefully"
|
|
else
|
|
echo "FAIL: re-run did not skip"
|
|
exit 1
|
|
fi
|
|
|
|
# Linux-only: full predev + dev server smoke test (requires Docker)
|
|
test-dev:
|
|
name: pnpm dev smoke test (ubuntu)
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NEXT_PUBLIC_WWV_EDITION: local
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
|
|
- name: Create coolify docker network
|
|
run: docker network create coolify || true
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Run pnpm setup
|
|
run: pnpm run setup
|
|
|
|
- name: Run predev (Docker DB + Prisma + Cesium + plugins)
|
|
run: pnpm run predev
|
|
|
|
- name: Start dev server and wait for ready
|
|
run: |
|
|
pnpm run dev &
|
|
DEV_PID=$!
|
|
echo "Waiting for Next.js on :3000 (up to 120s)..."
|
|
timeout 120 bash -c 'until curl -sf http://localhost:3000 > /dev/null; do sleep 5; done'
|
|
if ! kill -0 $DEV_PID 2>/dev/null; then
|
|
echo "FAIL: dev server crashed before responding"
|
|
exit 1
|
|
fi
|
|
echo "PASS: dev server responded on :3000"
|
|
kill $DEV_PID
|