Skip to content

Commit

Permalink
dev(dx): lint improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed Sep 1, 2020
1 parent 903abf8 commit d048746
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: golangci-lint
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ script: ./test.sh
jobs:
include:
- stage: linting
before_script: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
script: make lint
after_success: echo "Linting check succeeded"
after_failure: echo "Linting check failed. Run make lint to check it locally"
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ Following the targets that can be used to test your changes locally.
|--- |--- |--- |
| make go-test | Runs go tests | no |
| make test| Runs tests in shell (`./test.sh`) | yes |
| make lint | Check the code implementation | yes |
| make lint | Run [golangci][golangci] lint checks | yes |
| make lint-fix | Run [golangci][golangci] to automatically perform fixes | no |
| make test-coverage | Run coveralls to check the % of code covered by tests | yes |
| make check-testdata | Checks if the testdata dir is updated with the latest changes | yes |
| make test-e2e-local | Runs the CI e2e tests locally | no |
Expand Down Expand Up @@ -134,3 +135,4 @@ KubeBuilder and the related repositories. See

Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md).

[golangci]:https://github.com/golangci/golangci-lint
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,24 @@ generate: ## Update/generate all mock data. You should run this commands to upda
.PHONY: generate-testdata
generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/kubebuilder
GO111MODULE=on ./generate_testdata.sh

.PHONY: lint
lint: ## Run code lint checks
./scripts/verify.sh
lint: golangci-lint ## Run golangci lint checks
@$(GOLANGCI_LINT) run

lint-fix: golangci-lint ## Run golangci lint to automatically perform fixes
@$(GOLANGCI_LINT) run --fix

golangci-lint:
ifeq (, $(shell which golangci-lint))
@{ \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.29.0 ;\
}
GOLANGCI_LINT=$(shell go env GOPATH)/bin/golangci-lint
else
GOLANGCI_LINT=$(shell which golangci-lint)
endif

##@ Tests

Expand Down
21 changes: 0 additions & 21 deletions scripts/verify.sh

This file was deleted.

0 comments on commit d048746

Please sign in to comment.