CNTRLPLANE-4008: feat: add hypershiftlinter golangci-lint plugin - #9237
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Skipping CI for Draft Pull Request. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change adds a Sequence Diagram(s)sequenceDiagram
participant PullRequest
participant GitHubActions
participant Makefile
participant HypershiftLinterPlugin
participant GolangCILint
PullRequest->>GitHubActions: change linter-related paths
GitHubActions->>Makefile: run make test-linter
Makefile->>HypershiftLinterPlugin: execute analyzer tests
Makefile->>HypershiftLinterPlugin: build plugin with CGO enabled
GolangCILint->>HypershiftLinterPlugin: call New with settings
HypershiftLinterPlugin-->>GolangCILint: return configured analyzers
Mergeability Score: ⚪ Minimal · up to This change adds and tests an opt-in linting plugin without changing existing lint enforcement; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
4d80587 to
d2da990
Compare
d2da990 to
a2056a8
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bryan-cox The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…uite
Address review feedback on the hypershiftlinter analyzers:
- testcasename: looksLikeTestCaseMap now requires the value struct to
declare at least one recognized test field, matching the corroboration
looksLikeTestCaseStruct already applies. Plain lookup/fixture maps such
as map[string]struct{ Addr string }{...} are no longer flagged.
- contextbackground: exempt AfterSuite alongside BeforeSuite and the
Synchronized*Suite hooks, since it is the same suite-level teardown hook
with no per-spec context.
Add testdata fixtures covering both cases.
Signed-off-by: Bryan Cox <brcox@redhat.com>
Commit-Message-Assisted-by: Claude (via Claude Code)
Document why the plugin exists (machine-enforced test conventions), the 7 analyzers and their scopes, how the plugin is built and run, and the intentionally staged rollout that lands the plugin and its tests before enforcement is enabled. Signed-off-by: Bryan Cox <brcox@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
f4cfd7d to
91e3068
Compare
|
/lgtm |
|
/verified later @bryan-cox |
|
Scheduling tests matching the |
|
@bryan-cox: This PR has been marked to be verified later by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/override ci/prow/e2e-aks |
|
Overrode e2e, this is just linter changes. |
|
@bryan-cox: Overrode contexts on behalf of bryan-cox: ci/prow/e2e-aks, ci/prow/e2e-aws, ci/prow/e2e-aws-upgrade-hypershift-operator, ci/prow/e2e-kubevirt-aws-ovn-reduced, ci/prow/e2e-v2-aws, ci/prow/e2e-v2-azure-self-managed, ci/prow/e2e-v2-gke DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/hold Revision 91e3068 was retested 3 times: holding |
|
/override "ci/prow/e2e-v2-azure-self-managed" These tests are failing outside this PR and these most recent failures are not from this PR. Moving this PR forward so I can work on enabling the linter and fixing the linter issues. |
|
/hold cancel |
|
@bryan-cox: Overrode contexts on behalf of bryan-cox: ci/prow/e2e-kubevirt-aws-ovn-reduced, ci/prow/e2e-v2-azure-self-managed DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/override "Red Hat Konflux / hypershift-operator-enterprise-contract / hypershift-operator-main" |
|
/override "Red Hat Konflux / hypershift-operator-main-enterprise-contract / hypershift-operator-main" |
|
@bryan-cox: Overrode contexts on behalf of bryan-cox: Red Hat Konflux / hypershift-operator-enterprise-contract / hypershift-operator-main DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@bryan-cox: Overrode contexts on behalf of bryan-cox: Red Hat Konflux / hypershift-operator-main-enterprise-contract / hypershift-operator-main DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@bryan-cox: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
4f411bd
into
openshift:main
What this PR does / why we need it:
Adds the
hypershiftlintergolangci-lint v2 Go plugin: a framework plus 7 static-analysis analyzers that enforce test conventions from TESTING.md and test/e2e/v2/AGENTS.md. This PR introduces and unit-tests the analyzers only — it does not enable enforcement yet. Enablement (wiring into.golangci.yml/make lint) and the mechanical fix-up of existing violations are deferred to a follow-up PR (#9271) so that:hack/tools/hypershiftlinter.soandmake test-linterland onmainfirst, so the CI workflow that runs the analyzers' own unit tests (test-linter.yaml/test-linter-reusable.yaml) can actually execute on subsequent PRs — a brand-new reusable workflow can't get a green pre-merge run on the PR that introduces it, since GitHub resolvesuses: ...@mainand thepull_requesttrigger from the base branch.Commit 1 — Vendor
analysistest:Promotes
golang.org/x/toolsfrom indirect to direct inhack/tools/go.modand vendors theanalysistest,checker,diff,testenv, andtxtarpackages needed by the analyzer test suites.Commit 2 — Plugin framework:
plugin.go(BuildAnalyzerswith optional enable list via settings) andcmd/plugin/main.go(golangci-lint plugin entry point). Builds as a Go shared library (.so) viago build -buildmode=plugin. Adds thehypershiftlinter.sobuild target, an opt-inhypershift-lint-alltarget, and atest-lintertarget to the Makefile. Does not touchmake lint/lint-fix— enforcement is intentionally deferred to #9271.Commit 3 — Analyzers:
7 analyzers split by scope:
testcasename,testfuncnameguestcluster,contextbackground,vacuouspass,ipv6url,sippyannotationEach analyzer has
analysistest-based unit tests with good/badtestdata/fixtures.Commit 4 — CI workflows:
test-linter.yaml(caller, path-filtered tohack/tools/hypershiftlinter/**) andtest-linter-reusable.yaml(runsmake test-linter, i.e.go test ./hypershiftlinter/analyzers/...). NamedUnit Tests (HyperShift Linter)to match the existingUnit Testscheck naming convention. Also switcheslint-reusable.yamlfrom copying pre-built runner-image tools to anactions/cachestep keyed onMakefile + go.mod + go.sum + hypershiftlinter source, avoiding the version-mismatch failures that occur when the pre-built golangci-lint host binary and a source-built plugin disagree ongolang.org/x/tools.Which issue(s) this PR fixes:
Fixes CNTRLPLANE-4008
Special notes for your reviewer:
.so) viago build -buildmode=plugin. Plugin and golangci-lint host binary must be compiled from the samehack/tools/go.mod— agolang.org/x/toolsversion mismatch causesplugin.Open()to fail at runtime.hypershiftlinteris not enabled in this PR —.golangci.ymlandmake lintare unchanged frommain.make hypershift-lint-allexists as an opt-in target for manually running the analyzers against the current tree.make test-linterruns the analyzers' own unit tests and passes locally with all 7 analyzer packages green..golangci.yml/make lintand fixes all resulting test-naming violations. It depends on this PR merging first sohypershiftlinter.soexists.Checklist:
Summary by CodeRabbit
New Features
CI
Documentation
Tests