Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Nov 4, 2025

Split test targets into two categories:

  • test: Fast tests without infrastructure (vitest, types)
  • test:live: Tests requiring live infrastructure (pgtap, integration)

Enable Nx Cloud caching for verification tasks:

  • Remove local: true from verify-* targets
  • Add db:verify meta-target for verification pipeline
  • Verification results now cached across CI jobs

Restructure CI workflow:

  • Job 1: db-verification (runs once, caches to Nx Cloud)
  • Job 2: fast-tests (restores cache, runs all packages in parallel)
  • Job 3-5: *-live-tests (separate jobs per package infrastructure)
  • Job 6: edge-worker-e2e (unchanged)

Benefits:

  • verify-migrations runs once instead of multiple times
  • Fast tests complete in ~2-3 min with full parallelization
  • Simple commands: nx affected -t test (fast), nx affected -t test:live (infra)
  • Nx handles dependency resolution and caching automatically

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

⚠️ No Changeset found

Latest commit: ec56e39

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

jumski commented Nov 4, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge:queue - adds this PR to the back of the merge queue
  • hotfix:queue - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nx-cloud
Copy link

nx-cloud bot commented Nov 4, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit ec56e39

Command Status Duration Result
nx run edge-worker:test:live ❌ Failed 4m 16s View ↗
nx run cli:test:live ❌ Failed 3s View ↗
nx run client:test:live ✅ Succeeded 2m 44s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 22s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 1m 11s View ↗
nx run core:test:live ✅ Succeeded 1s View ↗
nx run core:db:verify ✅ Succeeded 3m 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-08 13:18:20 UTC

Comment on lines 170 to 172
edge-worker-e2e:
runs-on: ubuntu-latest
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The edge-worker-e2e job should include a dependency on the db-verification job to maintain consistency with the other test jobs. Adding needs: [db-verification] would ensure that database verification completes successfully before running the E2E tests, preventing potential issues from unverified database changes.

Suggested change
edge-worker-e2e:
runs-on: ubuntu-latest
env:
edge-worker-e2e:
runs-on: ubuntu-latest
needs: [db-verification]
env:

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the ci-optimize-test-separation branch from b3f3430 to 67d3641 Compare November 4, 2025 15:29
@jumski jumski force-pushed the ci-optimize-test-separation branch from 67d3641 to 14e5260 Compare November 4, 2025 18:30
@jumski jumski force-pushed the ci-optimize-test-separation branch from 14e5260 to 0a2a37d Compare November 4, 2025 20:08
Comment on lines 86 to 136
- name: Run core live tests
run: pnpm nx run core:test:live
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core-live-tests job unconditionally runs pnpm nx run core:test:live without checking if core is affected by the changes. This is inconsistent with client-live-tests (line 119-121) and edge-worker-live-tests (line 153-155), which both check if they are affected before running.

This means core's live tests will run on every CI run, even when core is not affected by any changes, wasting CI resources and time.

Fix: Add an affected check similar to the other packages:

- name: Check if core is affected
  id: check-affected
  run: |
    if pnpm nx show projects --affected --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^core$"; then
      echo "affected=true" >> $GITHUB_OUTPUT
      echo "Core is affected by changes"
    else
      echo "affected=false" >> $GITHUB_OUTPUT
      echo "Core is not affected by changes - skipping"
    fi

- name: Run core live tests
  if: steps.check-affected.outputs.affected == 'true'
  run: pnpm nx run core:test:live
Suggested change
- name: Run core live tests
run: pnpm nx run core:test:live
- name: Check if core is affected
id: check-affected
run: |
if pnpm nx show projects --affected --base="$NX_BASE" --head="$NX_HEAD" | grep -q "^core$"; then
echo "affected=true" >> $GITHUB_OUTPUT
echo "Core is affected by changes"
else
echo "affected=false" >> $GITHUB_OUTPUT
echo "Core is not affected by changes - skipping"
fi
- name: Run core live tests
if: steps.check-affected.outputs.affected == 'true'
run: pnpm nx run core:test:live

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

🔍 Preview Deployment: Website

Deployment successful!

🔗 Preview URL: https://pr-315.pgflow.pages.dev

📝 Details:

  • Branch: ci-optimize-test-separation
  • Commit: 1c3e5d403bd0d02e7db0e6d0d79c6f2db646916c
  • View Logs

_Last updated: _

@jumski jumski force-pushed the ci-optimize-test-separation branch from 0a2a37d to cc056b9 Compare November 5, 2025 13:12
@jumski jumski force-pushed the ci-optimize-test-separation branch 2 times, most recently from dd77727 to c42ad3d Compare November 5, 2025 16:51
# ─────────────────────────────────────── 2. EDGE-WORKER E2E ──────────────────────────────────────
edge-worker-e2e:
# ─────────────────────────────────────── 3. CLI LIVE TESTS ──────────────────────────────────────
cli-live-tests:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider running live tests sequentially instead of in parallel by making cli-live-tests depend on db-verification, core-live-tests depend on cli-live-tests, client-live-tests depend on core-live-tests, and edge-worker-live-tests depend on client-live-tests. This would prevent resource conflicts at the cost of longer CI run times.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

- name: Run edge-worker live tests
if: steps.check-affected.outputs.affected == 'true'
run: pnpm nx affected -t test:e2e --parallel --base="$NX_BASE" --head="$NX_HEAD"
run: pnpm nx run edge-worker:test:live
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a timeout to prevent the edge-worker live tests from being terminated prematurely. Change to: run: pnpm nx run edge-worker:test:live --timeout=10m

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +106 to +107
core-live-tests:
needs: [db-verification]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core-live-tests job should depend on fast-tests instead of db-verification to ensure it runs after fast-tests completes, creating a sequential chain of jobs.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +18 to +26
cd "$SUPABASE_DIR"

