2022-05-02 19:04:45 +00:00
|
|
|
.DEFAULT_GOAL := build
|
|
|
|
|
2022-02-11 04:32:00 +00:00
|
|
|
INSTALL_DIR=$(shell go env GOPATH)/bin
|
2022-02-28 17:16:44 +00:00
|
|
|
GOOS=$(shell go env GOOS)
|
|
|
|
GOARCH=$(shell go env GOARCH)
|
2022-02-11 04:32:00 +00:00
|
|
|
|
2022-05-27 13:34:32 +00:00
|
|
|
bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
2022-05-02 19:04:45 +00:00
|
|
|
@echo "== This builds binaries for command-line usage."
|
|
|
|
@echo "== Use \"make build\" to embed the site."
|
|
|
|
goreleaser build --snapshot --rm-dist --single-target
|
|
|
|
|
|
|
|
build: dist/artifacts.json
|
2022-01-18 21:13:19 +00:00
|
|
|
.PHONY: build
|
|
|
|
|
2022-01-05 15:20:56 +00:00
|
|
|
# Runs migrations to output a dump of the database.
|
2022-03-25 21:07:45 +00:00
|
|
|
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
|
|
|
|
go run coderd/database/dump/main.go
|
2022-01-05 15:20:56 +00:00
|
|
|
|
|
|
|
# Generates Go code for querying the database.
|
2022-05-02 18:23:13 +00:00
|
|
|
coderd/database/querier.go: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
|
2022-04-01 20:45:23 +00:00
|
|
|
coderd/database/generate.sh
|
2022-01-05 15:20:56 +00:00
|
|
|
|
2022-05-18 16:00:20 +00:00
|
|
|
dev:
|
2022-05-17 18:12:14 +00:00
|
|
|
./scripts/develop.sh
|
|
|
|
.PHONY: dev
|
|
|
|
|
2022-05-27 13:34:32 +00:00
|
|
|
dist/artifacts.json: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
2022-05-02 19:04:45 +00:00
|
|
|
goreleaser release --snapshot --rm-dist --skip-sign
|
2022-04-19 00:45:22 +00:00
|
|
|
|
2022-01-04 02:54:27 +00:00
|
|
|
fmt/prettier:
|
|
|
|
@echo "--- prettier"
|
|
|
|
# Avoid writing files in CI to reduce file write activity
|
|
|
|
ifdef CI
|
2022-02-01 21:34:43 +00:00
|
|
|
cd site && yarn run format:check
|
2022-01-04 02:54:27 +00:00
|
|
|
else
|
2022-02-01 21:34:43 +00:00
|
|
|
cd site && yarn run format:write
|
2022-01-04 02:54:27 +00:00
|
|
|
endif
|
|
|
|
.PHONY: fmt/prettier
|
|
|
|
|
2022-04-11 21:06:15 +00:00
|
|
|
fmt/terraform: $(wildcard *.tf)
|
|
|
|
terraform fmt -recursive
|
2022-05-02 19:04:45 +00:00
|
|
|
.PHONY: fmt/terraform
|
2022-04-11 21:06:15 +00:00
|
|
|
|
2022-05-27 17:15:19 +00:00
|
|
|
fmt/shfmt: $(shell shfmt -f .)
|
|
|
|
@echo "--- shfmt"
|
|
|
|
# Only do diff check in CI, errors on diff.
|
|
|
|
ifdef CI
|
|
|
|
shfmt -d $(shell shfmt -f .)
|
|
|
|
else
|
|
|
|
shfmt -w $(shell shfmt -f .)
|
|
|
|
endif
|
|
|
|
|
|
|
|
fmt: fmt/prettier fmt/terraform fmt/shfmt
|
2022-01-05 15:20:56 +00:00
|
|
|
.PHONY: fmt
|
2022-01-08 17:24:02 +00:00
|
|
|
|
2022-05-02 18:23:13 +00:00
|
|
|
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
|
2022-01-08 17:24:02 +00:00
|
|
|
|
2022-04-25 20:24:23 +00:00
|
|
|
install: build
|
2022-05-27 17:15:19 +00:00
|
|
|
mkdir -p $(INSTALL_DIR)
|
2022-02-11 04:32:00 +00:00
|
|
|
@echo "--- Copying from bin to $(INSTALL_DIR)"
|
2022-04-22 20:41:45 +00:00
|
|
|
cp -r ./dist/coder-$(GOOS)_$(GOOS)_$(GOARCH)*/* $(INSTALL_DIR)
|
2022-02-11 04:32:00 +00:00
|
|
|
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
|
|
|
|
.PHONY: install
|
|
|
|
|
2022-05-27 17:15:19 +00:00
|
|
|
lint: lint/shellcheck lint/go
|
|
|
|
|
|
|
|
lint/go:
|
2022-03-28 20:21:00 +00:00
|
|
|
golangci-lint run
|
2022-05-27 17:15:19 +00:00
|
|
|
.PHONY: lint/go
|
|
|
|
|
|
|
|
# Use shfmt to determine the shell files, takes editorconfig into consideration.
|
|
|
|
lint/shellcheck: $(shell shfmt -f .)
|
|
|
|
@echo "--- shellcheck"
|
2022-06-01 19:15:09 +00:00
|
|
|
shellcheck --external-sources $(shell shfmt -f .)
|
2022-03-28 20:21:00 +00:00
|
|
|
|
2022-05-02 18:23:13 +00:00
|
|
|
peerbroker/proto/peerbroker.pb.go: peerbroker/proto/peerbroker.proto
|
2022-01-29 23:52:14 +00:00
|
|
|
protoc \
|
2022-01-11 15:28:41 +00:00
|
|
|
--go_out=. \
|
|
|
|
--go_opt=paths=source_relative \
|
|
|
|
--go-drpc_out=. \
|
|
|
|
--go-drpc_opt=paths=source_relative \
|
2022-01-29 23:52:14 +00:00
|
|
|
./peerbroker/proto/peerbroker.proto
|
2022-01-11 15:28:41 +00:00
|
|
|
|
2022-05-02 18:23:13 +00:00
|
|
|
provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
|
2022-01-29 23:52:14 +00:00
|
|
|
protoc \
|
|
|
|
--go_out=. \
|
|
|
|
--go_opt=paths=source_relative \
|
|
|
|
--go-drpc_out=. \
|
|
|
|
--go-drpc_opt=paths=source_relative \
|
|
|
|
./provisionerd/proto/provisionerd.proto
|
|
|
|
|
2022-05-02 18:23:13 +00:00
|
|
|
provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
|
2022-01-29 23:52:14 +00:00
|
|
|
protoc \
|
2022-01-08 17:24:02 +00:00
|
|
|
--go_out=. \
|
|
|
|
--go_opt=paths=source_relative \
|
|
|
|
--go-drpc_out=. \
|
|
|
|
--go-drpc_opt=paths=source_relative \
|
2022-01-29 23:52:14 +00:00
|
|
|
./provisionersdk/proto/provisioner.proto
|
2022-01-18 21:13:19 +00:00
|
|
|
|
2022-05-04 14:47:48 +00:00
|
|
|
site/out/index.html: $(shell find ./site -not -path './site/node_modules/*' -type f -name '*.tsx') $(shell find ./site -not -path './site/node_modules/*' -type f -name '*.ts') site/package.json
|
2022-02-20 19:52:14 +00:00
|
|
|
./scripts/yarn_install.sh
|
2022-03-18 18:07:08 +00:00
|
|
|
cd site && yarn typegen
|
2022-02-01 21:34:43 +00:00
|
|
|
cd site && yarn build
|
2022-03-08 01:50:37 +00:00
|
|
|
# Restores GITKEEP files!
|
|
|
|
git checkout HEAD site/out
|
2022-05-02 18:23:13 +00:00
|
|
|
|
2022-05-10 07:44:09 +00:00
|
|
|
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk -type f -name '*.go')
|
2022-05-02 18:23:13 +00:00
|
|
|
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
|
|
|
|
cd site && yarn run format:types
|
2022-03-28 19:14:40 +00:00
|
|
|
|
2022-05-20 23:39:51 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: test-clean
|
2022-03-28 20:21:00 +00:00
|
|
|
gotestsum -- -v -short ./...
|
2022-05-20 23:39:51 +00:00
|
|
|
|
|
|
|
.PHONY: test-postgres
|
|
|
|
test-postgres: test-clean
|
|
|
|
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \
|
2022-06-16 16:01:33 +00:00
|
|
|
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \
|
2022-05-20 23:39:51 +00:00
|
|
|
-coverpkg=./...,github.com/coder/coder/codersdk \
|
2022-06-16 16:01:33 +00:00
|
|
|
-count=1 -race -failfast
|
2022-05-20 23:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: test-postgres-docker
|
|
|
|
test-postgres-docker:
|
|
|
|
docker run \
|
|
|
|
--env POSTGRES_PASSWORD=postgres \
|
|
|
|
--env POSTGRES_USER=postgres \
|
|
|
|
--env POSTGRES_DB=postgres \
|
|
|
|
--env PGDATA=/tmp \
|
2022-06-17 19:57:38 +00:00
|
|
|
--tmpfs /tmp \
|
2022-05-20 23:39:51 +00:00
|
|
|
--publish 5432:5432 \
|
|
|
|
--name test-postgres-docker \
|
2022-06-17 19:57:38 +00:00
|
|
|
--restart no \
|
2022-05-20 23:39:51 +00:00
|
|
|
--detach \
|
|
|
|
postgres:11 \
|
|
|
|
-c shared_buffers=1GB \
|
2022-06-17 19:57:38 +00:00
|
|
|
-c max_connections=1000 \
|
|
|
|
-c fsync=off \
|
|
|
|
-c synchronous_commit=off \
|
|
|
|
-c full_page_writes=off
|
2022-05-20 23:39:51 +00:00
|
|
|
|
|
|
|
.PHONY: test-clean
|
|
|
|
test-clean:
|
|
|
|
go clean -testcache
|