Repository navigation
chore(build): keep the Makefile Go targets out of frontend/node_modules - #1558
Conversation
Go's ./... skips only testdata and paths starting with . or _, so once `npm ci` had run, the Makefile's vet, test-unit, test-compile-integration, test-integration, test-coverage and fmt targets (and plain golangci-lint and govulncheck runs) picked up frontend/node_modules/flatted/golang as a package of this module and checked third-party code. Add `ignore ./frontend/node_modules` to go.mod (Go 1.25+). It applies to every go command's ./... and to the tools that load packages through go list, so the Makefile targets need no change and stay identical to the commands people copy. Checked with the pinned tools: golangci-lint v2.10.1 and govulncheck v1.1.4 drop the package; gocyclo walks the filesystem and keeps its own -ignore; go mod tidy -diff is clean. scripts/test-make-gates.sh (run by CI's lint job) gains a case that overlays a probe package under frontend/node_modules plus a control probe elsewhere under frontend/ and asserts go list ./... (with and without -tags=integration) lists only the control. It fails without the go.mod line. Closes LeanerCloud#177 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
govulncheck in the Docker image build now fails on these two advisories, both fixed in x/net v0.62.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Head moved from Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rG2. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 1 approving independent review(s) on |
Conflict in scripts/test-make-gates.sh: kept main's case 5 (./... skips frontend/node_modules, LeanerCloud#1558) and renumbered this branch's complexity case to 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root cause
Go's
./...pattern skips onlytestdataand paths that start with.or_. Oncenpm cihas run,frontend/node_modules/flatted/golang/pkg/flatted(Go source shipped inside an npm package, with nogo.modof its own) becomes a package of this module. Every Makefile Go target that passes./...then checks that third-party code:vet,test-unit,test-compile-integration,test-integration,test-coverageandfmt. So do plaingolangci-lint runandgovulncheck ./.... #1286 already fixed the gocyclo walk and #1512 fixed the pre-commitgo vet/go testhooks. The Makefile targets were the last item in the issue.Fix
Add
ignore ./frontend/node_modulestogo.mod. Theignoredirective arrived in Go 1.25, and this repo pins 1.26.10. It applies to./...in every go command and to every tool that loads packages throughgo list/go/packages. As a result:./...target is covered automatically.I chose this over the
go list -e ./... | grep -v /node_modules/fallback because the brief asked for it if every pinned tool accepts it, and they do (results below). The fallback would also have needed six recipe edits plus apipefailguard per target.A new case in
scripts/test-make-gates.shcovers the regression. CI's lint job already runs that script ("Run Makefile gate self-tests"), and the step comment inci.ymlnow mentions the new case. The case usesgo list -overlayto add two packages:frontend/node_modules/.frontend/.It then asserts that
go list ./...andgo list -tags=integration ./...list the control but not the probe. The control proves the overlay took effect, so the check can't pass vacuously, and it also shows the ignore covers onlynode_modules. No npm install is needed (the lint job has none) and nothing is written into the repo.Closes #177
Verification
Local evidence: a real
frontend/node_modulesfromcd frontend && npm ci, plus the overlay probe. Go 1.26.10.Fail-before/pass-after of the new gate case (
bash scripts/test-make-gates.sh):The commands each Makefile target runs, with
frontend/node_modulespopulated (count ofnode_moduleslines in-noutput, before -> after):go vet -n ./...go vet -n -tags=integration ./...go test -n -short ./...go test -n -tags=integration ./...go fmt -n ./...go build -n ./...go list -e ./...went from 51 packages including.../frontend/node_modules/flatted/golang/pkg/flattedto 50 packages without it.Pinned tools against the new
go.mod:run --allow-parallel-runners --no-config --default=none --enable gocyclo ./...): before, it reportedfrontend/node_modules/flatted/golang/pkg/flatted/flatted.go:16:1: cyclomatic complexity 32 of func Stringify(exit 1). After,0 issues.(exit 0). It parses theignoredirective without error.-show verbose ./..., the CI pin): before, the flatted package was in the scanned package list. After, it isn't. Exit 0 both times, and the findings are unchanged.go.mod, so the directive has no effect on it. The Makefilecomplexitytarget andci.ymlkeep their existing-ignore '(^|/)(node_modules|vendor)/'from ci: keep gocyclo's filesystem walk out of node_modules and vendor #1286. Output is unchanged: 0 findings.go build ./...,go vet ./...andgo vet -tags integration ./...all pass.make tidy-check(go mod tidy -diffin both modules underGOTOOLCHAIN=go1.26.10 GOWORK=off) is clean, so tidy keeps the directive and its comment where they are.GOWORK=off go list ./...also skips the package.shellcheck scripts/test-make-gates.shandactionlint .github/workflows/ci.ymlare clean.Combined-tree verification. This branch was tested together with the other queued branches on a local, never-pushed tree:
queue/platform@400d256b= origin/main7b86e386plus these heads, merged in this order:Linux, Go 1.26.9,
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true; Docker Postgres via testcontainers. The full suite ran onf7c48020, which differs from this tree only by test-only commits on fix/issue-30, fix/issue-713 and fix/issue-263 that replace placeholder account-number literals with named constants:go build ./...,go vet ./...,go vet -tags integration ./...and the fullgo test -race -short -count=1 ./....--build-tags integration.gocyclo -over 10is silent on the changed non-test files.-tags integration -count=1):internal/analytics,internal/api,internal/auth,internal/config,internal/database/postgres/migrations,internal/purchase,internal/schedulerandinternal/serverall pass. Migrations 000149, 000150 and 000151 apply in order on this tree.approval-details,settings-accounts,api) pass (221 tests).accountkey); fixed with named constants. Re-run on this tree: git-secrets, using the repo'sscripts/setup-git-secrets.shpatterns in a fresh repo with an isolated HOME, found nothing in the changed files, and a planted fake key was flagged.scripts/test-git-secrets-allowlist.sh: 183 PASS, 0 FAIL..tftest.hclfiles were not run locally (CI runs them). Nothing was applied to any cloud.Left out of scope / notes
scripts/run-gosec.shpasses only-exclude-dir=.legacy -exclude-dir=.dev-notes -exclude-dir=vendor. With deps installed, gosec v2.28.0 still checksfrontend/node_modules/flatted/golang/pkg/flatted/flatted.goboth before and after this PR. That is the same kind of exposure but a different tool, and chore(ci): gocyclo's filesystem walk in ci.yml scans frontend/node_modules when deps are installed #177 doesn't mention it. A one-line follow-up would add-exclude-dir=node_modulesinrun-gosec.sh.go list -e ./... | grep -v /node_modules/filter from chore(ci): keep the pre-commit go vet and go test hooks out of node_modules #1512. It's now redundant but harmless, so I left it alone.go.modlocally. It needs a Go 1.25+ updater to acceptignore. Current Dependabot images ship a newer Go, so the first Dependabot gomod run after merge is worth a glance.Maintainer: please mirror the issue's triage labels onto this PR:
effort/xs,impact/internal,priority/p3,severity/low,triaged,type/chore,urgency/eventually.🤖 Generated with Claude Code