-
Notifications
You must be signed in to change notification settings - Fork 0
test(buildgen): add incremental output equivalence #798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Implementation Plan: Incremental Build Equivalence | ||
|
|
||
| ## Context | ||
|
|
||
| Spec: [Incremental Build Equivalence](incremental-build-equivalence-spec.md) | ||
|
|
||
| Issue: [#686](https://github.com/cssbruno/GoWDK/issues/686) | ||
|
|
||
| ## Assumptions | ||
|
|
||
| - The first checked-in slice can live in `internal/buildgen` because current | ||
| incremental SPA generation is implemented there. | ||
| - `gowdk-build-report.json` records progress-path information by design, so the | ||
| equivalence helper compares artifact-relevant report events and exact bytes | ||
| for every other file. | ||
|
|
||
| ## Proposed Changes | ||
|
|
||
| - Add a reusable scenario helper for clean-versus-incremental output tree | ||
| comparison. | ||
| - Compare served output plus sibling compiler report output. | ||
| - Add deterministic multi-step coverage for route moves, component changes, | ||
| content-hashed assets, and layout changes. | ||
| - Remove stale asset-manifest files during incremental output publication. | ||
|
|
||
| ## Files Expected To Change | ||
|
|
||
| - `internal/buildgen/equivalence_test.go` | ||
| - `internal/buildgen/build.go` | ||
| - `internal/buildgen/manifests.go` | ||
| - `docs/engineering/testing.md` | ||
| - `docs/engineering/incremental-build-equivalence-spec.md` | ||
| - `docs/engineering/incremental-build-equivalence-plan.md` | ||
|
|
||
| ## Data And API Impact | ||
|
|
||
| - No public API changes. | ||
| - Incremental builds now remove stale generated asset files that were present in | ||
| the previous asset manifest but are absent from the current generated asset | ||
| set. | ||
|
|
||
| ## Tests | ||
|
|
||
| - Unit: focused `internal/buildgen` equivalence scenario. | ||
| - Integration: existing generated-output determinism script remains separate and | ||
| continues to cover clean-build determinism. | ||
| - End-to-end: generated app equivalence remains a follow-up. | ||
| - Manual: none. | ||
|
|
||
| ## Verification Commands | ||
|
|
||
| ```sh | ||
| go test ./internal/buildgen -run 'TestIncrementalBuildMatchesCleanBuildEquivalence|TestBuildIncremental' -count=1 | ||
| go test ./internal/buildgen -count=1 | ||
| go build ./cmd/gowdk | ||
| ``` | ||
|
|
||
| ## Rollback Plan | ||
|
|
||
| - Revert the stale asset cleanup and equivalence test if incremental publication | ||
| needs to return to previous behavior. | ||
| - Existing clean build output remains unaffected by this slice. | ||
|
|
||
| ## Risks | ||
|
|
||
| - The current report projection could miss a future artifact-relevant build | ||
| report event. Add such event kinds to the projection with the generator change | ||
| that introduces them. | ||
| - The deterministic matrix is not yet broad enough for generated app, split | ||
| target, backend endpoint, config, or WASM output equivalence. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Feature Spec: Incremental Build Equivalence | ||
|
|
||
| ## Problem | ||
|
|
||
| `gowdk dev` serves incrementally generated output. Focused incremental tests can | ||
| pass while stale files, manifests, or generated assets remain from an earlier | ||
| source state. For the same final project state, incremental output must converge | ||
| to the compiler-owned artifact tree produced by a clean build. | ||
|
|
||
| ## Goals | ||
|
|
||
| - Compare incremental output with a clean build of the same final state. | ||
| - Cover complete served output, compiler-owned report output, file bytes, and | ||
| meaningful file modes. | ||
| - Include manifests and report-relevant metadata, not only HTML. | ||
| - Identify the edit step and divergent file when equivalence fails. | ||
| - Keep intentional normalization rules narrow and documented. | ||
|
|
||
| ## Non-Goals | ||
|
|
||
| - Requiring every edit to use the incremental path; full rebuild fallback | ||
| remains valid. | ||
| - Comparing timestamps, wall-clock timings, or debug progress logs. | ||
| - Optimizing invalidation before correctness is covered. | ||
|
|
||
| ## Users And Permissions | ||
|
|
||
| - Primary users: GOWDK maintainers and contributors changing build generation or | ||
| dev-loop invalidation. | ||
| - Roles or permissions: repository test access. | ||
| - Data visibility rules: test fixtures must not include secrets or local | ||
| environment-specific data. | ||
|
|
||
| ## User Flow | ||
|
|
||
| 1. A test defines an initial compiler source state. | ||
| 2. The harness builds that state into an incremental output directory. | ||
| 3. Each scenario step mutates source/config state and runs the incremental | ||
| build path. | ||
| 4. The harness builds the same current state into a fresh clean directory. | ||
| 5. The harness compares the incremental tree with the clean tree and reports the | ||
| first divergent file for the responsible step. | ||
|
|
||
| ## Requirements | ||
|
|
||
| ### Functional | ||
|
|
||
| - Compare relative file paths, file bytes, and permission bits. | ||
| - Detect files present only in incremental output or only in clean output. | ||
| - Compare the served output directory and sibling `.gowdk/reports/<target>/` | ||
| compiler report directory. | ||
| - Canonicalize only `gowdk-build-report.json` fields that are path-dependent or | ||
| progress-path-dependent between clean and incremental runs. | ||
| - Exercise at least one multi-step scenario where edit order can expose stale | ||
| state. | ||
|
|
||
| ### Non-Functional | ||
|
|
||
| - Performance: focused scenarios must stay cheap enough for normal Go test CI. | ||
| - Reliability: failures must name the step and artifact path. | ||
| - Accessibility: not applicable. | ||
| - Security/privacy: generated security posture reports are compared as compiler | ||
| output, but fixtures do not contain secret material. | ||
| - Observability: failure output is file-level and byte-offset-level. | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - [x] A reusable test harness compares incremental output with clean output. | ||
| - [x] Comparison covers artifact paths, bytes, modes, stale-file absence, served | ||
| output, and compiler-owned report output. | ||
| - [x] Manifest equivalence is included through exact file comparison. | ||
| - [x] Build report equivalence is included through a narrow canonical report | ||
| projection. | ||
| - [x] A deterministic multi-edit scenario covers route, component, asset, and | ||
| layout changes. | ||
| - [ ] Generated app and split frontend/backend output equivalence are covered. | ||
| - [ ] Backend endpoint, contract, config, selected-target, and WASM scenarios are | ||
| added. | ||
| - [ ] A bounded seeded state-machine test is added. | ||
|
|
||
| ## Edge Cases | ||
|
|
||
| - Content-hashed asset turnover must remove stale emitted files. | ||
| - Route moves must remove stale page outputs. | ||
| - Security manifests live outside the served output directory and must still be | ||
| compared. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - Internal: `internal/buildgen` clean and incremental SPA builders. | ||
| - External: none. | ||
|
|
||
| ## Open Questions | ||
|
|
||
| - Which generated app targets should be the first appgen equivalence slice? | ||
| - Should broader state-machine coverage run in every pull request or only in a | ||
| scheduled lane once the deterministic matrix is larger? |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
BuildIncrementalFromValidatedProgram, only pages listed inchangedPageSourcesare re-rendered, but this cleanup removes every previous manifest asset that is not in the current asset set. When a global CSS processor asset such as Tailwind's app stylesheet changes during a single-page incremental rebuild, unchanged pages keep their old hashed stylesheet link while this deletes that old file, turning those pages' CSS URL into a 404; either force all pages that include changed global assets to render or delay deleting stale assets until no unchanged HTML can reference them.Useful? React with 👍 / 👎.