-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (69 loc) · 2.02 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
# Go executable to use, i.e. `make GO=/usr/bin/go1.18`
# Defaults to first found in PATH
GO?=go
include Makefile.*
# ----------------------------------------------------------------------
# Dependencies
# ----------------------------------------------------------------------
# To download more dependencies.
bin/bindl:
mkdir -p ${PWD}/bin
curl --location https://bindl.dev/bootstrap.sh | OUTDIR=${PWD}/bin bash
# To download Go dependencies.
.PHONY: gomod
gomod:
go mod tidy
# ----------------------------------------------------------------------
# Build
# ----------------------------------------------------------------------
bin/snippets: gomod
@${GO} build -o bin/snippets ./app/cmd/
.PHONY: bin/snippets-dev
bin/snippets-dev: bin/goreleaser gomod
bin/goreleaser build \
--output bin/snippets \
--single-target \
--snapshot \
--rm-dist
.PHONY: clean
clean:
@([[ -f "bin/snippets" ]] && rm bin/snippets) || echo
.PHONY: rebuild
rebuild:
@$(MAKE) clean
@$(MAKE) bin/snippets
RUN_FLAGS +=
.PHONY: run
run: rebuild
@./bin/snippets --debug
run-local:
@go run ./app
# ----------------------------------------------------------------------
# Tests
# ----------------------------------------------------------------------
.PHONY: test/unit
test/unit: gomod
${GO} test -race -short -v ./...
# .PHONY: test/integration
# test/integration: gomod
# ${GO} test -race -run ".*[Ii]ntegration.*" -v ./...
#
# .PHONY: test/functional
# test/functional: gomod
# PATH=${PWD}/bin:${PATH} ${MAKE} bin/snippets
# PATH=${PWD}/bin:${PATH} ${GO} test -race -run ".*[Ff]unctional.*" -v ./...
.PHONY: test/all
test/all: gomod
${GO} test -race -v ./...
# ----------------------------------------------------------------------
# Lint
# ----------------------------------------------------------------------
.PHONY: lint
lint: bin/golangci-lint
bin/golangci-lint run
.PHONY: lint/fix
lint/fix: bin/golangci-lint
bin/golangci-lint run --fix
.PHONY: lint/gh-actions
lint/gh-actions: bin/golangci-lint
bin/golangci-lint run --out-format github-actions