You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dace583
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix: enforce consolestderr on wasm and guard native/wasm CI parity (#67634)
* fix: enforce console formatting on wasm and guard CI parity
Mirror the dedicated consolestderr check for WebAssembly and compare native and wasm analyzer sets independently of registry membership. Track the existing contextcancelnotdeferred exception and cover target drift regressions.
Fixes#67609
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add draft ADR for native/wasm linter parity enforcement
* fix: ignore commented CI linter commands and simplify regression
Filter full-line shell comments before both target and analyzer scans. Replace workflow-format-dependent mutation tests with a focused standalone block-scalar regression while retaining the production parity guard.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
The custom analyzers in `pkg/linters` are enforced in CI through `LINTER_FLAGS` lists in `.github/workflows/cgo.yml`, which runs the linters twice: once natively and once with `GOOS=js GOARCH=wasm`. Some analyzers (notably `consolestderr`) were enforced only on the native target, so WebAssembly-only regressions could land undetected (see #67609). The previous guard in `pkg/linters` relied on a hard-coded expected step count, which was brittle: it broke on unrelated workflow edits while still failing to detect analyzer-set drift between the two targets. A known, deliberate exception exists — `contextcancelnotdeferred` is native-only pending the work tracked in #65753 — so the guard must tolerate an explicitly enumerated exception set rather than demanding exact equality.
12
+
13
+
### Decision
14
+
15
+
We will enforce native/WebAssembly analyzer parity by parsing the custom-linter job in `.github/workflows/cgo.yml` and comparing the *combined* analyzer sets (bulk step plus dedicated single-analyzer steps) per target, instead of asserting on a hard-coded step count. The parity test tracks native-only exceptions in an explicit allow-list keyed to tracking issues, and fails both when a target is missing an enforced analyzer and when a stale exception remains after parity is restored. As part of this decision, the `consolestderr -test=false` step is mirrored onto the wasm target using the existing wasm package scope.
16
+
17
+
### Alternatives Considered
18
+
19
+
#### Alternative 1: Keep the hard-coded step-count guard and just add the missing wasm step
20
+
21
+
Minimal diff: add the `consolestderr (wasm)` step and bump the expected step count. This was rejected because it fixes only the current instance of the bug class — the next analyzer added to one target but not the other would still slip through — and the step count keeps producing false failures on unrelated workflow edits.
22
+
23
+
#### Alternative 2: Generate the CI linter steps from the analyzer registry
24
+
25
+
Rather than testing the workflow, derive the `LINTER_FLAGS` lists (and therefore both target steps) from `pkg/linters`' registry at compile/generation time, making drift structurally impossible. This is the stronger guarantee, but it requires a generator plus workflow regeneration plumbing and does not accommodate intentional per-target differences (such as the #65753 exception) without additional metadata. It remains a reasonable future step; parity testing was chosen as the lower-risk increment.
26
+
27
+
#### Alternative 3: Collapse to a single linter invocation covering both targets
28
+
29
+
Run the analyzers once over a union package set and drop per-target steps entirely. Rejected because `GOOS=js GOARCH=wasm` build constraints change which files are analyzed, so a single invocation would lose genuine wasm-specific coverage.
30
+
31
+
### Consequences
32
+
33
+
#### Positive
34
+
35
+
- Native-only or wasm-only enforcement gaps now fail fast in `go test ./pkg/linters` instead of reaching `main`.
36
+
-`consolestderr` violations are caught in WebAssembly-constrained code paths, closing #67609.
37
+
- Removing the hard-coded step count eliminates a recurring source of unrelated CI failures when `cgo.yml` is edited.
38
+
- Deliberate exceptions are documented in code and tied to tracking issues, and stale exceptions are rejected automatically once parity is restored.
39
+
40
+
#### Negative
41
+
42
+
- The test parses CI YAML with string/structure matching, so it is coupled to the current step formatting (bulk flag layout, quoting, `GOOS=js GOARCH=wasm` prefix); reformatting the workflow can require test updates.
43
+
- The native-only exception list is a manually maintained allow-list that must be kept honest by reviewers.
44
+
- Analyzer flags are still duplicated between the native and wasm steps, so additions require touching two places — the test only detects the mistake rather than preventing it.
45
+
46
+
#### Neutral
47
+
48
+
- CI runtime grows slightly with the extra dedicated wasm step.
49
+
-`pkg/linters/README.md` becomes the canonical description of which analyzers are enforced per target and why exceptions exist.
Copy file name to clipboardExpand all lines: pkg/linters/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -376,6 +376,7 @@ _ = typeassertionnil.Analyzer
376
376
377
377
- The package is intentionally organized as a namespace (`pkg/linters/*`) so individual analyzers remain isolated and independently testable.
378
378
- CI enforces selected production analyzers via the native and WebAssembly `LINTER_FLAGS` lists in `.github/workflows/cgo.yml`; `fprintferrorunchecked` is excluded from blocking checks and reported separately as a non-blocking warning on native Go code.
379
+
-`consolestderr` has dedicated blocking steps on both targets. `TestCIEnforcedLintersMatchTargets` compares the combined bulk and dedicated analyzer sets per target, independently of the registry guard; the pre-existing native-only `contextcancelnotdeferred` exception is tracked in #65753 and must be removed when WebAssembly enables it.
379
380
-`typeassertionnil` is registered but excluded from CI enforcement pending a cross-platform enforcement-readiness audit.
380
381
-`unchecked_deferredclose` is registered but excluded from CI enforcement until existing deferred `Close()` findings are remediated.
381
382
-`excessivefuncparams` exposes a `-max-params` analyzer flag and defaults to `8` parameters (`DefaultMaxParams`).
0 commit comments