Skip to content

Commit

Permalink
add test env vars and ports
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexErrant committed Nov 11, 2024
1 parent 1acd4cf commit a7b79a8
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 81 deletions.
6 changes: 3 additions & 3 deletions app-playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { defineConfig, devices } from '@playwright/test'

const isCI = Boolean(process.env.CI)
const baseURL = isCI
? 'http://localhost:3023'
: 'https://app.pentive.localhost:3023'
? 'http://localhost:3043'
: 'https://app.pentive.localhost:3043'

/**
* See https://playwright.dev/docs/test-configuration.
Expand Down Expand Up @@ -77,7 +77,7 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm run preview --port 3023',
command: 'pnpm previewTest',
cwd: '../app',
url: baseURL,
ignoreHTTPSErrors: true,
Expand Down
8 changes: 8 additions & 0 deletions app/.example.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
VITE_CWA_URL=$VITE_TEST_CWA_URL
VITE_AUGC_URL=$VITE_TEST_AUGC_URL
VITE_APP_UGC_ORIGIN=$VITE_TEST_APP_UGC_ORIGIN
VITE_PEER_HOST=$VITE_DEVELOPMENT_PEER_HOST
VITE_PEER_PORT=$VITE_DEVELOPMENT_PEER_PORT
VITE_HUB_ORIGIN=$VITE_TEST_HUB_ORIGIN
VITE_AG_GRID_LICENSE=$VITE_DEVELOPMENT_AG_GRID_LICENSE
VITE_PEER_SYNC_PUBLIC_KEY="$developmentPeerSyncPublicKey"
2 changes: 2 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
node_modules
dev-dist
dist
distTest
lib
/test-results/
/playwright-report/
/playwright/.cache/
.cert
env.sh
.env.test
.env.development
.env.production
src/assets/sql-wasm.wasm
Expand Down
6 changes: 4 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"dev": "vite",
"deploy": "./deploy.sh",
"build": "vite build",
"buildDev": "vite build --mode development # Run before `preview`",
"buildDev": "vite build --mode development # Run before `preview`",
"buildTest": "vite build --mode test --outDir distTest # Run before testing",
"build-watch": "vite build --watch",
"preview": "vite preview --mode development",
"preview": "vite preview --mode development # This does NOT necessarily run with development env vars; it exists to enable HTTPS as per `vite.config.ts`",
"previewTest": "vite preview --mode test --outDir distTest --port 3043",
"postinstall": "./postinstall.sh",
"tsc-build": "tsc",
"eslint": "eslint . --ignore-path .gitignore --max-warnings 0",
Expand Down
2 changes: 1 addition & 1 deletion app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig(({ mode }: UserConfig) => {
const keyPath = './.cert/key.pem'
const certPath = './.cert/cert.pem'
let https
if (mode === 'development' && !isCI) {
if (mode !== 'production' && !isCI) {
https = {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
Expand Down
10 changes: 10 additions & 0 deletions design-decisions/example.pentive.secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export developmentAlphaKey=
export productionAlphaKey=
export cloudflareAccountId=
export developmentTursoDbUrl=http://127.0.0.1:3011
export testTursoDbUrl=http://127.0.0.1:3041
export developmentTursoAuthToken='optional if running locally'
export productionTursoDbUrl=
export productionTursoAuthToken=
Expand Down Expand Up @@ -58,6 +59,8 @@ baz

export developmentAppOrigin=https://app.pentive.localhost:3013
export developmentHubOrigin=https://pentive.localhost:3014
export testAppOrigin=https://app.pentive.localhost:3043
export testHubOrigin=https://pentive.localhost:3044

# If you add any `VITE_PRODUCTION_*` or edit the below, also update `cicd.yml`
export productionAppOrigin=https://app.pentive.com
Expand All @@ -67,18 +70,25 @@ export VITE_PRODUCTION_AG_GRID_LICENSE=
export VITE_DEVELOPMENT_HUB_DOMAIN=pentive.localhost
export VITE_PRODUCTION_HUB_DOMAIN=hub.yourusernamehere.workers.dev
export VITE_DEVELOPMENT_HUB_ORIGIN=https://pentive.localhost:3014
export VITE_TEST_HUB_ORIGIN=https://pentive.localhost:3044
export VITE_PRODUCTION_HUB_ORIGIN=https://pentive.com
export VITE_DEVELOPMENT_CWA_URL=https://cwa.pentive.localhost:3017/
export VITE_TEST_CWA_URL=https://cwa.pentive.localhost:3047/
export VITE_PRODUCTION_CWA_URL=https://cwa.yourusernamehere.workers.dev/
export VITE_DEVELOPMENT_AUGC_URL=https://user-generated-content-pentive.localhost:3019/
export VITE_TEST_AUGC_URL=https://user-generated-content-pentive.localhost:3049/
export VITE_PRODUCTION_AUGC_URL=https://user-generated-content-pentive.yourusernamehere.workers.dev/
export VITE_DEVELOPMENT_APP_ORIGIN=https://app.pentive.localhost:3013
export VITE_TEST_APP_ORIGIN=https://app.pentive.localhost:3043
export VITE_PRODUCTION_APP_ORIGIN=https://app.yourusernamehere.workers.dev
export VITE_DEVELOPMENT_HUB_UGC_ORIGIN=https://hub-user-generated-content-pentive.localhost:3016
export VITE_TEST_HUB_UGC_ORIGIN=https://hub-user-generated-content-pentive.localhost:3046
export VITE_PRODUCTION_HUB_UGC_ORIGIN=https://hub-user-generated-content.yourusernamehere.workers.dev
export VITE_DEVELOPMENT_APP_UGC_ORIGIN=https://app-user-generated-content-pentive.localhost:3015
export VITE_TEST_APP_UGC_ORIGIN=https://app-user-generated-content-pentive.localhost:3045
export VITE_PRODUCTION_APP_UGC_ORIGIN=https://app-user-generated-content.yourusernamehere.workers.dev
export VITE_DEVELOPMENT_PEER_HOST=peer.pentive.localhost
export VITE_DEVELOPMENT_PEER_PORT="3018"
export VITE_TEST_PEER_PORT="3048"
export VITE_PRODUCTION_PEER_HOST="0.peerjs.com"
export VITE_PRODUCTION_PEER_PORT="443"
1 change: 1 addition & 0 deletions mkenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ envsubst < ./lrpc/.example.env > ./lrpc/.env
envsubst < ./app-ugc/example.env.sh > ./app-ugc/env.sh
envsubst < ./hub-ugc/example.env.sh > ./hub-ugc/env.sh
envsubst < ./app/example.env.sh > ./app/env.sh
envsubst < ./app/.example.env.test > ./app/.env.test
envsubst < ./app/.example.env.development > ./app/.env.development
envsubst < ./app/.example.env.production > ./app/.env.production
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"wrangler": "^3.81.0"
},
"scripts": {
"kill": "kill-port 3011 3012 3013 3014 3015 3016 3017 3018 3019",
"kill": "kill-port 3011 3012 3013 3014 3015 3016 3017 3018 3019 3041 3042 3043 3044 3045 3046 3047 3048 3049",
"//": "ugc and dev are distinct because you may frequently wish to restart `dev`, whereas `ugc` rarely changes",
"ugc": "concurrently --kill-others -p \"[{name}]\" -n \"app-ugc,hub-ugc\" -c \"bgBlue.bold,bgMagenta.bold\" \"pnpm --filter app-ugc build --mode development && pnpm --filter app-ugc serve\" \"pnpm --filter hub-ugc build --mode development && pnpm --filter hub-ugc serve\"",
"dev": "concurrently --kill-others -p \"[{name}]\" -n \"app,hub,cwa,peer,api-ugc\" -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold,bgWhiteBright.bold,bgCyan.bold\" \"pnpm --filter app dev\" \"pnpm --filter hub dev\" \"pnpm --filter cwa dev\" \"pnpm --filter peer dev\" \"pnpm --filter api-ugc dev\"",
Expand Down
160 changes: 86 additions & 74 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,88 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"tsc-build": {
"dependsOn": [
// Don't use "transit nodes"! https://turbo.build/repo/docs/core-concepts/package-and-task-graph#transit-nodes
// tsc-build, build, eslint, and check all require their parents' tsc-build runs to succeed.
"^tsc-build"
],
"outputs": [
"lib/**"
]
},
"eslint": {
"dependsOn": [
// "By using typed linting in your config, you incur the performance penalty of asking TypeScript to do a build of your project before ESLint can do its linting" https://typescript-eslint.io/getting-started/typed-linting#how-is-performance
"tsc-build"
]
},
"hub#build": {
"dependsOn": [
// I don't think hub's eslint and build can run concurrently. Without this we get an error in Github Actions like
// Error: ENOENT: no such file or directory, open '/home/runner/work/Pentive/Pentive/hub/app.config.timestamp_1725915755421.js'
"hub#eslint"
],
"outputs": [
"dist/**",
".vinxi/**"
]
},
"check": {
"dependsOn": [
"tsc-build"
]
},
"test": {
"cache": false,
"persistent": true
},
"test:run": {},
"shared-dom#test:run": { // grep AD3A801F-81D4-4C83-80A3-94ED10F05608
"dependsOn": [
"shared-dom#tsc-build"
]
},
"app-playwright#test:run": {
"dependsOn": [
"app#build"
]
},
"deploy": {
"dependsOn": [
"build"
],
"env": [
"CLOUDFLARE_ACCOUNT_ID",
"CLOUDFLARE_API_TOKEN"
]
},
"build": {
"dependsOn": [
"tsc-build"
],
"outputs": [
"dist/**"
],
"inputs": [
"$TURBO_DEFAULT$",
".env.development",
".env.production",
".env.production.local",
".env"
]
}
}
"$schema": "https://turbo.build/schema.json",
"tasks": {
"tsc-build": {
"dependsOn": [
// Don't use "transit nodes"! https://turbo.build/repo/docs/core-concepts/package-and-task-graph#transit-nodes
// tsc-build, build, eslint, and check all require their parents' tsc-build runs to succeed.
"^tsc-build"
],
"outputs": [
"lib/**"
]
},
"eslint": {
"dependsOn": [
// "By using typed linting in your config, you incur the performance penalty of asking TypeScript to do a build of your project before ESLint can do its linting" https://typescript-eslint.io/getting-started/typed-linting#how-is-performance
"tsc-build"
]
},
"hub#build": {
"dependsOn": [
// I don't think hub's eslint and build can run concurrently. Without this we get an error in Github Actions like
// Error: ENOENT: no such file or directory, open '/home/runner/work/Pentive/Pentive/hub/app.config.timestamp_1725915755421.js'
"hub#eslint"
],
"outputs": [
"dist/**",
".vinxi/**"
]
},
"check": {
"dependsOn": [
"tsc-build"
]
},
"test": {
"cache": false,
"persistent": true
},
"test:run": {},
"shared-dom#test:run": { // grep AD3A801F-81D4-4C83-80A3-94ED10F05608
"dependsOn": [
"shared-dom#tsc-build"
]
},
"app-playwright#test:run": {
"dependsOn": [
"app#buildTest"
]
},
"deploy": {
"dependsOn": [
"build"
],
"env": [
"CLOUDFLARE_ACCOUNT_ID",
"CLOUDFLARE_API_TOKEN"
]
},
"build": {
"dependsOn": [
"tsc-build"
],
"outputs": [
"dist/**"
],
"inputs": [
"$TURBO_DEFAULT$",
".env.development",
".env.production",
".env.production.local",
".env"
]
},
"buildTest": {
"dependsOn": [
"tsc-build"
],
"outputs": [
"distTest/**"
],
"inputs": [
"$TURBO_DEFAULT$",
".env.test"
]
}
}
}

0 comments on commit a7b79a8

Please sign in to comment.