Skip to content

Commit 03a8abb

Browse files
Harxhitclaude
andcommitted
fix(ci): make api-tests workflow run green end-to-end
- run orchestration from apps/backend so prisma/tsx resolve schema and src paths (npm exec ran from repo root where ./prisma/schema.prisma is absent) - use `prisma db push` instead of `migrate deploy`: CI uses an ephemeral DB with no migration history, and committed migrations lag schema.prisma - materialise a repo-root .env from CI env vars, since src/env.ts throws when dotenv finds no .env file (CI passes config via real env vars) - ignore postman/** and JS-family files in eslint config so ci.yml's "lint every changed file" step doesn't crash type-checked linting on push.mjs / eslint.config.js (source is TypeScript only) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e219181 commit 03a8abb

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

.github/scripts/run-api-tests.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PORT="${PORT:-3000}"
1818
BASE_URL="http://localhost:${PORT}"
1919
HEALTH_RETRIES="${HEALTH_RETRIES:-30}"
2020
HEALTH_INTERVAL="${HEALTH_INTERVAL:-2}"
21-
COLLECTION="apps/backend/postman/DevCard.postman_collection.json"
21+
COLLECTION="postman/DevCard.postman_collection.json"
2222

2323
SERVER_PID=""
2424

@@ -31,13 +31,35 @@ cleanup() {
3131
}
3232
trap cleanup EXIT
3333

34-
echo "::group::Apply migrations and seed"
35-
npm --prefix apps/backend exec prisma migrate deploy
36-
npm --prefix apps/backend run db:seed
34+
# Prisma and tsx resolve paths relative to the working directory, so run
35+
# everything from the backend package rather than the repo root.
36+
cd apps/backend
37+
38+
# CI runs against an ephemeral database with no migration history, and the
39+
# committed migrations can lag schema.prisma. `db push` syncs the database
40+
# straight from the schema — the right tool for a throwaway test database.
41+
echo "::group::Sync database schema and seed"
42+
npx prisma db push --skip-generate
43+
npm run db:seed
44+
echo "::endgroup::"
45+
46+
# src/env.ts loads a repo-root .env via dotenv and throws if the file is
47+
# absent. CI supplies config through real env vars, so materialise a .env
48+
# from them (dotenv does not override values already set in the environment).
49+
echo "::group::Write .env for dotenv"
50+
cat > ../../.env <<EOF
51+
DATABASE_URL=${DATABASE_URL:-}
52+
REDIS_URL=${REDIS_URL:-}
53+
JWT_SECRET=${JWT_SECRET:-}
54+
ENCRYPTION_KEY=${ENCRYPTION_KEY:-}
55+
NODE_ENV=${NODE_ENV:-development}
56+
PORT=${PORT:-3000}
57+
PUBLIC_APP_URL=${PUBLIC_APP_URL:-}
58+
EOF
3759
echo "::endgroup::"
3860

3961
echo "::group::Start API server"
40-
npm --prefix apps/backend exec tsx src/server.ts &
62+
npx tsx src/server.ts &
4163
SERVER_PID=$!
4264
echo "Server started (pid ${SERVER_PID})"
4365
echo "::endgroup::"

apps/backend/eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export default tseslint.config(
1616
'coverage/**',
1717
'prisma/migrations/**',
1818
'**/*.d.ts',
19+
'postman/**',
20+
// Source is TypeScript only; JS-family files are config/scripts that the
21+
// type-checked ruleset cannot parse (no tsconfig project). Skip them so
22+
// CI linting of changed files does not crash on e.g. push.mjs or this config.
23+
'**/*.mjs',
24+
'**/*.cjs',
25+
'**/*.js',
1926
],
2027
},
2128

0 commit comments

Comments
 (0)