diff --git a/Makefile b/Makefile deleted file mode 100644 index 32c219d..0000000 --- a/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -GREEN := $(shell tput -Txterm setaf 2) -YELLOW := $(shell tput -Txterm setaf 3) -WHITE := $(shell tput -Txterm setaf 7) -CYAN := $(shell tput -Txterm setaf 6) -RESET := $(shell tput -Txterm sgr0) - -GOTESTSUM_VERSION := v1.7.0 -STATICCHECK_VERSION := 2022.1 - -# Suppress CGO compiler warnings -export CGO_CFLAGS=-w - -.PHONY: all build test - -all: help - -## Targets: - -build: ## Build your project and put the output binary in out/bin/ - @mkdir -p out/bin - @go build -o out/bin/ . - -clean: ## Clean up task related files - @rm -fr ./out - @rm -f ./report.xml ./profile.cov - -verify: ## Verify dependencies - @go mod verify - @go mod download - -lint: ## Run linters - @go install honnef.co/go/tools/cmd/staticcheck@${STATICCHECK_VERSION} - - @go mod tidy - @git diff --exit-code go.mod - - @staticcheck ./... - -test: ## Run tests - @go install gotest.tools/gotestsum@${GOTESTSUM_VERSION} - @gotestsum -- -coverprofile=profile.cov ./... - -coverage: test ## Generate coverage report - @go tool cover -html=profile.cov - -help: ## Show this help - @echo '' - @echo 'Usage:' - @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' - @echo '' - @echo 'Targets:' - @awk 'BEGIN {FS = ":.*?## "} { \ - if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ - else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ - }' $(MAKEFILE_LIST) diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..a23d5ab --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,64 @@ +version: "3" + +vars: + TARGET: iSMC + GIT_LAST_TAG: + sh: git describe --abbrev=0 --tags 2>/dev/null || echo latest + GIT_HEAD_COMMIT: + sh: git rev-parse --short HEAD 2>/dev/null || echo unknown + GIT_TAG_COMMIT: + sh: git rev-parse --short {{.GIT_LAST_TAG}} 2>/dev/null || echo unknown + GIT_MODIFIED1: + sh: git diff {{.GIT_HEAD_COMMIT}} {{.GIT_TAG_COMMIT}} --quiet 2>/dev/null || echo .dev + GIT_MODIFIED2: + sh: git diff --quiet 2>/dev/null || echo .dirty + GIT_MODIFIED: + sh: echo "{{.GIT_MODIFIED1}}{{.GIT_MODIFIED2}}" + BUILD_DATE: + sh: date -u '+%Y-%m-%dT%H:%M:%SZ' + +env: + CGO_ENABLED: 1 + +tasks: + default: + cmds: + - task: update + - task: build + + update: + cmds: + - go get -u + - go mod tidy + + check: + cmds: + - gomajor list + + fmt: + cmds: + - gci write . + - gofumpt -l -w . + + build: + cmds: + - task: update + - task: fmt + - go build -trimpath -pgo=auto -ldflags="-s -w -X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -o {{.TARGET}} + + build-debug: + env: + CGO_ENABLED: 1 + cmds: + - task: update + - task: fmt + - go build -ldflags="-X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -race -o {{.TARGET}} + + lint: + cmds: + - task: fmt + - golangci-lint run --timeout 5m + + release: + cmds: + - goreleaser release --clean -p 4