Skip to content

Drop forbidigo env.Get carve-out for _test.go#5330

Open
pietern wants to merge 1 commit into
mainfrom
lint-trim-envget
Open

Drop forbidigo env.Get carve-out for _test.go#5330
pietern wants to merge 1 commit into
mainfrom
lint-trim-envget

Conversation

@pietern
Copy link
Copy Markdown
Contributor

@pietern pietern commented May 26, 2026

Removes the text: "Use env\.Get" / path: "_test\.go$" exception from .golangci.yaml so the forbidigo rule applies uniformly. Touches ~34 test sites to call env.Get(t.Context(), …) instead of os.Getenv(…), threading ctx into two helpers (getSkipReason, buildBaseParams) along the way.

The three package-level var X = os.Getenv("Y") != "" declarations in acceptance/acceptance_test.go (VerboseTest, benchmarkMode, ApplyCITimeoutMultipler) have no t/ctx available, so they're switched to bare bool declarations with the env reads moved into the existing init() via os.LookupEnv — which is not on the forbidigo list and preserves the "set and non-empty" semantics exactly.

Plumbs t.Context() into ~34 test sites so they use env.Get instead of
os.Getenv, and rewrites three package-level os.Getenv vars in
acceptance/acceptance_test.go to use os.LookupEnv (which preserves the
"set and non-empty" semantics without tripping the lint).

Co-authored-by: Isaac
flag.BoolVar(&OnlyOutTestToml, "only-out-test-toml", false, "Only regenerate out.test.toml files without running tests")
flag.BoolVar(&Subset, "subset", false, "Select a subset of EnvMatrix variants that cover all output files. Auto-enabled on -update (unless -run specifies a variant with '=').")

if v, _ := os.LookupEnv("VERBOSE_TEST"); v != "" {
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.

It seems odd that we use os.LookupEnv instead of os.GetEnv here because we banned os.GetEnv.

Also, what's the value of using env.Get in acceptance test runner? I thought it's only needed for production code that we want to unit test.

@github-actions
Copy link
Copy Markdown
Contributor

Approval status: pending

/cmd/apps/ - needs approval

Files: cmd/apps/dev_test.go, cmd/apps/import_test.go
Suggested: @fjakobs
Also eligible: @MarioCadenas, @jamesbroadhead, @Shridhad, @atilafassina, @keugenek, @arsenyinfo, @igrekun, @pkosiec, @pffigueiredo, @ditadi, @calvarjorge

/integration/ - needs approval

Files: integration/cmd/fs/helpers_test.go, integration/cmd/secrets/secrets_test.go, integration/libs/filer/helpers_test.go
Suggested: @simonfaltum
Also eligible: @renaudhartert-db, @hectorcast-db, @parthban-db, @tanmay-db, @Divyansh-db, @tejaskochar-db, @mihaimitrea-db, @chrisst, @rauchy

General files (require maintainer)

4 files changed
Based on git history:

  • @denik -- recent work in acceptance/, ./, libs/exec/

Any maintainer (@andrewnester, @anton-107, @denik, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants