diff --git a/.github/workflows/cgo.yml b/.github/workflows/cgo.yml index e472cb9fc26..da14d043b8a 100644 --- a/.github/workflows/cgo.yml +++ b/.github/workflows/cgo.yml @@ -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" + # Ensure no action shell scripts invoke python or python3 - name: Lint action shell scripts run: make lint-action-sh diff --git a/Makefile b/Makefile index 53b3c6d7a1c..f26c5a25166 100644 --- a/Makefile +++ b/Makefile @@ -715,14 +715,17 @@ golint: # Builds and runs linters defined in cmd/linters against the full repository. # Override the large-function line limit with: make golint-custom MAX_LINES=80 # Limit the analyzer set with: make golint-custom LINTER_FLAGS="-errstringmatch -test=false" +# Limit analyzed packages with: make golint-custom LINTER_PACKAGES="./pkg/console ./pkg/workflow" +# Prefix with GOOS/GOARCH to analyze alternate build targets without cross-compiling the linter runner itself. MAX_LINES ?= 60 LINTER_FLAGS ?= +LINTER_PACKAGES ?= ./cmd/... ./pkg/... .PHONY: golint-custom golint-custom: @echo "Building custom linters..." - @go build -o /tmp/gh-aw-linters ./cmd/linters + @env -u GOOS -u GOARCH go build -o /tmp/gh-aw-linters ./cmd/linters @echo "Running custom linters (largefunc max-lines=$(MAX_LINES))..." - @/tmp/gh-aw-linters $(LINTER_FLAGS) -largefunc.max-lines=$(MAX_LINES) ./cmd/... ./pkg/... + @/tmp/gh-aw-linters $(LINTER_FLAGS) -largefunc.max-lines=$(MAX_LINES) $(LINTER_PACKAGES) # Run incremental linter (only changed files since BASE_REF) # This provides 50-75% faster linting on PRs by only checking changed files diff --git a/gh-aw-wasm b/gh-aw-wasm index 439768d58f6..26f63fc0950 100755 Binary files a/gh-aw-wasm and b/gh-aw-wasm differ diff --git a/pkg/console/console_wasm.go b/pkg/console/console_wasm.go index ac7fb5543dc..49b18f034de 100644 --- a/pkg/console/console_wasm.go +++ b/pkg/console/console_wasm.go @@ -5,6 +5,7 @@ package console import ( "fmt" "os" + "strconv" "strings" ) @@ -38,7 +39,7 @@ func FormatError(err CompilerError) string { if len(err.Context) > 0 && err.Position.Line > 0 { maxLineNum := err.Position.Line + len(err.Context)/2 - lineNumWidth := len(fmt.Sprintf("%d", maxLineNum)) + lineNumWidth := len(strconv.Itoa(maxLineNum)) for i, line := range err.Context { lineNum := err.Position.Line - len(err.Context)/2 + i if lineNum < 1 { diff --git a/pkg/workflow/github_cli_wasm.go b/pkg/workflow/github_cli_wasm.go index f943f72e968..315eeaa10db 100644 --- a/pkg/workflow/github_cli_wasm.go +++ b/pkg/workflow/github_cli_wasm.go @@ -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 { + ctx = context.Background() + } + return exec.CommandContext(ctx, "echo", "gh CLI not available in Wasm") +} + func ForceGHHostEnv(cmd *exec.Cmd, host string) { // no-op in Wasm: gh CLI subprocesses are not run }