Repository navigation
feat(nix-checks): add ent-codegen-drift-check + ent-lint-check - #1221
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces CI checks for Ent codegen drift and linting, updates the Nix package's vendor hash, and excludes generated Ent and Atlas files from the formatter. Feedback was provided to optimize the CI check derivations by removing unnecessary inherited dependencies and to improve the formatter's exclusion patterns for better maintainability and to avoid accidentally excluding hand-written files like ent/generate.go.
74f8df5 to
bae8e7f
Compare
b61c139 to
da2e2de
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
bae8e7f to
74f0b82
Compare
da2e2de to
2a5b056
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
74f0b82 to
3f8d9aa
Compare
2a5b056 to
b58ba2f
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
3f8d9aa to
6df93cb
Compare
b58ba2f to
03b777f
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
6df93cb to
f540788
Compare
03b777f to
7cf61e7
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
f540788 to
bd57a59
Compare
7cf61e7 to
56eadca
Compare
ent/generate.go is hand-written (carries the //go:generate directive) but the broad ent/*.go exclusion swept it into the codegen-only group. Add an explicit !ent/generate.go negation so it stays formattable without re-introducing diff loops against the codegen drift check. Addresses gemini-code-assist comment on PR #1221 (PRRT_kwDONV6tZs6D3zlq). Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Automated stack merge failed during the rebase step. The |
Adds two new derivations to the nix checks tree, both of which feed into `nix flake check`: - `ent-codegen-drift-check` materializes the source tree, runs `go generate ./ent/...`, and fails the build if any committed file under `./ent` differs after regeneration. Uses `proxyVendor = true` because Ents `tool` dependency (entgo.io/ent/cmd/ent) is not vendored. - `ent-lint-check` builds and runs `cmd/ent-lint --root .` and fails if any `[FAIL]` lines appear in the output. Drive-by fixes: - Update vendor hash to match the post-cleanup go.sum (pre-existing drift after the sqlc removal). - Drop the now-broken `cp -r db $out/share/ncps/db` from postInstall; the `db/` tree no longer exists. - Add `ent/*.go`, `ent/<generated-pkg>/**/*.go`, and `migrations/**/*.sql` to treefmt-nixs global excludes so the formatter cannot fight the Ent generator or invalidate atlas.sum. Marks tasks 13.1 and 13.2 complete in the migrate-to-ent-and-atlas change.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with 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.
Inline comments:
In `@nix/checks/flake-module.nix`:
- Around line 92-97: The buildPhase for the ent-lint-check currently runs the
pipeline "./ent-lint --root . | tee ent-lint.out" without pipefail, which can
hide a failing ent-lint exit status; update the ent-lint-check buildPhase (the
pipeline invocation in the buildPhase) to enable pipefail before running the
pipeline (e.g. run "set -o pipefail" in the buildPhase shell context) so the
pipeline returns a non-zero status when ent-lint fails and the derivation fails
immediately.
- Around line 69-72: Update the ent codegen and lint checks so untracked
generated files and lint failures can't be masked: after running git diff
--exit-code ./ent/ also check for untracked files under ent (e.g., run git
ls-files --others --exclude-standard -- ent/ and fail if any output) and combine
both results to return non-zero when codegen drift exists; and ensure the
ent-lint invocation preserves failures by enabling pipefail (e.g., set -o
pipefail before running ./ent-lint --root . | tee ent-lint.out or run the lint
command and capture its exit status directly) so any non-zero exit from
./ent-lint causes the check to fail even if tee succeeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d3c9502e-fdb7-42e0-9f31-a85f1d8248c6
📒 Files selected for processing (3)
nix/checks/flake-module.nixnix/formatter/flake-module.nixopenspec/changes/migrate-to-ent-and-atlas/tasks.md
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (2)
nix/checks/flake-module.nix (2)
92-97:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
ent-lintfailures can be masked byteewithoutpipefail.The pipeline can return success from
teeeven when./ent-lintfails.💡 Suggested fix
+ set -o pipefail ./ent-lint --root . | tee ent-lint.out#!/bin/bash set -e echo "Without pipefail:" if ( false | tee /dev/null >/dev/null ); then echo "masked failure" else echo "pipeline failed" fi set -o pipefail echo "With pipefail:" if ( false | tee /dev/null >/dev/null ); then echo "pipeline succeeded" else echo "producer failure propagated" fi🤖 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 `@nix/checks/flake-module.nix` around lines 92 - 97, The ent-lint invocation piped into tee can mask failures because the shell may report tee's exit status instead of ent-lint's; ensure the producer failure is propagated by enabling pipefail or by checking ent-lint's exit explicitly. Update the block that runs "./ent-lint --root . | tee ent-lint.out" to either run "set -o pipefail" earlier in the script (so the pipeline fails if ent-lint fails) or replace the pipeline with a command that captures the exit status (e.g., run "./ent-lint --root . | tee ent-lint.out; lint_status=${PIPESTATUS[0]}; if [ \"$lint_status\" -ne 0 ]; then echo 'ent-lint failed' >&2; exit 1; fi"), referencing the "./ent-lint --root .", "tee ent-lint.out", and the subsequent "grep -q '^\[FAIL\]' ent-lint.out" logic so the rest of the check behaves correctly.
69-72:⚠️ Potential issue | 🟠 Major | ⚡ Quick winCodegen drift check misses untracked generated files.
git diff --exit-code ./ent/won’t catch newly created untracked files underent/, so drift can false-pass.💡 Suggested fix
- if ! git diff --exit-code ./ent/; then + if [ -n "$(git status --porcelain --untracked-files=all -- ./ent/)" ]; then + git diff -- ./ent/ || true echo "ent/ codegen is out of date — run 'go generate ./ent/...' and commit the result." >&2 exit 1 fi#!/bin/bash set -euo pipefail tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT cd "$tmp" git init -q mkdir -p ent printf '%s\n' '// baseline' > ent/a.go git add -A git -c [email protected] -c user.name=ci commit -q -m baseline printf '%s\n' '// newly generated' > ent/b.go echo "git diff result:" if git diff --exit-code -- ./ent/ >/dev/null; then echo "PASS (diff missed untracked file)" else echo "FAIL (diff caught change)" fi echo "git status porcelain:" git status --porcelain --untracked-files=all -- ./ent/🤖 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 `@nix/checks/flake-module.nix` around lines 69 - 72, The check uses "if ! git diff --exit-code ./ent/; then" which misses newly created untracked files; replace that condition with a git status porcelain check that includes untracked files (for example test whether "git status --porcelain --untracked-files=all -- ./ent/" returns non-empty) and fail when it does, keeping the existing error message and exit code so any modified or untracked files under ent/ cause the same error path.
🤖 Prompt for all review comments with 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.
Duplicate comments:
In `@nix/checks/flake-module.nix`:
- Around line 92-97: The ent-lint invocation piped into tee can mask failures
because the shell may report tee's exit status instead of ent-lint's; ensure the
producer failure is propagated by enabling pipefail or by checking ent-lint's
exit explicitly. Update the block that runs "./ent-lint --root . | tee
ent-lint.out" to either run "set -o pipefail" earlier in the script (so the
pipeline fails if ent-lint fails) or replace the pipeline with a command that
captures the exit status (e.g., run "./ent-lint --root . | tee ent-lint.out;
lint_status=${PIPESTATUS[0]}; if [ \"$lint_status\" -ne 0 ]; then echo 'ent-lint
failed' >&2; exit 1; fi"), referencing the "./ent-lint --root .", "tee
ent-lint.out", and the subsequent "grep -q '^\[FAIL\]' ent-lint.out" logic so
the rest of the check behaves correctly.
- Around line 69-72: The check uses "if ! git diff --exit-code ./ent/; then"
which misses newly created untracked files; replace that condition with a git
status porcelain check that includes untracked files (for example test whether
"git status --porcelain --untracked-files=all -- ./ent/" returns non-empty) and
fail when it does, keeping the existing error message and exit code so any
modified or untracked files under ent/ cause the same error path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 92d5739f-9f75-43db-8144-75e0fd8046bc
📒 Files selected for processing (2)
.github/workflows/ci.ymlnix/checks/flake-module.nix
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1221 +/- ##
=====================================
Coverage 5.50% 5.50%
=====================================
Files 6 6
Lines 400 400
=====================================
Hits 22 22
Misses 374 374
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds two new derivations to the nix checks tree, both of which feed into
nix flake check:ent-codegen-drift-checkmaterializes the source tree, runsgo generate ./ent/..., and fails the build if any committed fileunder
./entdiffers after regeneration. UsesproxyVendor = truebecause Ents
tooldependency (entgo.io/ent/cmd/ent) is not vendored.ent-lint-checkbuilds and runscmd/ent-lint --root .and failsif any
[FAIL]lines appear in the output.Drive-by fixes:
drift after the sqlc removal).
cp -r db $out/share/ncps/dbfrom postInstall;the
db/tree no longer exists.ent/*.go,ent/<generated-pkg>/**/*.go, andmigrations/**/*.sqlto treefmt-nixs global excludes so theformatter cannot fight the Ent generator or invalidate atlas.sum.
Marks tasks 13.1 and 13.2 complete in the migrate-to-ent-and-atlas
change.