mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Local emulator base (#1233)
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Provision local-emulator projects from a local config file and return emulator credentials via a new internal endpoint. * Dashboard: "Open config file" flow to open local projects and refresh owned projects. * **Changes** * Branch config can prefer/read/write local files for emulator projects. * Environment config updates/resets are blocked for local-emulator projects. * Dashboard UI shows read-only notices and disables project creation in emulator mode. * Added DB mapping and a standard env flag to identify local-emulator projects. * **Tests** * New E2E tests covering provisioning and config restrictions. * **Chores** * Removed legacy emulator docs and compose; added CI workflow for local-emulator E2E runs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Konstantin Wohlwend <[email protected]>
This commit is contained in:
co-authored by
Konstantin Wohlwend
parent
aeb5f77ebc
commit
66adb4e50f
@@ -1,42 +0,0 @@
|
||||
name: Docker Emulator Test
|
||||
|
||||
on:
|
||||
workflow_dispatch # skip this workflow for now, unless manually triggered
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
# - dev
|
||||
# pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-compose
|
||||
docker-compose version
|
||||
|
||||
- name: Start emulator with docker compose
|
||||
run: |
|
||||
docker-compose -f docker/emulator/docker.compose.yaml up -d
|
||||
sleep 30
|
||||
docker-compose -f docker/emulator/docker.compose.yaml logs
|
||||
|
||||
- name: Check emulator health
|
||||
run: |
|
||||
echo "Attempting to connect to emulator dashboard..."
|
||||
curl -v http://localhost:32101
|
||||
response_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:32101)
|
||||
echo "Response code: $response_code"
|
||||
if [ $response_code -ne 200 ]; then
|
||||
echo "Emulator health check failed with status code: $response_code"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,179 @@
|
||||
name: Runs E2E API Tests (Local Emulator)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: E2E Tests (Local Emulator, Node ${{ matrix.node-version }})
|
||||
runs-on: ubicloud-standard-8
|
||||
env:
|
||||
NODE_ENV: test
|
||||
NEXT_PUBLIC_STACK_IS_LOCAL_EMULATOR: "true"
|
||||
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
|
||||
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
|
||||
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
|
||||
STACK_EXTERNAL_DB_SYNC_DIRECT: "false"
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
# Even just starting the Docker Compose as a daemon is slow because we have to download and build the images
|
||||
# so, we run it in the background
|
||||
- name: Start Docker Compose in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: docker compose -f docker/dependencies/docker.compose.yaml up --pull always -d &
|
||||
# we don't need to wait on anything, just need to start the daemon
|
||||
wait-on: /dev/null
|
||||
tail: true
|
||||
wait-for: 3s
|
||||
log-output-if: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Create .env.test.local file for apps/backend
|
||||
run: cp apps/backend/.env.development apps/backend/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for apps/dashboard
|
||||
run: cp apps/dashboard/.env.development apps/dashboard/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for apps/e2e
|
||||
run: cp apps/e2e/.env.development apps/e2e/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for docs
|
||||
run: cp docs/.env.development docs/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/cjs-test
|
||||
run: cp examples/cjs-test/.env.development examples/cjs-test/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/demo
|
||||
run: cp examples/demo/.env.development examples/demo/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/docs-examples
|
||||
run: cp examples/docs-examples/.env.development examples/docs-examples/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/e-commerce
|
||||
run: cp examples/e-commerce/.env.development examples/e-commerce/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/middleware
|
||||
run: cp examples/middleware/.env.development examples/middleware/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/supabase
|
||||
run: cp examples/supabase/.env.development examples/supabase/.env.test.local
|
||||
|
||||
- name: Create .env.test.local file for examples/convex
|
||||
run: cp examples/convex/.env.development examples/convex/.env.test.local
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Wait on Postgres
|
||||
run: pnpm run wait-until-postgres-is-ready:pg_isready
|
||||
|
||||
- name: Wait on Inbucket
|
||||
run: pnpx wait-on tcp:localhost:8129
|
||||
|
||||
- name: Wait on Svix
|
||||
run: pnpx wait-on tcp:localhost:8113
|
||||
|
||||
- name: Wait on QStash
|
||||
run: pnpx wait-on tcp:localhost:8125
|
||||
|
||||
- name: Wait on ClickHouse
|
||||
run: pnpx wait-on http://localhost:8136/ping
|
||||
|
||||
- name: Initialize database
|
||||
run: pnpm run db:init
|
||||
|
||||
- name: Start stack-backend in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: pnpm run start:backend --log-order=stream &
|
||||
wait-on: |
|
||||
http://localhost:8102
|
||||
tail: true
|
||||
wait-for: 30s
|
||||
log-output-if: true
|
||||
|
||||
- name: Start stack-dashboard in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: pnpm run start:dashboard --log-order=stream &
|
||||
wait-on: |
|
||||
http://localhost:8101
|
||||
tail: true
|
||||
wait-for: 30s
|
||||
log-output-if: true
|
||||
|
||||
- name: Start mock-oauth-server in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: pnpm run start:mock-oauth-server --log-order=stream &
|
||||
wait-on: |
|
||||
http://localhost:8102
|
||||
tail: true
|
||||
wait-for: 30s
|
||||
log-output-if: true
|
||||
|
||||
- name: Start run-email-queue in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: pnpm -C apps/backend run run-email-queue --log-order=stream &
|
||||
wait-on: |
|
||||
http://localhost:8102
|
||||
tail: true
|
||||
wait-for: 30s
|
||||
log-output-if: true
|
||||
|
||||
- name: Start run-cron-jobs in background
|
||||
uses: JarvusInnovations/[email protected]
|
||||
with:
|
||||
run: pnpm -C apps/backend run run-cron-jobs:test --log-order=stream &
|
||||
wait-on: |
|
||||
http://localhost:8102
|
||||
tail: true
|
||||
wait-for: 30s
|
||||
log-output-if: true
|
||||
|
||||
- name: Wait 10 seconds
|
||||
run: sleep 10
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test run
|
||||
|
||||
- name: Run tests again (attempt 1)
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
|
||||
run: pnpm test run
|
||||
|
||||
- name: Run tests again (attempt 2)
|
||||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
|
||||
run: pnpm test run
|
||||
|
||||
- name: Verify data integrity
|
||||
run: pnpm run verify-data-integrity --no-bail
|
||||
|
||||
- name: Print Docker Compose logs
|
||||
if: always()
|
||||
run: docker compose -f docker/dependencies/docker.compose.yaml logs
|
||||
Reference in New Issue
Block a user