generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 182
Add makefile entries for api-lint #1384
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,5 @@ jobs: | |
persist-credentials: false | ||
- name: Set up Go | ||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # tag=v5.5.0 | ||
- name: Install Golang CI Lint | ||
run: go install github.com/golangci/golangci-lint/v2/cmd/[email protected] | ||
- name: Build KAL | ||
run: golangci-lint custom | ||
- name: run api linter | ||
run: ./bin/golangci-kube-api-linter run -c ./.golangci-kal.yml ./... | ||
- name: Run API Linter | ||
run: make api-lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,8 +160,12 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes | |
ci-lint: golangci-lint | ||
$(GOLANGCI_LINT) run --timeout 15m0s | ||
|
||
.PHONY: api-lint | ||
api-lint: golangci-api-lint | ||
$(GOLANGCI_API_LINT) run -c .golangci-kal.yml --timeout 15m0s ./... | ||
|
||
.PHONY: verify | ||
verify: vet fmt-verify generate ci-lint verify-all | ||
verify: vet fmt-verify generate ci-lint api-lint verify-all | ||
git --no-pager diff --exit-code config api client-go | ||
|
||
.PHONY: verify-crds | ||
|
@@ -365,6 +369,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize | |
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen | ||
ENVTEST ?= $(LOCALBIN)/setup-envtest | ||
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint | ||
GOLANGCI_API_LINT = $(LOCALBIN)/golangci-kube-api-linter | ||
HELM = $(PROJECT_DIR)/bin/helm | ||
YQ = $(PROJECT_DIR)/bin/yq | ||
KUBECTL_VALIDATE = $(PROJECT_DIR)/bin/kubectl-validate | ||
|
@@ -399,6 +404,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. | |
$(GOLANGCI_LINT): $(LOCALBIN) | ||
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) | ||
|
||
.PHONY: golangci-api-lint | ||
golangci-api-lint: golangci-lint $(GOLANGCI_API_LINT) ## Download golangci-lint locally if necessary before building KAL | ||
$(GOLANGCI_API_LINT): | ||
$(GOLANGCI_LINT) custom | ||
|
||
.PHONY: yq | ||
yq: ## Download yq locally if necessary. | ||
GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on go install github.com/mikefarah/yq/[email protected] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
make verify
runs as a pre submit check on every PR. now thatapi-lint
was added to the makefile, do you think this workflow is needed?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 wanted to keep it on Github action as:
make verify
later or make prow use a different target, asmake verify
was actually my attempt to add it to the developer workflow as wellwdyt? I think for now it doesn't hurt to have both prow job and the github action running, and we do some followup clean up on the prow job
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.
personally I like to have it in makefile without github workflow which allow users to run it locally in their envs with no surprises later in ci. as you probably noticed we have no github workflows, everything runs through the
make verify
which makes it repeatable in local envs.I think it’s cleaner, but not feeling strongly about it.
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 the benefits of using GitHub actions here (remarkably fast/lightweight presubmits, clearer feedback directly on the PR) has outweighed any potential disadvantages in our experience in Gateway API. I agree that we should also aim to have a
make
task that can verify everything locally as well, but would hate to require the structure of our presubmits to directly match that as it could become quite slow over time. It can be much more efficient to split out parts of the verification into separate presubmits.Uh oh!
There was an error while loading. Please reload this page.
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.
@robscott you touched two different points:
make api-lint
as another pre-submit check that runs in parallel tomake verify
. this is easy to do.let's assume we go with parallelism, so it's either we run another make command in parallel or using github action.
now the question is whether the fact that the action is faster is worth having it (github actions cannot run in local envs, so checks may drift as we make progress).
since we anyway have to wait for the longest pre-submit check which is the tests themselves, when looking at the tradeoff I prefer having an identical setup or at least a way to run it identically locally (e.g.,
make verify api-lint
) rather than having a super fast action, but the other pre-submit checks take long.but again, not feeling very strongly about it. if you feel strongly about having a github action, let's go with that.
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.
As a suggestion, I can remove the
api-lint
fromverify
target, and make the github action callmake api-lint
directly.My addition of api-lint to verify was mostly as @danehans raised correctly that as a developer, sometimes I just do a
make verify
on the repo and expect that all of the validations run.We can probably add to some doc that the
api-lint
is a different target, or eventually create a new target that should be called by prow, and will contain all verify targets butapi-lint
.So a developer doing
make verify
will get the full package, the CI doingmake ci-verify
will do all but api-lint, and api-lint is called by github action.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.
IMHO
api-lint
should be called from theverify
target to simplify the dev UX.