Skip to content

Add golangci-lint CI workflow and Makefile target - #1004

Open
parametalol wants to merge 1 commit into
openshift:masterfrom
parametalol:add-golangci-lint
Open

Add golangci-lint CI workflow and Makefile target#1004
parametalol wants to merge 1 commit into
openshift:masterfrom
parametalol:add-golangci-lint

Conversation

@parametalol

@parametalol parametalol commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Add a GitHub Actions workflow (golangci-lint.yaml) that runs golangci-lint on pushes and PRs to master, using golangci/golangci-lint-action@v9 with golangci-lint v2.12
  • Add a make lint target for running golangci-lint locally
  • Add a minimal .golangci.yml config with vendor mode and the standard linter set (errcheck, govet, staticcheck, unused, ineffassign, gosimple)

Test plan

  • Verify the GitHub Actions workflow triggers on a PR to master
  • Run make lint locally and confirm it invokes golangci-lint correctly
  • Confirm vendor directory is not linted

Add a GitHub Actions workflow using golangci/golangci-lint-action@v9
to lint Go code on pushes and PRs to master. Add a `make lint` target
for local use, and a minimal .golangci.yml config with vendor mode
and the standard linter set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: parametalol
Once this PR has been reviewed and has the lgtm label, please assign rhmdnd for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 22, 2026
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Hi @parametalol. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@parametalol

Copy link
Copy Markdown
Author
$ make lint
golangci-lint run ./...
bundle-hack/update_csv.go:37:17: Error return value of `enc.Close` is not checked (errcheck)
	defer enc.Close()
	              ^
cmd/manager/daemon.go:279:25: Error return value of `http.ListenAndServe` is not checked (errcheck)
		go http.ListenAndServe(pprofAddr, mux)
		                     ^
cmd/manager/daemon_util.go:85:15: Error return value of `f.Close` is not checked (errcheck)
	defer f.Close()
	            ^
cmd/manager/logcollector_util.go:115:12: Error return value of `enc.Close` is not checked (errcheck)
		enc.Close()
		        ^
cmd/manager/logcollector_util.go:120:12: Error return value of `pw.Close` is not checked (errcheck)
			pw.Close()
			       ^
cmd/manager/operator.go:105:13: Error return value of `flags.Parse` is not checked (errcheck)
	flags.Parse(args)
	          ^
pkg/common/name.go:25:16: Error return value of `io.WriteString` is not checked (errcheck)
	io.WriteString(hasher, friendlyName)
	             ^
tests/e2e/helpers.go:2158:16: Error return value of `podLogs.Close` is not checked (errcheck)
		podLogs.Close()
		            ^
tests/e2e/helpers.go:2330:21: Error return value of `logFile.Close` is not checked (errcheck)
	defer logFile.Close()
	                  ^
tests/e2e/helpers.go:2335:14: Error return value of `logFile.Sync` is not checked (errcheck)
	logFile.Sync()
	           ^
tests/framework/resource.go:120:56: inline: Call of context.TODO should be inlined (govet)
	_, err := ctx.kubeclient.CoreV1().Namespaces().Create(context.TODO(), namespaceObj, metav1.CreateOptions{})
	                                                     ^
tests/framework/resource.go:129:54: inline: Call of context.TODO should be inlined (govet)
		return ctx.kubeclient.CoreV1().Namespaces().Delete(context.TODO(), ns, opts)
		                                                  ^
bundle-hack/update_csv.go:89:8: ineffectual assignment to ok (ineffassign)
	spec, ok := csv["spec"].(map[string]interface{})
	     ^
bundle-hack/update_csv.go:16:3: S1038: should use log.Fatalf(...) instead of log.Fatal(fmt.Sprintf(...)) (staticcheck)
		log.Fatal(fmt.Sprintf("Error: Failed to read file '%s'", csvFilename))
		^
bundle-hack/update_csv.go:21:3: S1038: should use log.Fatalf(...) instead of log.Fatal(fmt.Sprintf(...)) (staticcheck)
		log.Fatal(fmt.Sprintf("Error: Failed to unmarshal yaml file '%s'", csvFilename))
		^
bundle-hack/update_csv.go:28:3: S1038: should use log.Fatalf(...) instead of log.Fatal(fmt.Sprintf(...)) (staticcheck)
		log.Fatal(fmt.Sprintf("Error: Failed to remofe file '%s'", csvFilename))
		^
bundle-hack/update_csv.go:95:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (staticcheck)
	fmt.Println(fmt.Sprintf("Updating version references from %s to %s", oldVersion, newVersion))
	^
bundle-hack/update_csv.go:105:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (staticcheck)
	fmt.Println(fmt.Sprintf("Updated version references from %s to %s", oldVersion, newVersion))
	^
bundle-hack/update_csv.go:130:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (staticcheck)
	fmt.Println(fmt.Sprintf("Updated the operator image to use icon in %s", iconPath))
	^
cmd/manager/daemon.go:303:46: SA1016: syscall.SIGKILL cannot be trapped (did you mean syscall.SIGTERM?) (staticcheck)
	signal.Notify(sigTermChan, syscall.SIGTERM, syscall.SIGKILL)
	                                           ^
