-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Pass patch file to golangci-lint, align with CI #2365
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2365 +/- ##
==========================================
+ Coverage 53.66% 53.69% +0.02%
==========================================
Files 48 48
Lines 14201 14201
==========================================
+ Hits 7621 7625 +4
+ Misses 6340 6338 -2
+ Partials 240 238 -2
Continue to review full report at Codecov.
|
60f5a7f
to
22a81bc
Compare
@@ -29,7 +29,8 @@ all: test lint verify-codegen update-crds debian-image | |||
|
|||
.PHONY: lint | |||
lint: ## Run linter | |||
docker run --pull always --rm -v $(shell pwd):/kubernetes-ingress -w /kubernetes-ingress -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH)/pkg:/go/pkg golangci/golangci-lint:latest golangci-lint --color always run -v | |||
@git fetch | |||
docker run --pull always --rm -v $(shell pwd):/kubernetes-ingress -w /kubernetes-ingress -v $(shell go env GOCACHE):/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH)/pkg:/go/pkg golangci/golangci-lint:latest git diff -p origin/master > /tmp/diff.patch && golangci-lint --color always run -v --new-from-patch=/tmp/diff.patch |
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.
shall we make the diff against the parent branch rather than the master?
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.
I think usually the patch file is generated against the main branch? That 99% of the time is also the parent I guess 😅
I'm not sure how you would easily get the parent, I found this on stackoverflow https://stackoverflow.com/questions/3161204/how-to-find-the-nearest-parent-of-a-git-branch but the proposed solution doesn't work for me, and the second one looks like a lot of "magic" 😄
I was trying to reproduce the behavior of golangci-lint, which gets the patch file for a PR from GitHub API, like this https://github.com/nginxinc/kubernetes-ingress/pull/2365.patch
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.
👍
fef7a62
to
6b8fe91
Compare
This should align local runs of
golangci-lint
with CI runs.