Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint:ci": "biome ci",
"test": "vitest --silent passed-only",
"test:integration": "vitest --config vitest.integration.config.ts --silent passed-only",
"test:integration:ci": "pnpm -F @ensnode/integration-test-env start",
"test:integration:ci": "pnpm -F @ensnode/integration-test-env start:ci",
"audit:osv": "osv-scanner scan source --lockfile pnpm-lock.yaml",
"typecheck": "pnpm -r --parallel --aggregate-output typecheck",
"changeset": "changeset",
Expand Down
33 changes: 25 additions & 8 deletions packages/integration-test-env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,41 @@ via the `docker/docker-compose.orchestrator.yml` file.

## How It Works

The orchestrator runs a 6-phase pipeline:
The lifecycle runs a 6-phase bring-up:

1. **Postgres + Devnet** — started in parallel via testcontainers
2. **ENSRainbow database** — downloads pre-built LevelDB, extracts, starts ENSRainbow from source
3. **ENSIndexer** — starts from source, waits for health
4. **Indexing** — polls until omnichain status reaches "Following" or "Completed"
5. **ENSApi** — starts from source, waits for health
6. **Integration tests** — runs `pnpm test:integration`
2. **Seed devnet** — primary names and resolver records
3. **ENSRainbow database** — downloads pre-built LevelDB, extracts, starts ENSRainbow from source
4. **ENSIndexer** — starts from source, waits for health
5. **Indexing** — polls until omnichain status reaches "Following" or "Completed"
6. **ENSApi** — starts from source, waits for health

Two entrypoints share that bring-up:

- `pnpm start` — bring up the stack and wait for Ctrl+C. Use this when you want to point `pnpm test:integration` (or anything else) at a long-lived stack.
- `pnpm start:ci` — bring up the stack, run `pnpm test:integration` at the monorepo root, then tear everything down (CI flow).

## Usage

### Automated
### Bring up the stack (manual)

```sh
pnpm start
```

Works both in CI and locally — just make sure the required ports are available (8545, 8000, 3223, 42069, 4334).
Brings up the full stack and blocks until Ctrl+C. The required ports must be available (8545, 8000, 3223, 42069, 4334). Once it's up, run integration tests from another terminal:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Brings up the full stack and blocks until Ctrl+C. The required ports must be available (8545, 8000, 3223, 42069, 4334). Once it's up, run integration tests from another terminal:
Brings up the full stack and blocks until Ctrl+C. The required ports must be available (8545, 3223, 42069, 4334, 5433). Once it's up, run integration tests from another terminal:

README lists incorrect ports (includes non-existent 8000, omits PostgreSQL port 5433)

Fix on Vercel


```sh
pnpm test:integration
```
Comment on lines +39 to +43
Comment on lines +41 to +43
Comment on lines 35 to +43
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Consider documenting the --only flag for partial stack bring-up.

The PR introduces an --only flag to bring up a subset of services (valid values: devnet, ensrainbow, ensindexer, ensapi). This would be useful for developers who want to run only part of the stack. Consider adding a brief example after line 43, such as:

To bring up only specific services, use the `--only` flag:

