-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add golangci-lint to the project and fix issues
fix all the issues found by golangci-lint and add it to the project
- Loading branch information
Showing
9 changed files
with
176 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ on: | |
name: build-test-publish | ||
|
||
jobs: | ||
build: | ||
go: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
@@ -20,12 +20,17 @@ jobs: | |
- run: go env | ||
- name: go build | ||
run: go build -v ./... | ||
|
||
- uses: alexellis/setup-arkade@v3 | ||
- uses: alexellis/arkade-get@master | ||
with: | ||
golangci-lint: latest | ||
- name: Lint Go Code | ||
run: | | ||
make lint-go | ||
e2e: | ||
name: e2e tests | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
|
||
needs: [go] | ||
steps: | ||
- uses: ko-build/[email protected] | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
issues: | ||
exclude-dirs: | ||
- vendor | ||
- pkg/provider/gitea/structs | ||
exclude-rules: | ||
# Exclude some linters from running on tests files. | ||
- path: _test\.go | ||
linters: | ||
- gosec | ||
run: | ||
build-tags: | ||
- e2e | ||
linters-settings: | ||
gocritic: | ||
disabled-checks: | ||
- unlambda | ||
errcheck: | ||
exclude-functions: | ||
- (*github.com/tektoncd/pipeline/vendor/go.uber.org/zap.SugaredLogger).Sync | ||
- flag.Set | ||
- logger.Sync | ||
- fmt.Fprintf | ||
- fmt.Fprintln | ||
- (io.Closer).Close | ||
- updateConfigMap | ||
linters: | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
#- containedctx | ||
#- contextcheck | ||
#- cyclop | ||
- decorder | ||
#- depguard | ||
- dogsled | ||
- dupl | ||
- dupword | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- execinquery | ||
- exhaustive | ||
#- exhaustruct | ||
- exportloopref | ||
- forbidigo | ||
- forcetypeassert | ||
#- funlen | ||
#- gci | ||
- ginkgolinter | ||
- gocheckcompilerdirectives | ||
#- gochecknoglobals | ||
- gochecknoinits | ||
- gochecksumtype | ||
#- gocognit | ||
#- goconst | ||
- gocritic | ||
#- gocyclo | ||
- godot | ||
#- godox | ||
#- goerr113 | ||
#- gofmt | ||
- gofumpt | ||
- goheader | ||
- goimports | ||
#- gomnd | ||
#- gomoddirectives | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- gosmopolitan | ||
- govet | ||
- grouper | ||
- importas | ||
#- inamedparam | ||
#- interfacebloat | ||
#- ireturn | ||
#- lll | ||
- loggercheck | ||
#- maintidx | ||
- makezero | ||
- mirror | ||
- misspell | ||
#- musttag | ||
- nakedret | ||
#- nestif | ||
- nilerr | ||
#- nilnil | ||
#- nlreturn | ||
- noctx | ||
#- nolintlint | ||
#- nonamedreturns | ||
- nosprintfhostport | ||
#- paralleltest | ||
#- perfsprint | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- protogetter | ||
- reassign | ||
- revive | ||
#- rowserrcheck | ||
- sloglint | ||
#- sqlclosecheck | ||
- staticcheck | ||
- stylecheck | ||
- tagalign | ||
#- tagliatelle | ||
- tenv | ||
- testableexamples | ||
# - testifylint | ||
#- testpackage | ||
#- thelper | ||
- tparallel | ||
#- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
#- varnamelen | ||
#- wastedassign | ||
- whitespace | ||
#- wrapcheck | ||
#- wsl | ||
- zerologlint |
This file contains 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 |
---|---|---|
@@ -1,16 +1,37 @@ | ||
E2E_TAG ?= e2e | ||
REGISTRY_NAME ?= registry | ||
|
||
e2e-coverage: | ||
GOLANGCI_LINT=golangci-lint | ||
TIMEOUT_UNIT = 20m | ||
GOFUMPT=gofumpt | ||
|
||
e2e-coverage: ## run e2e tests with coverage | ||
@go test -failfast -count=1 -tags=$(E2E_TAG) ./tests -coverpkg=./... -coverprofile /tmp/coverage.out | ||
@go tool cover -func /tmp/coverage.out | ||
e2e: e2e-coverage | ||
|
||
e2e-docker: | ||
e2e-docker: ## run e2e tests with a docker registry started | ||
@if [[ $$(docker ps --filter name=$(REGISTRY_NAME) --format '{{.ID}}') == "" ]]; then \ | ||
echo -n "Starting container $(REGISTRY_NAME) ... "; \ | ||
docker run --name $(REGISTRY_NAME) -p 127.0.0.1:5000:5000 -d registry:2 >/dev/null; \ | ||
echo "done"; \ | ||
fi | ||
make e2e-coverage | ||
@docker rm -f $(REGISTRY_NAME) >/dev/null | ||
|
||
lint: lint-go | ||
lint-go: ## runs go linter on all go files | ||
@echo "Linting go files..." | ||
@$(GOLANGCI_LINT) run ./... --modules-download-mode=vendor \ | ||
--max-issues-per-linter=0 \ | ||
--max-same-issues=0 \ | ||
--timeout $(TIMEOUT_UNIT) | ||
|
||
.PHONY: fumpt ## formats the GO code with gofumpt(excludes vendors dir) | ||
fumpt: | ||
@find internal cmd tests -name '*.go'|xargs -P4 $(GOFUMPT) -w -extra | ||
|
||
.PHONY: help | ||
help: ## print this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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