2021-12-19 21:39:53 +00:00
|
|
|
#! /usr/bin/make -f
|
|
|
|
|
2022-01-14 14:02:39 +00:00
|
|
|
|
2021-12-19 21:39:53 +00:00
|
|
|
# Go related variables.
|
|
|
|
GOBASE := $(shell pwd)
|
|
|
|
GOBIN := $(GOBASE)/bin
|
|
|
|
|
2022-01-14 14:02:39 +00:00
|
|
|
|
2021-12-19 21:39:53 +00:00
|
|
|
# Go files.
|
|
|
|
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
|
|
|
|
|
2022-01-14 14:02:39 +00:00
|
|
|
|
|
|
|
# Common commands.
|
2021-12-19 21:39:53 +00:00
|
|
|
all: fmt lint test
|
|
|
|
|
|
|
|
test:
|
|
|
|
@echo " > Running unit tests"
|
|
|
|
GOBIN=$(GOBIN) go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
@echo " > Format all go files"
|
|
|
|
GOBIN=$(GOBIN) gofmt -w ${GOFMT_FILES}
|
|
|
|
|
|
|
|
lint-install:
|
|
|
|
ifeq (,$(wildcard test -f bin/golangci-lint))
|
|
|
|
@echo " > Installing golint"
|
|
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s
|
|
|
|
endif
|
|
|
|
|
|
|
|
lint: lint-install
|
|
|
|
@echo " > Running golint"
|
2021-12-22 16:22:21 +00:00
|
|
|
bin/golangci-lint run --timeout=2m
|
|
|
|
|
2022-01-14 14:02:39 +00:00
|
|
|
|
|
|
|
# Assets commands.
|
2021-12-22 16:22:21 +00:00
|
|
|
check:
|
2022-01-14 14:02:39 +00:00
|
|
|
go run cmd/main.go check
|
2021-12-22 16:22:21 +00:00
|
|
|
|
|
|
|
fix:
|
2022-01-14 14:02:39 +00:00
|
|
|
go run cmd/main.go fix
|
2021-12-22 16:22:21 +00:00
|
|
|
|
|
|
|
update-auto:
|
2022-01-14 14:02:39 +00:00
|
|
|
go run cmd/main.go update-auto
|
2021-12-22 16:22:21 +00:00
|
|
|
|
|
|
|
update-manual:
|
2022-01-14 14:02:39 +00:00
|
|
|
go run cmd/main.go update-manual
|
|
|
|
|
|
|
|
|
|
|
|
# Helper commands.
|
|
|
|
add-token:
|
|
|
|
go run cmd/main.go add-token $(token)
|