This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
100 lines (71 loc) · 2.96 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/make -f
GOBIN ?= $(GOPATH)/BINARY_NAME
VERSION := $(shell echo $(shell git describe --tags 2> /dev/null || echo "dev-$(shell git describe --always)") | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
BINARY_NAME = server
ARM = arm
MY_ARCH = $(shell go env GOARCH)
export GO111MODULE = on
###############################################################################
### Build ###
###############################################################################
all: lint build test
build:
@cd ./web_res && tsc
@go build -o ${BINARY_NAME}
clean:
ifneq ("$(wildcard ./web_res/dist/)", "")
@rm -rf ./web_res/dist/*
endif
ifneq ("$(wildcard ${BINARY_NAME})", "")
@rm ${BINARY_NAME}
endif
ifneq ("$(wildcard coverage.html)", "")
@rm coverage.html
endif
ifneq ("$(wildcard coverage.out)", "")
@rm coverage.out
endif
ifneq ("$(wildcard serviceWorker.js)", "")
@rm -f serviceWorker.js
endif
ifneq ("$(wildcard serviceWorker.js.map)", "")
@rm -f serviceWorker.js.map
endif
@sudo rm -rf static/
@go clean
.PHONY: build clean
###############################################################################
### Linting ###
###############################################################################
markdownLintImage=tmknom/markdownlint
containerMarkdownLint=$(PROJECT_NAME)-markdownlint
containerMarkdownLintFix=$(PROJECT_NAME)-markdownlint-fix
lint:
@golangci-lint run -c ./.golangci.yml --out-format=tab --issues-exit-code=0
@# @if $(DOCKER) ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then $(DOCKER) start -a $(containerMarkdownLint); else $(DOCKER) run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi
FIND_ARGS := -name '*.go' -type f -not -path "./sample_txs*" -not -path "*.git*" -not -path "./build_report/*" -not -path "./scripts*" -not -name '*.pb.go'
format:
@find . $(FIND_ARGS) | xargs gofmt -w -s
@find . $(FIND_ARGS) | xargs goimports -w -local github.com/aljo242/shmeeload.xyz
.PHONY: lint format
###############################################################################
### Testing ###
###############################################################################
test: test-unit
test-unit:
# cannot use "-race" flag on ARM systems
ifeq ($(MY_ARCH), $(ARM))
@go test -v -coverprofile=coverage.out
else
@go test -v -race -coverprofile=coverage.out
endif
@go tool cover -html coverage.out -o coverage.html
.PHONY: test test-unit
###############################################################################
### Commands ###
###############################################################################
run: build
sudo ./${BINARY_NAME}
.PHONY: run