gomodoro/Makefile
Ian Fijolek c057514cb7
Some checks failed
continuous-integration/drone Build is passing
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing
Reduce coverage target
2024-10-18 14:23:42 -07:00

51 lines
1.2 KiB
Makefile

VERSION ?= $(shell git describe --tags --dirty)
GOFILES = *.go go.mod go.sum
APP_NAME = gomodoro
# Multi-arch targets are generated from this
TARGET_ALIAS = $(APP_NAME)-linux-amd64 $(APP_NAME)-linux-arm $(APP_NAME)-linux-arm64 $(APP_NAME)-darwin-amd64
TARGETS = $(addprefix dist/,$(TARGET_ALIAS))
#
# Default make target will run tests
.DEFAULT_GOAL = test
# Build all static Minitor binaries
.PHONY: all
all: $(TARGETS)
# Build app for the current machine
$(APP_NAME): $(GOFILES)
@echo Version: $(VERSION)
go build -ldflags '-X "main.version=${VERSION}"' -o $(APP_NAME)
.PHONY: build
build: $(APP_NAME)
# Run app for the current machine
.PHONY: run
run: $(APP_NAME)
./$(APP_NAME)
# Run all tests
.PHONY: test
test:
go test -coverprofile=coverage.out
go tool cover -func=coverage.out
@go tool cover -func=coverage.out | awk -v target=50.0% \
'/^total:/ { print "Total coverage: " $$3 " Minimum coverage: " target; if ($$3+0.0 >= target+0.0) print "ok"; else { print "fail"; exit 1; } }'
# Installs pre-commit hooks
.PHONY: install-hooks
install-hooks:
pre-commit install --install-hooks
# Runs pre-commit checks on files
.PHONY: check
check:
pre-commit run --all-files
.PHONY: clean
clean:
rm -f ./$(APP_NAME)
rm -f ./coverage.out
rm -fr ./dist