-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (89 loc) · 2.67 KB
/
Makefile
File metadata and controls
108 lines (89 loc) · 2.67 KB
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
INSTALL_DIR=$(shell go env GOPATH)/bin
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
bin:
goreleaser build --snapshot --rm-dist
.PHONY: bin
build: site/out bin
.PHONY: build
# Runs migrations to output a dump of the database.
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
go run coderd/database/dump/main.go
.PHONY: coderd/database/dump.sql
# Generates Go code for querying the database.
coderd/database/generate: fmt/sql coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
coderd/database/generate.sh
.PHONY: coderd/database/generate
apitypings/generate: site/src/api/types.ts
go run scripts/apitypings/main.go > site/src/api/types-generated.ts
cd site && yarn run format:types
.PHONY: apitypings/generate
fmt/prettier:
@echo "--- prettier"
# Avoid writing files in CI to reduce file write activity
ifdef CI
cd site && yarn run format:check
else
cd site && yarn run format:write
endif
.PHONY: fmt/prettier
fmt/sql: $(wildcard coderd/database/queries/*.sql)
for fi in coderd/database/queries/*.sql; do \
npx sql-formatter \
--language postgresql \
--lines-between-queries 2 \
--tab-indent \
$$fi \
--output $$fi; \
done
sed -i 's/@ /@/g' ./coderd/database/queries/*.sql
fmt/terraform: $(wildcard *.tf)
terraform fmt -recursive
fmt: fmt/prettier fmt/sql fmt/terraform
.PHONY: fmt
gen: coderd/database/generate peerbroker/proto provisionersdk/proto provisionerd/proto apitypings/generate
.PHONY: gen
install: bin
@echo "--- Copying from bin to $(INSTALL_DIR)"
cp -r ./dist/coder_$(GOOS)_$(GOARCH)/* $(INSTALL_DIR)
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
.PHONY: install
lint:
golangci-lint run
.PHONY: lint
peerbroker/proto: peerbroker/proto/peerbroker.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./peerbroker/proto/peerbroker.proto
.PHONY: peerbroker/proto
provisionerd/proto: provisionerd/proto/provisionerd.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto
.PHONY: provisionerd/proto
provisionersdk/proto: provisionersdk/proto/provisioner.proto
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisionersdk/proto/provisioner.proto
.PHONY: provisionersdk/proto
release:
goreleaser release --snapshot --rm-dist --skip-sign
.PHONY: release
site/out:
./scripts/yarn_install.sh
cd site && yarn typegen
cd site && yarn build
# Restores GITKEEP files!
git checkout HEAD site/out
.PHONY: site/out
test:
gotestsum -- -v -short ./...