forked from mwieser/nullable
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
85 lines (67 loc) · 1.93 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
### -----------------------
# --- Building
### -----------------------
# first is default task when running "make" without args
build:
@$(MAKE) go-generate
@$(MAKE) go-format
@$(MAKE) go-build
@$(MAKE) go-lint
# useful to ensure that everything gets resetuped from scratch
all:
@$(MAKE) clean
@$(MAKE) init
@$(MAKE) build
@$(MAKE) info
@$(MAKE) test
info:
@go version
go-format:
go fmt
go-build:
go build ./...
go-lint:
golangci-lint run --fast
go-generate:
go run -tags scripts scripts/nullable/gen_nullable_types.go
# https://github.com/golang/go/issues/24573
# w/o cache - see "go help testflag"
# use https://github.com/kyoh86/richgo to color
# note that these tests should not run verbose by default (e.g. use your IDE for this)
# TODO: add test shuffling/seeding when landed in go v1.15 (https://github.com/golang/go/issues/28592)
test:
richgo test -cover -race -count=1 ./...
### -----------------------
# --- Initializing
### -----------------------
init:
@$(MAKE) modules
@$(MAKE) tools
@$(MAKE) tidy
@go version
# cache go modules (locally into .pkg)
modules:
go mod download
# https://marcofranssen.nl/manage-go-tools-via-go-modules/
tools:
cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
tidy:
go mod tidy
### -----------------------
# --- Helpers
### -----------------------
clean:
rm -rf tmp
### -----------------------
# --- Special targets
### -----------------------
# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
# ignore matching file/make rule combinations in working-dir
.PHONY: test
# https://unix.stackexchange.com/questions/153763/dont-stop-makeing-if-a-command-fails-but-check-exit-status
# https://www.gnu.org/software/make/manual/html_node/One-Shell.html
# required to ensure make fails if one recipe fails (even on parallel jobs)
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS = -ec