提交 53b37e2b 编写于 作者: M Medya Ghazizadeh 提交者: Sharif Elgamal

Separate make lint targets for developers vs travis (#4852)

* Lowering memory for golangci-lint

* ci 2 jobs , gogc 5

* change ci jobs number

* added a new make target for ci and for developers

* reuse golint options for two targets
上级 65dd2d0d
......@@ -48,9 +48,15 @@ KERNEL_VERSION ?= 4.16.14
GO_VERSION ?= $(shell go version | cut -d' ' -f3 | sed -e 's/go//')
GOLINT_VERSION ?= v1.17.1
# Limit number of default jobs, to avoid the CI builds running out of memory
GOLINT_JOBS ?= 1
GOLINT_JOBS ?= 4
# see https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint
GOLINT_GOGC ?= 10
GOLINT_GOGC ?= 8
# options for lint (golangci-lint)
GOLINT_OPTIONS = --deadline 4m \
--build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
--enable goimports,gocritic,golint,gocyclo,interfacer,misspell,nakedret,stylecheck,unconvert,unparam \
--exclude 'variable on range scope.*in function literal|ifElseChain'
export GO111MODULE := on
......@@ -80,6 +86,7 @@ MINIKUBE_TEST_FILES := ./cmd/... ./pkg/...
# npm install -g markdownlint-cli
MARKDOWNLINT ?= markdownlint
MINIKUBE_MARKDOWN_FILES := README.md docs CONTRIBUTING.md CHANGELOG.md
MINIKUBE_BUILD_TAGS := container_image_ostree_stub containers_image_openpgp
......@@ -278,15 +285,16 @@ out/linters/golangci-lint:
mkdir -p out/linters
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b out/linters $(GOLINT_VERSION)
# this one is meant for local use
.PHONY: lint
lint: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go out/linters/golangci-lint
./out/linters/golangci-lint run ${GOLINT_OPTIONS} ./...
# lint-ci is slower version of lint and is meant to be used in ci (travis) to avoid out of memory leaks.
.PHONY: lint-ci
lint-ci: pkg/minikube/assets/assets.go pkg/minikube/translate/translations.go out/linters/golangci-lint
GOGC=${GOLINT_GOGC} ./out/linters/golangci-lint run \
--concurrency ${GOLINT_JOBS} \
--deadline 4m \
--build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
--enable goimports,gocritic,golint,gocyclo,interfacer,misspell,nakedret,stylecheck,unconvert,unparam \
--exclude 'variable on range scope.*in function literal|ifElseChain' \
./...
--concurrency ${GOLINT_JOBS} ${GOLINT_OPTIONS} ./...
.PHONY: reportcard
reportcard:
......
......@@ -20,10 +20,10 @@ exitcode=0
echo "= go mod ================================================================"
go mod download 2>&1 | grep -v "go: finding" || true
go mod tidy -v && echo ok || ((exitcode+=2))
go mod tidy -v && echo ok || ((exitcode += 2))
echo "= make lint ============================================================="
make -s lint && echo ok || ((exitcode+=4))
make -s lint-ci && echo ok || ((exitcode += 4))
echo "= boilerplate ==========================================================="
readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python)
......@@ -32,24 +32,24 @@ missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR}
if [[ -n "${missing}" ]]; then
echo "boilerplate missing: $missing"
echo "consider running: ${BDIR}/fix.sh"
((exitcode+=4))
((exitcode += 4))
else
echo "ok"
fi
echo "= schema_check =========================================================="
go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode+=8))
go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8))
echo "= go test ==============================================================="
cov_tmp="$(mktemp)"
readonly COVERAGE_PATH=./out/coverage.txt
echo "mode: count" > "${COVERAGE_PATH}"
echo "mode: count" >"${COVERAGE_PATH}"
pkgs=$(go list -f '{{ if .TestGoFiles }}{{.ImportPath}}{{end}}' ./cmd/... ./pkg/... | xargs)
go test \
-tags "container_image_ostree_stub containers_image_openpgp" \
-covermode=count \
-coverprofile="${cov_tmp}" \
${pkgs} && echo ok || ((exitcode+=16))
tail -n +2 "${cov_tmp}" >> "${COVERAGE_PATH}"
${pkgs} && echo ok || ((exitcode += 16))
tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}"
exit "${exitcode}"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册