diff --git a/.github/workflows/vmware-go-kcl-v2-ci.yml b/.github/workflows/vmware-go-kcl-v2-ci.yml index 5f2b6a9..bcdd40e 100755 --- a/.github/workflows/vmware-go-kcl-v2-ci.yml +++ b/.github/workflows/vmware-go-kcl-v2-ci.yml @@ -40,7 +40,7 @@ jobs: - name: Lint shell: bash run: | - make lint + make lint-docker - name: Scan shell: bash diff --git a/Makefile b/Makefile index 78026f1..0823e84 100644 --- a/Makefile +++ b/Makefile @@ -44,9 +44,9 @@ scan: ## - execute static code analysis lint: ## - runs golangci-lint @ ./_support/scripts/ci.sh lint -.PHONY: ci-lint-docker +.PHONY: lint-docker lint-docker: ## - runs golangci-lint with docker container - @ docker run --rm -v "$(shell pwd)":/app -w /app ${LINT_IMAGE} golangci-lint run ${LINT_FLAGS} + @ ./_support/scripts/ci.sh lintDocker .PHONY: sonar-scan sonar-scan: ## - start sonar qube locally with docker (you will need docker installed in your machine) diff --git a/_support/scripts/ci.sh b/_support/scripts/ci.sh index e53d247..beaba8a 100755 --- a/_support/scripts/ci.sh +++ b/_support/scripts/ci.sh @@ -31,14 +31,25 @@ function go_format() { function lint() { # golangci-lint run --enable-all -D forbidigo -D gochecknoglobals -D gofumpt -D gofmt -D nlreturn - golangci-lint run \ - --skip-files=_mock.go \ - --disable=golint \ - --skip-dirs=test \ - --fast \ - --timeout=600s \ - --verbose \ - "$(local_go_pkgs)" + + golangci-lint run \ + --skip-files=_mock.go \ + --skip-dirs=test \ + --skip-dirs=internal \ + --timeout=600s \ + --verbose +} + +function lintDocker() { + lintVersion="1.41.1" + lintImage="golangci/golangci-lint:v$lintVersion-alpine" + + docker run --rm -v "${PWD}":/app -w /app "$lintImage" golangci-lint run \ + --skip-files=_mock.go \ + --skip-dirs=test \ + --skip-dirs=internal \ + --timeout=600s \ + --verbose } function test() { @@ -99,6 +110,7 @@ case "$1" in fmtcheck) checkfmt ;; format) go_format ;; lint) lint ;; + lintDocker) lintDocker ;; unittest) test ;; scan) scanast ;; *) usage ;;