if pnpm supabase status &>/dev/null; then
echo "✓ Supabase already running in $SUPABASE_DIR"
exit 0
fi

echo "Starting Supabase in $SUPABASE_DIR..."
pnpm supabase start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a locking mechanism to prevent multiple processes from starting Supabase simultaneously. This could be implemented using flock or a simple file-based lock to ensure only one process can start Supabase at a time.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the ci-optimize-test-separation branch from c42ad3d to 3a5298f Compare November 5, 2025 19:10
# Initialize a fresh Supabase project
echo "🏗️ Creating new Supabase project"
npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings
supabase init --force --with-vscode-settings --with-intellij-settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is missing the '--force' flag which is causing the test to fail with an EEXIST error when trying to create a directory that already exists. The command should be 'supabase init --force --with-vscode-settings --with-intellij-settings' to match the other similar scripts in the codebase.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines 192 to 203
"test:e2e": {
"executor": "nx:run-commands",
"dependsOn": ["supabase:reset", "serve:functions:e2e"],
"dependsOn": ["supabase:reset", "sync-e2e-deps"],
"local": true,
"inputs": ["default", "^production"],
"options": {
"cwd": "pkgs/edge-worker",
"commands": [
"../../scripts/ensure-supabase.sh .",
"deno test --config deno.test.json --allow-all --env=supabase/functions/.env tests/e2e/"
],
"parallel": false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add retry mechanism for the supabase db reset command to handle potential interruptions. The current implementation fails with SIGINT (code 130) which suggests the command is being interrupted, possibly due to race conditions with other jobs.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +1 to +26
#!/usr/bin/env bash
set -e

# Usage: ensure-supabase.sh <path-to-supabase-parent-dir>
if [ -z "$1" ]; then
echo "ERROR: Supabase directory path required"
echo "Usage: ensure-supabase.sh <path-to-supabase-parent-dir>"
exit 1
fi

SUPABASE_DIR="$1"

if [ ! -d "$SUPABASE_DIR/supabase" ]; then
echo "ERROR: No supabase/ directory found in $SUPABASE_DIR"
exit 1
fi

cd "$SUPABASE_DIR"

if pnpm supabase status &>/dev/null; then
echo "✓ Supabase already running in $SUPABASE_DIR"
exit 0
fi

echo "Starting Supabase in $SUPABASE_DIR..."
pnpm supabase start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhance script to handle potential race conditions by adding retries and better error handling. The script should be more resilient when multiple CI jobs call it simultaneously.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the ci-optimize-test-separation branch from 3a5298f to f0eb6fa Compare November 6, 2025 08:34
Comment on lines +29 to +30
- name: Install sqruff
uses: quarylabs/install-sqruff-cli-action@main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is failing because the 'quarylabs/install-sqruff-cli-action@main' action cannot successfully download and install the sqruff-linux-x86_64-musl.tar.gz file. Either pin this action to a specific stable version (e.g., 'quarylabs/install-sqruff-cli-action@v1.0.0') instead of using the potentially unstable '@main' reference, or temporarily remove this step until the upstream action is fixed.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines 107 to 111
"commands": [
"../../scripts/ensure-supabase.sh .",
"mkdir -p supabase/migrations/",
"rm -f supabase/migrations/*.sql",
"cp ../core/supabase/migrations/*.sql supabase/migrations/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'supabase db reset' command is likely hanging or timing out. We should add a timeout and potentially retry logic. Replace the last command with 'timeout 60s supabase db reset || (echo "Retrying database reset..." && timeout 60s supabase db reset)' to give the command a 60-second timeout and one retry attempt if it fails.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the ci-optimize-test-separation branch from f0eb6fa to dc614a9 Compare November 6, 2025 13:00
Comment on lines +20 to +26
if pnpm supabase status &>/dev/null; then
echo "✓ Supabase already running in $SUPABASE_DIR"
exit 0
fi

echo "Starting Supabase in $SUPABASE_DIR..."
pnpm supabase start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't handle timeouts or potential failures when starting Supabase. It should include a timeout mechanism and retry logic to prevent hanging indefinitely, which is likely causing the SIGINT termination in CI.

Spotted by Graphite Agent (based on CI logs)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jumski jumski force-pushed the ci-optimize-test-separation branch from dc614a9 to 5ba8b03 Compare November 6, 2025 17:11
Split test targets into two categories:
- test: Fast tests without infrastructure (vitest, types)
- test:live: Tests requiring live infrastructure (pgtap, integration)

Enable Nx Cloud caching for verification tasks:
- Remove local: true from verify-* targets
- Add db:verify meta-target for verification pipeline
- Verification results now cached across CI jobs

Restructure CI workflow:
- Job 1: db-verification (runs once, caches to Nx Cloud)
- Job 2: fast-tests (restores cache, runs all packages in parallel)
- Job 3-5: *-live-tests (separate jobs per package infrastructure)
- Job 6: edge-worker-e2e (unchanged)

Benefits:
- verify-migrations runs once instead of multiple times
- Fast tests complete in ~2-3 min with full parallelization
- Simple commands: nx affected -t test (fast), nx affected -t test:live (infra)
- Nx handles dependency resolution and caching automatically

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jumski jumski force-pushed the ci-optimize-test-separation branch from 5ba8b03 to ec56e39 Compare November 8, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants