You've already forked testing-go-code-with-postgres
mirror of
https://github.com/xorcare/testing-go-code-with-postgres.git
synced 2025-06-30 23:23:40 +02:00
Publish an example testing go code with Postgres
This commit is contained in:
52
Makefile
Normal file
52
Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
COVER_FILE ?= coverage.out
|
||||
|
||||
.PHONY: build
|
||||
build: ## Build a command to quickly check compiles.
|
||||
@go build ./...
|
||||
|
||||
.PHONY: check
|
||||
check: lint build test ## Runs all necessary code checks.
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run all tests.
|
||||
@go test -race -count=1 -coverprofile=$(COVER_FILE) ./...
|
||||
@go tool cover -func=$(COVER_FILE) | grep ^total | tr -s '\t'
|
||||
|
||||
.PHONY: test-short
|
||||
test-short: ## Run only unit tests, tests without I/O dependencies.
|
||||
@go test -short ./...
|
||||
|
||||
.PHONY: test-env-up
|
||||
test-env-up: ## Run test environment.
|
||||
@docker-compose up migrate
|
||||
|
||||
.PHONY: test-env-down
|
||||
test-env-down: ## Down and cleanup test environment.
|
||||
@docker-compose down -v
|
||||
|
||||
.PHONY: lint
|
||||
lint: tools ## Check the project with lint.
|
||||
@golangci-lint run \
|
||||
--fix \
|
||||
--disable-all \
|
||||
-E errcheck \
|
||||
-E godot \
|
||||
-E goimports \
|
||||
-E gosimple \
|
||||
-E govet \
|
||||
-E ineffassign \
|
||||
-E misspell \
|
||||
-E staticcheck \
|
||||
-E typecheck \
|
||||
-E unused \
|
||||
-E whitespace \
|
||||
./...
|
||||
|
||||
tools: ## Install all needed tools, e.g.
|
||||
@go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.2
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show help for each of the Makefile targets.
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
Reference in New Issue
Block a user