fix: Adjust Makefile tagets to use dependencies (#1259)

It was getting slow to run `make gen` and other operations,
but this resolves it by targeting files properly.
This commit is contained in:
Kyle Carberry
2022-05-02 13:23:13 -05:00
committed by GitHub
parent 2293d7efd1
commit dacc025cf3
+15 -26
View File
@@ -2,27 +2,21 @@ INSTALL_DIR=$(shell go env GOPATH)/bin
GOOS=$(shell go env GOOS) GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH) GOARCH=$(shell go env GOARCH)
bin: # First target is the default for `make`.
goreleaser build --snapshot --rm-dist build: dist
.PHONY: bin
build: site/out bin
.PHONY: build .PHONY: build
# Runs migrations to output a dump of the database. # Runs migrations to output a dump of the database.
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql) coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
go run coderd/database/dump/main.go go run coderd/database/dump/main.go
.PHONY: coderd/database/dump.sql
# Generates Go code for querying the database. # Generates Go code for querying the database.
coderd/database/generate: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql) coderd/database/querier.go: coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
coderd/database/generate.sh coderd/database/generate.sh
.PHONY: coderd/database/generate
apitypings/generate: site/src/api/types.ts # This is called "dist" to target the output directory for binaries.
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts dist: site/out $(find -not -path './vendor/*' -type f -name '*.go') go.mod go.sum
cd site && yarn run format:types goreleaser build --snapshot --rm-dist
.PHONY: apitypings/generate
fmt/prettier: fmt/prettier:
@echo "--- prettier" @echo "--- prettier"
@@ -40,8 +34,7 @@ fmt/terraform: $(wildcard *.tf)
fmt: fmt/prettier fmt/terraform fmt: fmt/prettier fmt/terraform
.PHONY: fmt .PHONY: fmt
gen: coderd/database/generate peerbroker/proto provisionersdk/proto provisionerd/proto apitypings/generate 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
.PHONY: gen
install: build install: build
@echo "--- Copying from bin to $(INSTALL_DIR)" @echo "--- Copying from bin to $(INSTALL_DIR)"
@@ -53,44 +46,40 @@ lint:
golangci-lint run golangci-lint run
.PHONY: lint .PHONY: lint
peerbroker/proto: peerbroker/proto/peerbroker.proto peerbroker/proto/peerbroker.pb.go: peerbroker/proto/peerbroker.proto
protoc \ protoc \
--go_out=. \ --go_out=. \
--go_opt=paths=source_relative \ --go_opt=paths=source_relative \
--go-drpc_out=. \ --go-drpc_out=. \
--go-drpc_opt=paths=source_relative \ --go-drpc_opt=paths=source_relative \
./peerbroker/proto/peerbroker.proto ./peerbroker/proto/peerbroker.proto
.PHONY: peerbroker/proto
provisionerd/proto: provisionerd/proto/provisionerd.proto provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
protoc \ protoc \
--go_out=. \ --go_out=. \
--go_opt=paths=source_relative \ --go_opt=paths=source_relative \
--go-drpc_out=. \ --go-drpc_out=. \
--go-drpc_opt=paths=source_relative \ --go-drpc_opt=paths=source_relative \
./provisionerd/proto/provisionerd.proto ./provisionerd/proto/provisionerd.proto
.PHONY: provisionerd/proto
provisionersdk/proto: provisionersdk/proto/provisioner.proto provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
protoc \ protoc \
--go_out=. \ --go_out=. \
--go_opt=paths=source_relative \ --go_opt=paths=source_relative \
--go-drpc_out=. \ --go-drpc_out=. \
--go-drpc_opt=paths=source_relative \ --go-drpc_opt=paths=source_relative \
./provisionersdk/proto/provisioner.proto ./provisionersdk/proto/provisioner.proto
.PHONY: provisionersdk/proto
release: site/out site/out: $(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
goreleaser release --snapshot --rm-dist --skip-sign
.PHONY: release
site/out:
./scripts/yarn_install.sh ./scripts/yarn_install.sh
cd site && yarn typegen cd site && yarn typegen
cd site && yarn build cd site && yarn build
# Restores GITKEEP files! # Restores GITKEEP files!
git checkout HEAD site/out git checkout HEAD site/out
.PHONY: site/out
site/src/api/typesGenerated.ts: $(shell find codersdk -type f -name '*.go')
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
cd site && yarn run format:types
test: test:
gotestsum -- -v -short ./... gotestsum -- -v -short ./...