github.com/arsham/gitrelease@v0.3.2-0.20221207124258-6867180b2c2d/Makefile (about) 1 help: ## Show help messages. 2 @grep -E '^[0-9a-zA-Z_-]+:(.*?## .*)?$$' $(MAKEFILE_LIST) | sed 's/^Makefile://' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 3 4 run="." 5 dir="./..." 6 short="-short" 7 flags="" 8 timeout=1m 9 build_tag=$(shell git describe --abbrev=0 --tags) 10 current_sha=$(shell git rev-parse --short HEAD) 11 12 .PHONY: install 13 install: ## Install gitrelease. 14 @go install -trimpath -ldflags="-s -w -X main.version=$(build_tag) -X main.currentSha=$(current_sha)" 15 16 .PHONY: unit_test 17 unit_test: ## Run unit tests. You can set: [run, timeout, short, dir, flags]. Example: make unit_test flags="-race". 18 @go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags) 19 20 .PHONY: unit_test_watch 21 unit_test_watch: ## Run unit tests in watch mode. You can set: [run, timeout, short, dir, flags]. Example: make unit_test flags="-race". 22 @echo "running tests on $(run). waiting for changes..." 23 @-zsh -c "go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags); repeat 100 printf '#'; echo" 24 @reflex -d none -r "(\.go$$)|(go.mod)|(\.sql$$)" -- zsh -c "go mod tidy; go test -trimpath --timeout=$(timeout) $(short) $(dir) -run $(run) $(flags); repeat 100 printf '#'" 25 26 .PHONY: lint 27 lint: ## list the code 28 go fmt ./... 29 go vet ./... 30 golangci-lint run ./... 31 32 .PHONY: ci_tests 33 ci_tests: ## Run tests for CI. 34 go test -trimpath --timeout=10m -failfast -v -tags=integration -race -covermode=atomic -coverprofile=coverage.out ./... 35 36 .PHONY: dependencies 37 dependencies: ## Install dependencies requried for development operations. 38 @go install github.com/cespare/reflex@latest 39 @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 40 @go install github.com/psampaz/go-mod-outdated@latest 41 @go install github.com/jondot/goweight@latest 42 @go get -t -u golang.org/x/tools/cmd/cover 43 @go get -t -u github.com/sonatype-nexus-community/nancy@latest 44 @go get -u ./... 45 @go mod tidy 46 47 .PHONY: run 48 run: ## Run the application. More like: make run args="update user" 49 @go run . $(args) 50 51 .PHONY: clean 52 clean: ## Clean test caches and tidy up modules. 53 @go clean -testcache 54 @go mod tidy 55 56 .PHONY: coverage 57 coverage: ## Show the test coverage on browser. 58 go test -covermode=count -coverprofile=coverage.out -tags=integration ./... 59 go tool cover -func=coverage.out | tail -n 1 60 go tool cover -html=coverage.out 61 62 .PHONY: audit 63 audit: ## Audit the code for updates, vulnerabilities and binary weight. 64 go list -u -m -json all | go-mod-outdated -update -direct 65 go list -json -m all | nancy sleuth 66 goweight | head -n 20