-
Notifications
You must be signed in to change notification settings - Fork 552
Introduce a sanity workflow for checking static linting violations in CI #2346
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
Introduce a sanity workflow for checking static linting violations in CI #2346
Conversation
cc4634d
to
8483185
Compare
Makefile
Outdated
find . -name '*.go' -not -path "./vendor/*" | xargs gofmt -w | ||
find . -name '*.go' -not -path "./vendor/*" | xargs goimports -w |
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.
This likely isn't the greatest structure but I didn't have an immediate answer on how to clean it up.
It looks like we do some combination of the following:
- Not run both of those checks
- Make the list of files spit out by that
find
command a prerequisite and update the xargs command to run both gofmt/goimports references that same set of files.
Explicitly ignore operatorclient generated packages The gofmt/goimport commands are touching generated packages that don't have the proper "//go:generate ..." instructions. Signed-off-by: timflannagan <[email protected]>
…style checks Introduce the ci/sanity GH workflow: - Runs `make vendor` - Runs `make lint` - Ensures that both of those targets don't produce a diff when running `make diff` Signed-off-by: timflannagan <[email protected]>
Run find . -name '*.go' -not -path "./vendor/*" -not -path "./pkg/lib/operatorclient/operatorclientmocks/*" | xargs gofmt -w find . -name '*.go' -not -path "./vendor/*" -not -path "./pkg/lib/operatorclient/operatorclientmocks/*" | xargs goimports -w and commit the results. Signed-off-by: timflannagan <[email protected]>
8483185
to
2246f8a
Compare
@@ -184,6 +184,9 @@ clean: | |||
@rm -rf test/e2e/log | |||
@rm -rf e2e.namespace | |||
|
|||
lint: | |||
find . -name '*.go' -not -path "./vendor/*" -not -path "./pkg/lib/operatorclient/operatorclientmocks/*" | xargs gofmt -w |
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.
Note: mentioned this in the commit, but that operatorclientmocks package doesn't have the //go:generate ...
comment that it looks like gofmt/goimports are configured to ignore, so we'd need to explicitly ignore this path from the find command output.
/approve |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dinhxuanvu, njhale, timflannagan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Manually merging - that unit test is permafailing (#2091). |
/retest-required Please review the full test history for this PR and help us cut down flakes. |
Update the Makefile and introduce a
lint
target. This target is responsible for running bothgofmt
andgoimports
against non-vendor packages in the codebase.Introduce the ci/sanity GH workflow:
make vendor
make lint
make diff
Fix any linting gofmt/goimports linting violations that came up when running the
make lint
target locally.