1
1
.DEFAULT_GOAL := build
2
2
3
+ # use a single bash shell for each job, and immediately exit on failure
4
+ SHELL := bash
5
+ .SHELLFLAGS = -ceu
6
+ .ONESHELL :
7
+
8
+ # This doesn't work on directories.
9
+ # See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
10
+ .DELETE_ON_ERROR :
11
+
3
12
INSTALL_DIR =$(shell go env GOPATH) /bin
4
13
GOOS =$(shell go env GOOS)
5
14
GOARCH =$(shell go env GOARCH)
15
+ VERSION =$(shell ./scripts/version.sh)
6
16
7
17
bin : $(shell find . -not -path './vendor/* ' -type f -name '* .go') go.mod go.sum $(shell find ./examples/templates)
8
- @echo " == This builds binaries for command-line usage."
18
+ @echo " == This builds slim binaries for command-line usage."
9
19
@echo " == Use \" make build\" to embed the site."
10
- goreleaser build --snapshot --rm-dist --single-target
11
20
12
- build : dist/artifacts.json
21
+ rm -rf ./dist/coder-slim_*
22
+ ./scripts/build_go_slim.sh \
23
+ --version "$(VERSION)" \
24
+ --output ./dist/ \
25
+ linux:amd64,armv7,arm64 \
26
+ windows:amd64,arm64 \
27
+ darwin:amd64,arm64
28
+ .PHONY : bin
29
+
30
+ build : site/out/index.html $(shell find . -not -path './vendor/* ' -type f -name '* .go') go.mod go.sum $(shell find ./examples/templates)
31
+ rm -rf ./dist
32
+ mkdir -p ./dist
33
+
34
+ # build slim artifacts and copy them to the site output directory
35
+ ./scripts/build_go_slim.sh \
36
+ --version "$(VERSION)" \
37
+ --output ./dist/ \
38
+ linux:amd64,armv7,arm64 \
39
+ windows:amd64,arm64 \
40
+ darwin:amd64,arm64
41
+
42
+ # build not-so-slim artifacts with the default name format
43
+ ./scripts/build_go_matrix.sh \
44
+ --version "$(VERSION)" \
45
+ --output ./dist/ \
46
+ --archive \
47
+ --package-linux \
48
+ linux:amd64,armv7,arm64 \
49
+ windows:amd64,arm64 \
50
+ darwin:amd64,arm64
13
51
.PHONY : build
14
52
15
53
# Runs migrations to output a dump of the database.
24
62
./scripts/develop.sh
25
63
.PHONY : dev
26
64
27
- dist/artifacts.json : site/out/index.html $(shell find . -not -path './vendor/* ' -type f -name '* .go') go.mod go.sum $(shell find ./examples/templates)
28
- goreleaser release --snapshot --rm-dist --skip-sign
29
-
30
65
fmt/prettier :
31
66
@echo " --- prettier"
32
67
# Avoid writing files in CI to reduce file write activity
@@ -49,20 +84,34 @@ ifdef CI
49
84
else
50
85
shfmt -w $(shell shfmt -f .)
51
86
endif
87
+ .PHONY : fmt/shfmt
52
88
53
89
fmt : fmt/prettier fmt/terraform fmt/shfmt
54
90
.PHONY : fmt
55
91
56
92
gen : coderd/database/querier.go peerbroker/proto/peerbroker.pb.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts
93
+ .PHONY : gen
94
+
95
+ install : site/out/index.html $(shell find . -not -path './vendor/* ' -type f -name '* .go') go.mod go.sum $(shell find ./examples/templates)
96
+ @output_file=" $( INSTALL_DIR) /coder"
57
97
58
- install : build
59
- mkdir -p $(INSTALL_DIR )
60
- @echo " --- Copying from bin to $( INSTALL_DIR) "
61
- cp -r ./dist/coder-$(GOOS ) _$(GOOS ) _$(GOARCH ) * /* $(INSTALL_DIR )
62
- @echo " -- CLI available at $( shell ls $( INSTALL_DIR) /coder* ) "
98
+ @if [[ "$(GOOS)" == "windows" ]]; then
99
+ @output_file="$${output_file}.exe"
100
+ @fi
101
+
102
+ @echo "-- Building CLI for $(GOOS) $(GOARCH) at $$output_file"
103
+
104
+ ./scripts/build_go.sh \
105
+ --version "$(VERSION)" \
106
+ --output "$$output_file" \
107
+ --os "$(GOOS)" \
108
+ --arch "$(GOARCH)"
109
+
110
+ @echo
63
111
.PHONY : install
64
112
65
113
lint : lint/shellcheck lint/go
114
+ .PHONY : lint
66
115
67
116
lint/go :
68
117
golangci-lint run
@@ -72,6 +121,7 @@ lint/go:
72
121
lint/shellcheck : $(shell shfmt -f .)
73
122
@echo " --- shellcheck"
74
123
shellcheck --external-sources $(shell shfmt -f .)
124
+ .PHONY : lint/shellcheck
75
125
76
126
peerbroker/proto/peerbroker.pb.go : peerbroker/proto/peerbroker.proto
77
127
protoc \
@@ -108,19 +158,17 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
108
158
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
109
159
cd site && yarn run format:types
110
160
111
- .PHONY : test
112
161
test : test-clean
113
162
gotestsum -- -v -short ./...
163
+ .PHONY : test
114
164
115
- .PHONY : test-postgres
116
165
test-postgres : test-clean
117
166
DB=ci gotestsum --junitfile=" gotests.xml" --packages=" ./..." -- \
118
167
-covermode =atomic -coverprofile="gotests.coverage" -timeout=5m \
119
168
-coverpkg=./...,github.com/coder/coder/codersdk \
120
169
-count=1 -parallel=1 -race -failfast
170
+ .PHONY : test-postgres
121
171
122
-
123
- .PHONY : test-postgres-docker
124
172
test-postgres-docker :
125
173
docker run \
126
174
--env POSTGRES_PASSWORD=postgres \
@@ -134,7 +182,8 @@ test-postgres-docker:
134
182
postgres:11 \
135
183
-c shared_buffers=1GB \
136
184
-c max_connections=1000
185
+ .PHONY : test-postgres-docker
137
186
138
- .PHONY : test-clean
139
187
test-clean :
140
188
go clean -testcache
189
+ .PHONY : test-clean
0 commit comments