-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
136 lines (123 loc) · 2.73 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
133
134
135
136
PKG := github.com/ChrisWiegman/kana
VERSION := $(shell git describe --tags || echo "0.0.1")
TIMESTAMP := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
ARGS = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
%:
@:
.PHONY: build
build:
go mod vendor
go$(GO_VERSION) build \
-o ./build/kana \
-ldflags "-s -w -X $(PKG)/internal/cmd.Version=$(VERSION) -X $(PKG)/internal/cmd.Timestamp=$(TIMESTAMP)" \
./cmd/...
.PHONY: build-test-image
build-test-image:
docker build -t kana-test .
.PHONY: change
change:
docker run \
--rm \
--platform linux/amd64 \
--mount type=bind,source=$(PWD),target=/src \
-w /src \
-it \
ghcr.io/miniscruff/changie \
new
.PHONY: changelog
changelog:
docker run \
--rm \
--platform linux/amd64 \
--mount type=bind,source=$(PWD),target=/src \
-w /src \
-it \
ghcr.io/miniscruff/changie \
batch $(call ARGS,defaultstring)
docker run \
--rm \
--platform linux/amd64 \
--mount type=bind,source=$(PWD),target=/src \
-w /src \
-it \
ghcr.io/miniscruff/changie \
merge
.PHONY: clean
clean:
rm -rf \
dist \
vendor \
build
.PHONY: install
install:
go mod vendor
go$(GO_VERSION) install \
-ldflags "-s -X $(PKG)/internal/cmd.Version=$(VERSION) -X $(PKG)/internal/cmd.Timestamp=$(TIMESTAMP)" \
./cmd/...
.PHONY: lint
lint:
@if [ ! -f $GOPATH/bin/gilangci-lint ]; then \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest;\
fi
@golangci-lint \
run
.PHONY: mockery
mockery:
docker \
run \
--rm \
--mount type=bind,source=$(PWD),target=/src \
-w /src/internal/docker \
vektra/mockery \
--all
docker \
run \
--rm \
--mount type=bind,source=$(PWD),target=/src \
-w /src/internal/site \
vektra/mockery \
--all
docker \
run \
--rm \
--mount type=bind,source=$(PWD),target=/src \
-w /src/internal/settings \
vektra/mockery \
--all
.PHONY: update
update:
go get -u ./...
go mod vendor
go mod tidy
.PHONY: snapshot
snapshot:
docker run --rm \
--privileged \
-v $(PWD):/go/src/$(PKG) \
-w /go/src/$(PKG) \
goreleaser/goreleaser \
release \
--clean \
--release-notes=./.changes/$(VERSION).md \
--snapshot
.PHONY: test
test: clean build-test-image
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(PWD):/usr/src/kana \
-w /usr/src/kana \
kana-test
$(MAKE) clean
$(MAKE) install
.PHONY: update-test-snapshot
update-test-snapshot:
go build \
-o ./build/kana \
-buildvcs=false \
-ldflags "-s -w -X github.com/ChrisWiegman/kana/internal/cmd.Version=1.0.0 -X github.com/ChrisWiegman/kana/internal/cmd.Timestamp=2024-03-16_10:50:11PM" \
./cmd/... && \
UPDATE_SNAPS=true go test \
-v \
-timeout 30s\
-cover \
./...