Skip to content

test: make Nx own test environments - #675

Merged
jumski merged 2 commits into
mainfrom
673-nx-test-lifecycle
Sep 9, 2026
Merged

test: make Nx own test environments#675
jumski merged 2 commits into
mainfrom
673-nx-test-lifecycle

Conversation

@jumski

@jumski jumski commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make Nx own fresh test-environment setup, focused slow tests, and interruption recovery
  • serialize each shared Supabase stack and integration database across worktrees
  • validate focused selectors before test execution through a direct-argv Nx executor
  • fingerprint live database and stack state, including post-reset service readiness
  • own E2E server processes and exact runtime containers through readiness, tests, and cleanup

Why

Direct test-runner commands bypassed Nx setup and caching, while interrupted runs could leave stale processes or shared infrastructure. The prior lifecycle also allowed stale migrations, shell-expanded selectors, false readiness, and cross-worktree resource races.

The updated lifecycle keeps setup, recovery, cache validity, and live-resource ownership inside Nx. Full E2E suites remain intact because their workers and database state are shared.

Local checks

Passed on commit 3d5d5f01:

  • affected lint, build, unit, type, and export checks
  • Core pgTAP and lifecycle regression suite
  • edge-worker E2E and portable-runtime E2E: 12 tests each
  • client E2E: 12 files, 47 tests
  • CLI E2E install checks and the full pre-push hook

Local edge-worker integration did not complete successfully. The full target timed out, and its focused reproduction failed one unchanged performanceMapFlow.test.ts 15-second completion bound while two tests passed. The change does not touch worker, schema, migration, integration-helper, or performance-test behavior. CI's isolated integration job will add evidence about whether this is local load or a reproducible regression.

Closes #673

Route pgflow test startup, cleanup, focused slow checks, and interruption recovery through Nx so deliveries reuse one owned environment without bypassing setup dependencies.

Add endpoint-specific E2E readiness, integration database config guards, pidfd-safe cleanup, and complete cache inputs. Keep E2E at full-suite scope because its workers and database state are shared.
@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3d5d5f0

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

jumski commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

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

@nx-cloud

nx-cloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3d5d5f0

Command Status Duration Result
nx run-many -t build --projects=dsl,core,cli ✅ Succeeded 5s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-09 09:46:26 UTC

Serialize shared Supabase and integration resources through Nx-owned locks, validate focused test selectors before execution, and make E2E startup and cleanup track live process and container state.

The first lifecycle pass could reuse stale database state, trust shell-expanded selectors, and certify or leak failed E2E servers. This correction records applied fingerprints only after readiness, declares actual cache inputs, and adds deterministic lifecycle regression checks.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Preview Deployment: Website

Deployment successful!

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

📝 Details:

  • Branch: 673-nx-test-lifecycle
  • Commit: a5a9252cbdfacf2692664d6eb0bb5abee63e30ba
  • View Logs

_Last updated: _

@jumski jumski left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i feel like this is very complicated setup - maybe this complexity is required, maybe its overneigneered? we need to understand exacly. need to invoke ponytail for help

scripts/ensure-migrations.sh: wow why is it needed? why its so complicated?

scripts/functions-server.sh: why is it needed and why its so complex? its concerning tbh

scripts/require-test-file.sh: why is it needed?

scripts/run-e2e.sh: why is it needed?

scripts/test-lifecycle.sh: why is it needed?

scripts/with-integration-lock.sh: why is it needed?

tools/nx-executors/focused-file.cjs: how this works in simple terms?

Comment thread scripts/test-env-fresh.sh
declare -a stack_lock_fds=()

# Nx-owned lifecycle targets this cleanup may stop. The exact workspace,
# project, and target come from Nx task environment variables, not argv.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this looks like something that will be hard to maintain - would it be possible to use some kind of tag system built into nx and mark the targets via this tag system in each project.json then retrieve all tagged targets here? would it be a good idea? ponytail?

Comment thread TESTING.md
pnpm nx test-env:fresh edge-worker
```

The target takes the environment lock first. It then previews and locks every pgflow stack resource, the integration database, and the core upgrade fixture before it stops or removes anything. It stops only Nx-owned lifecycle processes from this workspace. If another worktree still holds a resource lock, recovery stops before it changes that resource. Locks live in the repository Git common directory, so sibling worktrees and sandboxes share them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

damn... is it done so only one worktree can run at the given time? this could be easily solved via supabase/config.toml customizable env-based port specifiers, so each new worktree gets a new .env file with specified ports for all services, guaranteed to not conflict with others... right?

jumski commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Sep 9, 12:11 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 9, 12:11 PM UTC: @jumski merged this pull request with Graphite.

@jumski
jumski merged commit 4c09f51 into main Sep 9, 2026
17 checks passed
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: 4c09f51bdd4acf9d8465273f790ba20c378cb85f
  • View Logs

Deployed at: 2026-09-09T14:11:38+02:00

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.

test: make Nx own fresh environments and focused slow checks

1 participant