-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (98 loc) · 3.12 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Makefile - use `make` or `make help` to get a list of commands.
#
# Note - Comments inside this makefile should be made using a single
# hashtag `#`, lines with double hash-tags will be the messages that
# printed in the help command
# Name of the current directory
PROJECTNAME="iracelog-wamp-router"
# List of all Go-files to be processed
GOFILES=$(wildcard *.go)
# Redirecting error output to a file, acts as logs that can
# be referenced if needed
STDERR=/tmp/$(PROJECTNAME)-stderr.txt
# Docker image variables
IMAGE := $(PROJECTNAME)
VERSION := latest
# Ensures firing a blank `make` command default to help
.DEFAULT_GOAL := help
# Make is verbose in Linux. Make it silent
MAKEFLAGS += --silent
.PHONY: help
## `help`: Generates this help dialog for the Makefile
help: Makefile
echo
echo " Commands available in \`"$(PROJECTNAME)"\`:"
echo
sed -n 's/^[ \t]*##//p' $< | column -t -s ':' | sed -e 's/^//'
echo
PRECOMMIT_VERSION="3.0.4"
## `local-setup`: Setup development environment locally
.PHONY: pre-commit
pre-commit:
wget -O pre-commit.pyz https://github.com/pre-commit/pre-commit/releases/download/v${PRECOMMIT_VERSION}/pre-commit-${PRECOMMIT_VERSION}.pyz
python3 pre-commit.pyz install
python3 pre-commit.pyz install --hook-type commit-msg
rm pre-commit.pyz
.PHONY: local-setup
## `local-setup`: Setup development environment locally
local-setup:
echo " > Ensuring directory is a git repository"
git init &> /dev/null
pre-commit install
# Will install missing dependencies
.PHONY: install
## `install`: Fetch dependencies needed to run `iracelog-wamp-router`
install:
echo " > Getting dependencies..."
go get -v $(get)
go mod tidy
.PHONY: codestyle
## :
## `codestyle`: Run code formatter(s)
codestyle:
golangci-lint run --fix
.PHONY: lint
## `lint`: Run linters and check code-style
lint:
golangci-lint run
# No `help` message for this command - designed to be consumed internally
.PHONY: --test-runner
--test-runner:
go test ./... -race -covermode=atomic -coverprofile=./coverage/coverage.txt
go tool cover -html=./coverage/coverage.txt -o ./coverage/coverage.html
.PHONY: test
## :
## `test`: Run all tests
test: export TEST_MODE=complete
test: --test-runner
.PHONY: fast-tests
## `fast-tests`: Selectively run fast tests
fast-tests: export TEST_MODE=fast
fast-tests: --test-runner
.PHONY: slow-tests
## `slow-tests`: Selectively run slow tests
slow-tests: export TEST_MODE=slow
slow-tests: --test-runner
.PHONY: test-suite
## `test-suite`: Check code style, run linters and ALL tests
test-suite: export TEST_MODE=complete
test-suite: lint test
.PHONY: run
## :
## `run`: Run `iracelog-wamp-router` in production mode
run: export production_mode=production
run: export __BUILD_MODE__=production
run:
go run main.go $(q)
.PHONY: run-debug
## `run-debug`: Run `iracelog-wamp-router` in debug mode
run-debug: export debug_mode=debug
run-debug: export __BUILD_MODE__=debug
run-debug:
go run main.go $(q)
.PHONY: release-tag
## `release-tag`: Create a tag to trigger a release. (`make release-tag v=v0.1.0` for example)
release-tag:
echo " > Creating release $(v)"
git tag -a $(v) -m "Release $(v)"
git push origin $(v)