@@ -171,7 +171,6 @@ jobs:
171171 cli,
172172 common,
173173 packages/agent-runtime,
174- packages/internal,
175174 sdk,
176175 web,
177176 ]
@@ -318,4 +317,92 @@ jobs:
318317 echo "No integration tests found in packages/billing"
319318 fi
320319
320+ # Internal package integration tests (requires PostgreSQL for advisory lock tests)
321+ # DATABASE_URL is set at job level to override any secrets injection
322+ test-internal-integration :
323+ needs : [build-and-check]
324+ name : test-integration-packages/internal
325+ runs-on : ubuntu-latest
326+ env :
327+ DATABASE_URL : postgresql://postgres:postgres@127.0.0.1:5432/testdb
328+ services :
329+ postgres :
330+ image : postgres:16-alpine
331+ env :
332+ POSTGRES_USER : postgres
333+ POSTGRES_PASSWORD : postgres
334+ POSTGRES_DB : testdb
335+ options : >-
336+ --health-cmd pg_isready
337+ --health-interval 10s
338+ --health-timeout 5s
339+ --health-retries 5
340+ ports :
341+ - 5432:5432
342+ steps :
343+ - name : Checkout repository
344+ uses : actions/checkout@v4
345+
346+ - name : Set up Bun
347+ uses : oven-sh/setup-bun@v2
348+ with :
349+ bun-version : ' 1.3.5'
350+
351+ - name : Cache dependencies
352+ uses : actions/cache@v4
353+ with :
354+ path : |
355+ node_modules
356+ */node_modules
357+ packages/*/node_modules
358+ key : ${{ runner.os }}-deps-${{ hashFiles('**/bun.lock*') }}
359+ restore-keys : |
360+ ${{ runner.os }}-deps-
361+
362+ - name : Install dependencies
363+ run : bun install --frozen-lockfile
364+
365+ - name : Set environment variables
366+ env :
367+ SECRETS_CONTEXT : ${{ toJSON(secrets) }}
368+ run : |
369+ VAR_NAMES=$(bun scripts/generate-ci-env.ts)
370+ echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
371+ to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
372+ ' >> $GITHUB_ENV
373+ echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV
374+ echo "NEXT_PUBLIC_CB_ENVIRONMENT=test" >> $GITHUB_ENV
375+ echo "NEXT_PUBLIC_INFISICAL_UP=true" >> $GITHUB_ENV
376+ echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
377+
378+ - name : Build SDK before integration tests
379+ run : cd sdk && bun run build
380+
381+ # Override any DATABASE_URL injected from secrets with our test container URL
382+ - name : Override DATABASE_URL for test container
383+ run : echo "DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432/testdb" >> $GITHUB_ENV
384+
385+ - name : Setup database schema
386+ uses : nick-fields/retry@v3
387+ env :
388+ DATABASE_URL : postgresql://postgres:postgres@127.0.0.1:5432/testdb
389+ with :
390+ timeout_minutes : 2
391+ max_attempts : 3
392+ command : cd packages/internal && bun run db:migrate
393+
394+ - name : Run internal integration tests
395+ uses : nick-fields/retry@v3
396+ with :
397+ timeout_minutes : 15
398+ max_attempts : 3
399+ command : |
400+ cd packages/internal
401+ TEST_FILES=$(find src -name '*.integration.test.ts' 2>/dev/null | sort)
402+ if [ -n "$TEST_FILES" ]; then
403+ echo "$TEST_FILES" | xargs -I {} bun test --timeout=60000 {}
404+ else
405+ echo "No integration tests found in packages/internal"
406+ fi
407+
321408 # E2E tests for web intentionally omitted for now.
0 commit comments