cmd/manager/daemon_util.go:37:2: ST1019: package "k8s.io/apimachinery/pkg/apis/meta/v1" is being imported more than once (staticcheck)
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	^
cmd/manager/daemon_util.go:38:2: ST1019(related information): other import of "k8s.io/apimachinery/pkg/apis/meta/v1" (staticcheck)
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	^
cmd/manager/logcollector.go:43:4: QF1003: could use tagged switch on lastResult (staticcheck)
			if lastResult == -1 || lastResult == 18 {
			^
cmd/manager/loops.go:27:2: ST1019: package "k8s.io/apimachinery/pkg/apis/meta/v1" is being imported more than once (staticcheck)
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	^
cmd/manager/loops.go:28:2: ST1019(related information): other import of "k8s.io/apimachinery/pkg/apis/meta/v1" (staticcheck)
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	^
cmd/manager/loops.go:270:18: SA1019: watch2.NewRetryWatcher is deprecated: use NewRetryWatcherWithContext instead. (staticcheck)
	watcher, err := watch2.NewRetryWatcher(initialVersion, listWatcher)
	               ^
cmd/manager/loops.go:291:2: S1023: redundant return statement (staticcheck)
	return
	^
pkg/common/name.go:29:14: ST1005: error strings should not be capitalized (staticcheck)
		return "", fmt.Errorf("Cannot shorten '%s' with prefix %s", friendlyName, hashPrefix)
		          ^
pkg/common/util.go:535:22: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
	for k, v := range s.ObjectMeta.Labels {
	                   ^
pkg/common/util.go:543:17: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
			Name:      s.ObjectMeta.Name,
			            ^
pkg/common/util.go:544:17: QF1008: could remove embedded field "ObjectMeta" from selector (staticcheck)
			Namespace: s.ObjectMeta.Namespace,
			            ^
pkg/controller/fileintegrity/fileintegrity_controller.go:74:14: QF1008: could remove embedded field "Client" from selector (staticcheck)
	if err := r.Client.Get(context.TODO(), types.NamespacedName{
	           ^
pkg/controller/fileintegrity/fileintegrity_controller.go:82:15: QF1008: could remove embedded field "Client" from selector (staticcheck)
		if err := r.Client.Create(context.TODO(), aideReinitScript()); err != nil {
		           ^
pkg/controller/fileintegrity/fileintegrity_controller.go:88:15: QF1008: could remove embedded field "Client" from selector (staticcheck)
		if err := r.Client.Update(context.TODO(), aideReinitScript()); err != nil {
		           ^
pkg/controller/fileintegrity/fileintegrity_controller.go:233:4: QF1008: could remove embedded field "Metrics" from selector (staticcheck)
	r.Metrics.IncFileIntegrityReinitDaemonsetUpdate()
	 ^
pkg/controller/fileintegrity/fileintegrity_controller.go:523:7: QF1008: could remove embedded field "Metrics" from selector (staticcheck)
				r.Metrics.IncFileIntegrityReinitByDemand()
				 ^
pkg/controller/fileintegrity/fileintegrity_controller.go:526:7: QF1008: could remove embedded field "Metrics" from selector (staticcheck)
				r.Metrics.IncFileIntegrityReinitByConfig()
				 ^
pkg/controller/fileintegrity/fileintegrity_controller.go:562:50: QF1008: could remove embedded field "Time" from selector (staticcheck)
		shouldScheduleAt := instance.CreationTimestamp.Time.Add(delayTime)
		                                              ^
pkg/controller/fileintegrity/fileintegrity_controller.go:624:9: S1005: unnecessary assignment to the blank identifier (staticcheck)
	for i, _ := range daemonSetList.Items {
	      ^
tests/e2e/helpers.go:6:2: ST1019: package "context" is being imported more than once (staticcheck)
	"context"
	^
tests/e2e/helpers.go:7:2: ST1019(related information): other import of "context" (staticcheck)
	goctx "context"
	^
tests/e2e/helpers.go:310:8: SA1019: wait.Poll is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	err = wait.Poll(pollInterval, pollTimeout, func() (bool, error) {
	     ^
tests/e2e/helpers.go:457:17: QF1004: could use strings.ReplaceAll instead (staticcheck)
	newContents := strings.Replace(string(read), nsFrom, nsTo, -1)
	              ^
tests/e2e/helpers.go:621:13: SA1019: wait.PollImmediate is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	pollErr := wait.PollImmediate(time.Second, 5*time.Minute, func() (bool, error) {
	          ^
tests/e2e/helpers.go:734:9: SA1019: wait.PollImmediate is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	return wait.PollImmediate(pollInterval, timeout, daemonSetCallback)
	      ^
tests/e2e/helpers.go:738:9: SA1019: wait.PollImmediate is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	return wait.PollImmediate(pollInterval, timeoutVal, daemonSetCallback)
	      ^
tests/e2e/helpers.go:1261:9: SA1019: wait.Poll is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	err := wait.Poll(interval, timeout, func() (bool, error) {
	      ^
tests/e2e/helpers.go:1289:9: SA1019: wait.Poll is deprecated: This method does not return errors from context, use PollUntilContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release. (staticcheck)
	err := wait.Poll(interval, timeout, func() (bool, error) {
	      ^
tests/e2e/helpers.go:2057:12: ST1005: error strings should not be capitalized (staticcheck)
				return fmt.Errorf("The node '%s' is not ready yet", node.Name)
				      ^
tests/e2e/helpers.go:2066:10: ST1005: error strings should not be capitalized (staticcheck)
		return fmt.Errorf("The nodes were never ready: %s", err)
		      ^
tests/framework/resource.go:12:2: SA1019: "golang.org/x/net/context" is deprecated: Use the standard library context package instead. (staticcheck)
	"golang.org/x/net/context"
	^
tests/e2e/helpers.go:1493:6: func assertNodesUpdatingStarted is unused (unused)
func assertNodesUpdatingStarted(t *testing.T, f *framework.Framework, interval, timeout time.Duration) {
     ^
52 issues:
* errcheck: 10
* govet: 2
* ineffassign: 1
* staticcheck: 38
* unused: 1
make: *** [Makefile:239: lint] Error 1

@vickeybrown

Copy link
Copy Markdown

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2026
@parametalol

Copy link
Copy Markdown
Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@parametalol: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws 4dcb170 link true /test e2e-aws

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

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

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants