Skip to content

Commit 8a76453

Browse files
committed
Update
1 parent afae79b commit 8a76453

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+446
-216
lines changed

.claude/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"hooks": [
2222
{
2323
"type": "command",
24-
"command": "if ! curl -s --connect-timeout 1 http://localhost:8102 >/dev/null 2>&1; then echo -e '\\n\\n\\033[1;31mCannot reach backend on port 8102! Please run `pnpm run dev` before querying Claude Code\\033[0m\\n\\n' >&2; exit 2; fi"
24+
"command": "PORT=${STACK_PORT_PREFIX:-81}02; if ! curl -s --connect-timeout 1 \"http://localhost:$PORT\" >/dev/null 2>&1; then echo -e \"\\n\\n\\033[1;31mCannot reach backend on port $PORT! Please run \\`pnpm run dev\\` before querying Claude Code\\033[0m\\n\\n\" >&2; exit 2; fi"
2525
}
2626
]
2727
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Runs E2E API Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubicloud-standard-8
17+
env:
18+
NODE_ENV: test
19+
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
20+
STACK_DIRECT_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:6728/stackframe"
21+
STACK_PORT_PREFIX: "67"
22+
23+
strategy:
24+
matrix:
25+
node-version: [22.x]
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: Setup Node.js ${{ matrix.node-version }}
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: ${{ matrix.node-version }}
34+
35+
- name: Setup pnpm
36+
uses: pnpm/action-setup@v3
37+
with:
38+
version: 9.1.2
39+
40+
# Even just starting the Docker Compose as a daemon is slow because we have to download and build the images
41+
# so, we run it in the background
42+
- name: Start Docker Compose in background
43+
uses: JarvusInnovations/background-action@v1.0.7
44+
with:
45+
run: docker compose -f docker/dependencies/docker.compose.yaml up -d &
46+
# we don't need to wait on anything, just need to start the daemon
47+
wait-on: /dev/null
48+
tail: true
49+
wait-for: 3s
50+
log-output-if: true
51+
52+
- name: Install dependencies
53+
run: pnpm install --frozen-lockfile
54+
55+
- name: Create .env.test.local file for apps/backend
56+
run: cp apps/backend/.env.development apps/backend/.env.test.local
57+
58+
- name: Create .env.test.local file for apps/dashboard
59+
run: cp apps/dashboard/.env.development apps/dashboard/.env.test.local
60+
61+
- name: Create .env.test.local file for apps/e2e
62+
run: cp apps/e2e/.env.development apps/e2e/.env.test.local
63+
64+
- name: Create .env.test.local file for docs
65+
run: cp docs/.env.development docs/.env.test.local
66+
67+
- name: Create .env.test.local file for examples/cjs-test
68+
run: cp examples/cjs-test/.env.development examples/cjs-test/.env.test.local
69+
70+
- name: Create .env.test.local file for examples/demo
71+
run: cp examples/demo/.env.development examples/demo/.env.test.local
72+
73+
- name: Create .env.test.local file for examples/docs-examples
74+
run: cp examples/docs-examples/.env.development examples/docs-examples/.env.test.local
75+
76+
- name: Create .env.test.local file for examples/e-commerce
77+
run: cp examples/e-commerce/.env.development examples/e-commerce/.env.test.local
78+
79+
- name: Create .env.test.local file for examples/middleware
80+
run: cp examples/middleware/.env.development examples/middleware/.env.test.local
81+
82+
- name: Create .env.test.local file for examples/partial-prerendering
83+
run: cp examples/partial-prerendering/.env.development examples/partial-prerendering/.env.test.local
84+
85+
- name: Create .env.test.local file for examples/supabase
86+
run: cp examples/supabase/.env.development examples/supabase/.env.test.local
87+
88+
- name: Create .env.test.local file for examples/convex
89+
run: cp examples/convex/.env.development examples/convex/.env.test.local
90+
91+
- name: Build
92+
run: pnpm build
93+
94+
- name: Wait on Postgres
95+
run: pnpm run wait-until-postgres-is-ready:pg_isready
96+
97+
- name: Wait on Inbucket
98+
run: npx wait-on tcp:localhost:8129
99+
100+
- name: Wait on Svix
101+
run: npx wait-on tcp:localhost:8113
102+
103+
- name: Initialize database
104+
run: pnpm run db:init
105+
106+
- name: Start stack-backend in background
107+
uses: JarvusInnovations/background-action@v1.0.7
108+
with:
109+
run: pnpm run start:backend --log-order=stream &
110+
wait-on: |
111+
http://localhost:8102
112+
tail: true
113+
wait-for: 30s
114+
log-output-if: true
115+
- name: Start stack-dashboard in background
116+
uses: JarvusInnovations/background-action@v1.0.7
117+
with:
118+
run: pnpm run start:dashboard --log-order=stream &
119+
wait-on: |
120+
http://localhost:8102
121+
tail: true
122+
wait-for: 30s
123+
log-output-if: true
124+
- name: Start mock-oauth-server in background
125+
uses: JarvusInnovations/background-action@v1.0.7
126+
with:
127+
run: pnpm run start:mock-oauth-server --log-order=stream &
128+
wait-on: |
129+
http://localhost:8102
130+
tail: true
131+
wait-for: 30s
132+
log-output-if: true
133+
134+
- name: Wait 10 seconds
135+
run: sleep 10
136+
137+
- name: Run tests
138+
run: pnpm test
139+
140+
- name: Run tests again, to make sure they are stable (attempt 1)
141+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
142+
run: pnpm test
143+
144+
- name: Run tests again, to make sure they are stable (attempt 2)
145+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
146+
run: pnpm test
147+
148+
- name: Verify data integrity
149+
run: pnpm run verify-data-integrity
150+
151+
- name: Print Docker Compose logs
152+
if: always()
153+
run: docker compose -f docker/dependencies/docker.compose.yaml logs

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ You should ALWAYS add new E2E tests when you change the API or SDK interface. Ge
3434
Stack Auth is a monorepo using Turbo for build orchestration. The main components are:
3535

