Verify local environment during setup | **Head:** issue-313-setup-verification#461
Open
heyoub wants to merge 1 commit into
Open
Verify local environment during setup | **Head:** issue-313-setup-verification#461heyoub wants to merge 1 commit into
issue-313-setup-verification#461heyoub wants to merge 1 commit into
Conversation
Run Builder tests and reuse the local E2E lifecycle for Bruno and Chromium verification. Treat fresh Devbox registration as optional while failing closed on occupied ports and preserving emulator data transactionally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft pull request
Title: Verify local environment during setup
Repository:
CodeForPhilly/benefit-decision-toolkitBase:
mainHead:
issue-313-setup-verificationDraft: yes
Summary
This change makes the developer setup lifecycle verify that a Devbox-managed local environment or GitHub Codespace is not merely installed, but actually usable end to end.
bin/setupnow runs the Java test suites and then delegates to the existing local E2E lifecycle so setup verifies the complete stack with:emulator-dataThe implementation is intentionally limited to:
bin/setupbin/run-e2e-testsNo product code, workflow file, lockfile, or permanent documentation file is changed.
Closes #313.
Problem
Issue #313 asks setup to run E2E tests, Java Maven tests, and Bruno tests so a new Devbox-managed local environment or Codespace proves that it is configured and started correctly.
Before this change, setup could finish after dependency installation and Maven packaging without proving the full local graph. In particular:
-DskipTests, so its 40 tests were not part of setup verification. Library API packaging already ran its 14 tests.A setup command that only installs dependencies can still leave a contributor with a broken service graph, missing browser runtime, failing API behavior, or E2E fixtures that cannot be loaded. This PR changes Devbox-managed setup from an installation-only path into a local environment verification path.
Root cause and state model
The key orchestration bug was treating the absence of a process-compose registration as an error.
In a fresh or fully stopped worktree, all of the following may legitimately be absent:
.envfiles before the Codespaces bootstrap pre-stepemulator-dataThat is different from a registered graph, an occupied application port, malformed process-compose data, or an indeterminate socket state.
This PR codifies the distinction explicitly:
The managed application ports are:
The ordering is deliberate: port ownership and shutdown are resolved before
emulator-datais moved or replaced. The runner never mutates emulator state while another or unknown local process may still own the graph.Implementation
bin/setupSetup now performs a preflight when running inside Devbox:
The Java builds now run their tests:
The previous Builder API
-DskipTestsbehavior is removed. Library API packaging remains unchanged because it already runs its test suite.After environment files are prepared, Devbox setup runs:
This makes the normal setup lifecycle prove the complete local development environment instead of reporting success after dependency installation alone.
bin/run-e2e-testsThe E2E runner now treats local state as a transaction.
Preconditions
It verifies:
devbox,python3,node,npm, andbruare availableemulator-datais either absent or a real directorynpm ciBrowser installation
The runner uses the repository-local Playwright version and installs only Chromium:
This avoids an ambient
npxversion and keeps the browser runtime tied to the lockfile. On Linux, the first run may invoke the system package manager throughsudo; Codespaces supports that noninteractively.Service ownership
Before fixture mutation, it:
Emulator-data transaction
When original
emulator-dataexists, it is moved into a recovery directory underlogs/and the move is verified before fixture installation.The runner then:
The cleanup trap preserves the original test exit status while independently tracking cleanup failure.
When the cleanup trap runs, it will not remove or restore emulator data until it can prove the service graph is stopped. It verifies:
If restoration cannot be proven safe, cleanup fails loudly, reports the surviving backup/current paths, and tells the operator not to rerun until recovery is resolved. It does not paper over an unsafe state with
|| true.On successful cleanup, the same transaction restores either:
No shell trap can recover from
SIGKILLor abrupt container destruction. In those cases, any completed backup remains the recovery source and the runner reports recovery paths whenever it still has an opportunity to do so.Codespaces lifecycle
The validated Codespaces entrypoint is the repository's existing devcontainer lifecycle command:
bin/ensure-root-env-file && devbox run setupThe pre-step matters because
devbox.jsonloads the root file throughenv_frombefore Devbox invokesbin/setup. A completely absent.envtherefore prevents the standalonedevbox run setupcommand from entering the setup script.This PR does not change that configuration contract. It verifies the complete Codespaces lifecycle already defined by
.devcontainer/devcontainer.json.Validation
The exact lifecycle command completed successfully from an isolated feature worktree:
bin/ensure-root-env-file && devbox run setupJava
Library API classes:
DynamicEndpointPatternTest: 4ModelDiscoveryTest: 4OpenAPISchemaPatternTest: 4SituationTypeValidationTest: 2Builder API classes:
DmnParserTest: 4FormDataTransformerTest: 13InputSchemaServiceTest: 18LibraryApiServiceTest: 5Bruno
All requests targeted the local Library API. No cloud credentials were requested.
Playwright
The suite covered:
The repository-local Playwright 1.57 installation downloaded:
143.0.7499.4, build120012001011State-machine and shell validation
The disposable checks covered fresh/stopped state, active registration, malformed registration, occupied ports, partial startup, cleanup behavior, backup restoration, and fail-closed socket outcomes without touching the real service graph.
CI coverage note
The current path-filtered workflows do not execute
bin/setuporbin/run-e2e-testsfor this two-script diff. The results above come from the exact Codespaces lifecycle command and the disposable state harness. Expanding workflow triggers is intentionally outside this PR's scope.Temporary feature graph
The validation started a temporary graph, proved readiness, ran the tests, and stopped it successfully.
After cleanup:
The separate validation harness then removed the validation-created Playwright cache to return the Codespace to its pre-run baseline. Browser-cache removal is not a cleanup responsibility of
bin/run-e2e-tests.Original developer graph preservation
The original
mainworktree's service graph was stopped gracefully before isolated validation and restarted afterward.The original emulator-data digest immediately after graceful stop and after graph restoration matched exactly:
The match covered 22 filesystem entries.
The original worktree remained at the same commit with only its known pre-existing
devbox.lockmetadata drift. The feature worktree returned to a clean state after commit, and the branch contains one commit changing only the two approved scripts.Network boundary observed during validation
Directly evidenced external package/browser hosts were:
repo.maven.apache.orgdeb.debian.orgcdn.playwright.devRuntime application traffic used only localhost. Captured output showed no staging/production application requests and no Google Cloud or Firebase cloud service requests.
Relationship to other work
PR #460
This change builds on #460, which updated the E2E suite for current UI behavior and introduced the local
bin/run-e2e-testspath. This PR hardens that runner and wires it into setup; it does not duplicate the UI selector or test-maintenance work from #460.Issue #443
PR #460 introduced the local E2E runner and was intended to resolve #443. This PR builds on that implementation by hardening the runner and integrating it into setup.
This PR intentionally includes no closing keyword for #443. Maintainers can decide separately whether PR #460 already satisfied that issue.
Known limitation before ready-for-review
The underlying first-time Playwright dependency transaction was verified separately in this canonical Debian 13 Codespace. The repository-local Playwright 1.57 command installed the missing Chromium dependency set, added 92 Debian packages, downloaded Chromium, and launched it successfully.
The later successful full lifecycle run occurred after those operating-system packages were already present. During that run, Playwright reported:
Therefore the combined evidence proves:
./node_modules/.bin/playwright install --with-deps chromiumsucceeds on the canonical Debian 13 Codespace imageThe remaining unverified case is the entire setup lifecycle from a brand-new Codespace with those OS dependencies initially absent.
Before this draft is marked ready for review, rebuild or open a pristine Codespace and rerun:
bin/ensure-root-env-file && devbox run setupReviewer mental model
The safety invariant is:
The implementation is intentionally conservative because emulator state is developer data. A false refusal is recoverable; mutating data while ownership is unknown is not.
Checklist
bin/setupandbin/run-e2e-tests--with-deps chromiuminstalled missing Debian 13 packages and launched Chromium