From ba537ae4490be9cfaf6a2e92cbce6dc56d662ba2 Mon Sep 17 00:00:00 2001 From: Manav Aggarwal Date: Mon, 15 May 2023 15:50:56 -0400 Subject: [PATCH] feat: Improvements to Makefile (#935) Adds option for: - Cleaning testing cache - test both race and without race - lint Adds `--count=1` flag for tests to avoid cached results --- .yamllint.yml | 9 +++++++++ Makefile | 27 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .yamllint.yml diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000000..cd2a9e8293d --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,9 @@ +--- +# Built from docs https://yamllint.readthedocs.io/en/stable/configuration.html +extends: default + +rules: + # 120 chars should be enough, but don't fail if a line is longer + line-length: + max: 120 + level: warning diff --git a/Makefile b/Makefile index 6d855e3be46..c649f6f544b 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ help: Makefile @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' .PHONY: help +## clean: clean testcache +clean: + @echo "--> Clearing testcache" + @go clean --testcache +.PHONY: clean + ## cover: generate to code coverage report. cover: @echo "--> Generating Code Coverage" @@ -14,6 +20,19 @@ cover: @go-acc -o coverage.txt `go list ./...` .PHONY: cover +## lint: Run linters golangci-lint and markdownlint. +lint: + @echo "--> Running golangci-lint" + @golangci-lint run + @echo "--> Running markdownlint" + @markdownlint --config .markdownlint.yaml '**/*.md' + @echo "--> Running hadolint" + @hadolint docker/mockserv.Dockerfile + @echo "--> Running yamllint" + @yamllint --no-warnings . -c .yamllint.yml + +.PHONY: lint + ## test-unit: Running unit tests test-unit: @echo "--> Running unit tests" @@ -23,9 +42,15 @@ test-unit: ## test-unit-race: Running unit tests with data race detector test-unit-race: @echo "--> Running unit tests with data race detector" - @go test -race `go list ./...` + @go test -race -count=1 `go list ./...` .PHONY: test-unit-race +### test-all: Run tests with and without data race +test-all: + @$(MAKE) test-unit + @$(MAKE) test-unit-race +.PHONY: test-all + ## proto-gen: Generate protobuf files. Requires docker. proto-gen: @echo "--> Generating Protobuf files"