3636
### Apps (`/apps`)
37-
- **backend** (`/apps/backend`): Next.js API backend running on port 8102
37+
- **backend** (`/apps/backend`): Next.js API backend running on port `<$STACK_PORT_PREFIX>02` (defaults to 8102)
3838
- Main API routes in `/apps/backend/src/app/api/latest`
3939
- Database models using Prisma
40-
- **dashboard** (`/apps/dashboard`): Admin dashboard on port 8101
41-
- **dev-launchpad**: Development portal on port 8100
40+
- **dashboard** (`/apps/dashboard`): Admin dashboard on port `<$STACK_PORT_PREFIX>01` (defaults to 8101)
41+
- **dev-launchpad**: Development portal on port `<$STACK_PORT_PREFIX>00` (defaults to 8100)
4242
- **e2e**: End-to-end tests
4343

4444
### Packages (`/packages`)

apps/backend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"typecheck": "tsc --noEmit",
88
"with-env": "dotenv -c development --",
99
"with-env:prod": "dotenv -c --",
10-
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --turbopack --port 8102\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
10+
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --turbopack --port ${STACK_PORT_PREFIX:-81}02\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
1111
"build": "pnpm run codegen && next build",
1212
"docker-build": "pnpm run codegen && next build --experimental-build-mode compile",
1313
"build-self-host-migration-script": "tsup --config scripts/db-migrations.tsup.config.ts",
1414
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
15-
"start": "next start --port 8102",
15+
"start": "next start --port ${STACK_PORT_PREFIX:-81}02",
1616
"codegen-prisma": "pnpm run prisma generate",
1717
"codegen-prisma:watch": "pnpm run prisma generate --watch",
1818
"codegen-route-info": "pnpm run with-env tsx scripts/generate-route-info.ts",
@@ -21,7 +21,7 @@
2121
"codegen:watch": "concurrently -n \"prisma,docs,route-info,migration-imports\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\" \"pnpm run codegen-route-info:watch\" \"pnpm run generate-migration-imports:watch\"",
2222
"psql-inner": "psql $(echo $STACK_DATABASE_CONNECTION_STRING | sed 's/\\?.*$//')",
2323
"psql": "pnpm run with-env pnpm run psql-inner",
24-
"prisma-studio": "pnpm run with-env prisma studio --port 8106 --browser none",
24+
"prisma-studio": "pnpm run with-env prisma studio --port ${STACK_PORT_PREFIX:-81}06 --browser none",
2525
"prisma": "pnpm run with-env prisma",
2626
"db:migration-gen": "pnpm run with-env tsx scripts/db-migrations.ts generate-migration-file",
2727
"db:reset": "pnpm run with-env tsx scripts/db-migrations.ts reset",

apps/backend/src/lib/freestyle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export class Freestyle {
1515
if (!["development", "test"].includes(getNodeEnvironment())) {
1616
throw new StackAssertionError("Mock Freestyle key used in production; please set the STACK_FREESTYLE_API_KEY environment variable.");
1717
}
18-
baseUrl = "http://localhost:8122";
18+
const prefix = getEnvVariable("STACK_PORT_PREFIX", "81");
19+
baseUrl = `http://localhost:${prefix}22`;
1920
}
2021
this.freestyle = new FreestyleSandboxes({
2122
apiKey,

apps/backend/src/lib/stripe.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { createStripeProxy, type StripeOverridesMap } from "./stripe-proxy";
99

1010
const stripeSecretKey = getEnvVariable("STACK_STRIPE_SECRET_KEY");
1111
const useStripeMock = stripeSecretKey === "sk_test_mockstripekey" && ["development", "test"].includes(getNodeEnvironment());
12+
const stackPortPrefix = getEnvVariable("STACK_PORT_PREFIX", "81");
1213
const stripeConfig: Stripe.StripeConfig = useStripeMock ? {
1314
protocol: "http",
1415
host: "localhost",
15-
port: 8123,
16+
port: Number(`${stackPortPrefix}23`),
1617
} : {};
1718

1819
export const getStackStripe = (overrides?: StripeOverridesMap) => {

apps/dashboard/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"typecheck": "tsc --noEmit",
88
"with-env": "dotenv -c development --",
99
"with-env:prod": "dotenv -c --",
10-
"dev": "next dev --turbopack --port 8101",
10+
"dev": "next dev --turbopack --port ${STACK_PORT_PREFIX:-81}01",
1111
"build": "next build",
1212
"docker-build": "next build --experimental-build-mode compile",
1313
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
14-
"start": "next start --port 8101",
14+
"start": "next start --port ${STACK_PORT_PREFIX:-81}01",
1515
"psql": "pnpm run with-env bash -c 'psql $STACK_DATABASE_CONNECTION_STRING'",
1616
"lint": "next lint"
1717
},

apps/dev-launchpad/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public/env-config.js

apps/dev-launchpad/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.8.43",
44
"private": true,
55
"scripts": {
6-
"dev": "serve -p 8100 -s public",
6+
"dev": "node scripts/write-env-config.js && serve -p ${STACK_PORT_PREFIX:-81}00 -s public",
77
"clean": "rimraf node_modules"
88
},
99
"dependencies": {

0 commit comments

Comments
 (0)