```sh
pnpm start --only devnet,ensrainbow

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @packages/integration-test-env/README.md around lines 35 - 43, Add
documentation for the new --only flag in the section that explains how to run
the stack with pnpm start: state that you can pass --only with a comma-separated
list of services (valid values: devnet, ensrainbow, ensindexer, ensapi), show a
brief usage example like pnpm start --only devnet,ensrainbow, and mention that
this starts only the listed services instead of the full stack so ports for the
omitted services are not required.


</details>

<!-- fingerprinting:phantom:triton:puma -->

<!-- This is an auto-generated comment by CodeRabbit -->


### Full CI pipeline (bring up + tests + tear down)

```sh
pnpm start:ci
```

Works both in CI and locally — just make sure the required ports are available.

### Manual (local development)

Expand Down
3 changes: 2 additions & 1 deletion packages/integration-test-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "module",
"description": "Integration test environment orchestration for ENSNode",
"scripts": {
"start": "CI=1 tsx src/orchestrator.ts",
"start": "tsx src/start.ts",
"start:ci": "CI=1 tsx src/ci.ts",
Comment on lines +9 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for references to process.env.CI in the integration-test-env package.

rg -nP --type=ts -g 'packages/integration-test-env/**' '\bprocess\.env\.CI\b'

Repository: namehash/ensnode

Length of output: 42


🏁 Script executed:

# Check the structure of the integration-test-env package
find packages/integration-test-env -type f -name "*.ts" -o -name "*.js" | head -20

Repository: namehash/ensnode

Length of output: 561


🏁 Script executed:

# Look at the ci.ts file to understand what it does
cat packages/integration-test-env/src/ci.ts

Repository: namehash/ensnode

Length of output: 1180


🏁 Script executed:

# Check if lifecycle.ts exists and where
find packages/integration-test-env -name "lifecycle.ts" -o -name "lifecycle.js"

Repository: namehash/ensnode

Length of output: 107


🏁 Script executed:

# Search for any CI environment variable usage in broader context (not just process.env.CI)
rg -n 'CI' packages/integration-test-env/src --type=ts -B2 -A2

Repository: namehash/ensnode

Length of output: 1379


🏁 Script executed:

# Check the package.json dependencies to understand what lifecycle.ts might be from
cat packages/integration-test-env/package.json

Repository: namehash/ensnode

Length of output: 738


🏁 Script executed:

# Examine the full lifecycle.ts to check for CI environment variable usage
cat packages/integration-test-env/src/lifecycle.ts

Repository: namehash/ensnode

Length of output: 12435


Remove or use the unused CI=1 environment variable.

The start:ci script sets CI=1, but this variable is never referenced in ci.ts, lifecycle.ts, or any other module in the integration-test-env package. Either remove this environment variable from the script or update the code to consume it for conditional behavior (e.g., logging, timeouts, or resource allocation).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/integration-test-env/package.json` at line 10, The package.json
"start:ci" script exports CI=1 but that env var is never used; either remove
"CI=1" from the "start:ci" entry in package.json, or update the code to consume
it (e.g., check process.env.CI in src/ci.ts or src/lifecycle.ts and gate
CI-specific behavior such as tighter timeouts, quieter logging, or alternate
resource allocation). Ensure any new behavior is clearly named and documented in
the script and that process.env.CI is parsed as a boolean where used.

"typecheck": "tsc --noEmit"
},
Comment on lines 8 to 12
"dependencies": {
Expand Down
34 changes: 34 additions & 0 deletions packages/integration-test-env/src/ci.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* `pnpm -F @ensnode/integration-test-env start:ci`
*
* Integration Test Environment CI flow.
*
* Brings up the full stack, runs monorepo-level integration tests, then tears everything down.
* For the manual flow that brings up the stack and waits for Ctrl+C without running tests, use
* `pnpm start` (start.ts).
*
* Phases (lifecycle.bringUp + test run):
* 1. ENSDb (postgres) + devnet via docker-compose (testcontainers DockerComposeEnvironment)
* 2. Seed devnet (primary names and resolver records)
* 3. Start ENSRainbow via `pnpm entrypoint` (downloads + extracts the prebuilt LevelDB in the background)
* 4. Start ENSIndexer
* 5. Wait for omnichain-following / omnichain-completed (indexing complete)
* 6. Start ENSApi
* 7. Run `pnpm test:integration` at the monorepo root
*/

import { bringUp, cleanup, runIntegrationTests } from "./lifecycle";

async function main() {
await bringUp();
runIntegrationTests();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Missing await causes premature cleanup and exit.

runIntegrationTests() is not awaited, so cleanup() on line 26 and process.exit(0) on line 27 execute immediately without waiting for the test run to complete. This will tear down the stack while tests are still running, causing test failures or incomplete results. The file header (lines 6, 17) and PR objectives confirm tests must finish before teardown.

🐛 Proposed fix
   await bringUp();
-  runIntegrationTests();
+  await runIntegrationTests();
 
   await cleanup();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runIntegrationTests();
await runIntegrationTests();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/integration-test-env/src/ci.ts` at line 24, runIntegrationTests() is
being invoked without awaiting, causing cleanup() and process.exit(0) to run
before tests finish; change the invocation to await runIntegrationTests() and
ensure it's inside an async context (or use .then/.catch) so the process only
calls cleanup() and process.exit(0) after runIntegrationTests() resolves; refer
to runIntegrationTests(), cleanup(), and process.exit to locate and update the
call site and surrounding control flow (use try/finally or promise chaining to
guarantee cleanup runs after the awaited test run).


await cleanup();
process.exit(0);
}

main().catch(async (e: unknown) => {
console.error(`[ci] ERROR: ${String(e)}`);
await cleanup();
process.exit(1);
});
Loading
Loading