-
Notifications
You must be signed in to change notification settings - Fork 445
Cover wasm-only files in custom lint CI #42650
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1207,6 +1207,9 @@ jobs: | |
| - name: Run custom linters | ||
| run: make golint-custom LINTER_FLAGS="-errstringmatch -panicinlibrarycode -manualmutexunlock -osexitinlibrary -rawloginlib -regexpcompileinfunction -fprintlnsprintf -strconvparseignorederror -jsonmarshalignoredeerror -uncheckedtypeassertion -fmterrorfnoverbs -tolowerequalfold -httpnoctx -timeafterleak -errortypeassertion -execcommandwithoutcontext -test=false" | ||
|
|
||
| - name: Run custom linters (wasm) | ||
| run: GOOS=js GOARCH=wasm make golint-custom LINTER_FLAGS="-errstringmatch -panicinlibrarycode -manualmutexunlock -osexitinlibrary -rawloginlib -regexpcompileinfunction -fprintlnsprintf -strconvparseignorederror -jsonmarshalignoredeerror -uncheckedtypeassertion -fmterrorfnoverbs -tolowerequalfold -httpnoctx -timeafterleak -errortypeassertion -execcommandwithoutcontext -test=false" LINTER_PACKAGES="./pkg/console ./pkg/parser ./pkg/styles ./pkg/tty ./pkg/workflow" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/diagnosing-bugs] The wasm package list ( 💡 Suggestion: auto-discover packages with wasm filesConsider deriving the list from the repository instead: WASM_PACKAGES ?= $(shell grep -rl '(go/redacted):build js' --include='*.go' $(shell go list -f '{{.Dir}}' ./...) | xargs -I{} dirname {} | sort -u | sed 's|.*|\./&|')Or document the manual curation in a comment adjacent to the step so reviewers know to update it when adding new wasm files. @copilot please address this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated 💡 Suggested fixThe exact same 15-analyzer flags string is copy-pasted into both CI steps. Whenever an analyzer is added to or removed from the default step, the wasm step silently uses a stale set — meaning wasm-only code could evade a newly added rule, or the step could fail spuriously when an old flag is removed. Extract the shared flags to a workflow-level env:
CUSTOM_LINTER_FLAGS: >-
-errstringmatch -panicinlibrarycode -manualmutexunlock ...
jobs:
...
- name: Run custom linters
run: make golint-custom LINTER_FLAGS="$CUSTOM_LINTER_FLAGS"
- name: Run custom linters (wasm)
run: GOOS=js GOARCH=wasm make golint-custom LINTER_FLAGS="$CUSTOM_LINTER_FLAGS" LINTER_PACKAGES="..."Or add a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded 💡 DetailsThe five packages are manually enumerated. Any new package that gains a At minimum, add a comment that developers must keep this list in sync with: A stronger fix would derive the list dynamically in the Makefile by filtering packages that contain wasm build-tag files, so new packages are covered automatically. |
||
|
|
||
| # Ensure no action shell scripts invoke python or python3 | ||
| - name: Lint action shell scripts | ||
| run: make lint-action-sh | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,15 +16,15 @@ import ( | |
| // tool validation (WithSkipValidation(true)). | ||
|
|
||
| func setupGHCommand(ctx context.Context, args ...string) *exec.Cmd { | ||
| return exec.Command("echo", "gh CLI not available in Wasm") | ||
| return ghUnavailableCommand(ctx) | ||
| } | ||
|
|
||
| func ExecGH(args ...string) *exec.Cmd { | ||
| return exec.Command("echo", "gh CLI not available in Wasm") | ||
| return ghUnavailableCommand(context.Background()) | ||
| } | ||
|
|
||
| func ExecGHContext(ctx context.Context, args ...string) *exec.Cmd { | ||
| return exec.Command("echo", "gh CLI not available in Wasm") | ||
| return ghUnavailableCommand(ctx) | ||
| } | ||
|
|
||
| func ExecGHWithOutput(args ...string) (stdout, stderr bytes.Buffer, err error) { | ||
|
|
@@ -43,6 +43,13 @@ func RunGHCombined(spinnerMessage string, args ...string) ([]byte, error) { | |
| return nil, errors.New("gh CLI not available in Wasm") | ||
| } | ||
|
|
||
| func ghUnavailableCommand(ctx context.Context) *exec.Cmd { | ||
| if ctx == nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/diagnosing-bugs] The nil-context guard is good defensive programming, but none of the current callers can pass nil (they either have a real ctx or use 💡 Suggested commentfunc ghUnavailableCommand(ctx context.Context) *exec.Cmd {
// Guard against nil context: exec.CommandContext panics on nil.
if ctx == nil {
ctx = context.Background()
}
return exec.CommandContext(ctx, "echo", "gh CLI not available in Wasm")
}@copilot please address this. |
||
| ctx = context.Background() | ||
| } | ||
| return exec.CommandContext(ctx, "echo", "gh CLI not available in Wasm") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using 💡 DetailsPreviously all three stubs used Any caller that inspects the error message or type (e.g., looking for "not available in Wasm") will receive a different error class. The file comment states these stubs are never called at runtime due to |
||
| } | ||
|
|
||
| func ForceGHHostEnv(cmd *exec.Cmd, host string) { | ||
| // no-op in Wasm: gh CLI subprocesses are not run | ||
| } | ||
|
|
||
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.
[/codebase-design] The full
LINTER_FLAGSstring is copy-pasted from the step above — if a new analyzer flag is added to the main step, the wasm step silently misses it.💡 Suggestion: extract a Makefile variable
Define a shared default in the
Makefileso the flag set is the single source of truth:Then the CI steps simply omit
LINTER_FLAGSand both inherit the same defaults automatically:@copilot please address this.