mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Remove goreleaser in favor of build scripts (#2143)
This commit is contained in:
@@ -1,15 +1,54 @@
|
||||
.DEFAULT_GOAL := build
|
||||
|
||||
# Use a single bash shell for each job, and immediately exit on failure
|
||||
SHELL := bash
|
||||
.SHELLFLAGS = -ceu
|
||||
.ONESHELL:
|
||||
|
||||
# This doesn't work on directories.
|
||||
# See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
INSTALL_DIR=$(shell go env GOPATH)/bin
|
||||
GOOS=$(shell go env GOOS)
|
||||
GOARCH=$(shell go env GOARCH)
|
||||
VERSION=$(shell ./scripts/version.sh)
|
||||
|
||||
bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
||||
@echo "== This builds binaries for command-line usage."
|
||||
@echo "== This builds slim binaries for command-line usage."
|
||||
@echo "== Use \"make build\" to embed the site."
|
||||
goreleaser build --snapshot --rm-dist --single-target
|
||||
|
||||
build: dist/artifacts.json
|
||||
mkdir -p ./dist
|
||||
rm -rf ./dist/coder-slim_*
|
||||
./scripts/build_go_slim.sh \
|
||||
--version "$(VERSION)" \
|
||||
--output ./dist/ \
|
||||
linux:amd64,armv7,arm64 \
|
||||
windows:amd64,arm64 \
|
||||
darwin:amd64,arm64
|
||||
.PHONY: bin
|
||||
|
||||
build: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
||||
rm -rf ./dist
|
||||
mkdir -p ./dist
|
||||
|
||||
# build slim artifacts and copy them to the site output directory
|
||||
./scripts/build_go_slim.sh \
|
||||
--version "$(VERSION)" \
|
||||
--output ./dist/ \
|
||||
linux:amd64,armv7,arm64 \
|
||||
windows:amd64,arm64 \
|
||||
darwin:amd64,arm64
|
||||
|
||||
# build not-so-slim artifacts with the default name format
|
||||
./scripts/build_go_matrix.sh \
|
||||
--version "$(VERSION)" \
|
||||
--output ./dist/ \
|
||||
--archive \
|
||||
--package-linux \
|
||||
linux:amd64,armv7,arm64 \
|
||||
windows:amd64,arm64 \
|
||||
darwin:amd64,arm64
|
||||
.PHONY: build
|
||||
|
||||
# Runs migrations to output a dump of the database.
|
||||
@@ -24,16 +63,14 @@ dev:
|
||||
./scripts/develop.sh
|
||||
.PHONY: dev
|
||||
|
||||
dist/artifacts.json: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
||||
goreleaser release --snapshot --rm-dist --skip-sign
|
||||
|
||||
fmt/prettier:
|
||||
@echo "--- prettier"
|
||||
cd site
|
||||
# Avoid writing files in CI to reduce file write activity
|
||||
ifdef CI
|
||||
cd site && yarn run format:check
|
||||
yarn run format:check
|
||||
else
|
||||
cd site && yarn run format:write
|
||||
yarn run format:write
|
||||
endif
|
||||
.PHONY: fmt/prettier
|
||||
|
||||
@@ -49,20 +86,34 @@ ifdef CI
|
||||
else
|
||||
shfmt -w $(shell shfmt -f .)
|
||||
endif
|
||||
.PHONY: fmt/shfmt
|
||||
|
||||
fmt: fmt/prettier fmt/terraform fmt/shfmt
|
||||
.PHONY: fmt
|
||||
|
||||
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
|
||||
mkdir -p $(INSTALL_DIR)
|
||||
@echo "--- Copying from bin to $(INSTALL_DIR)"
|
||||
cp -r ./dist/coder-$(GOOS)_$(GOOS)_$(GOARCH)*/* $(INSTALL_DIR)
|
||||
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
|
||||
install: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
|
||||
@output_file="$(INSTALL_DIR)/coder"
|
||||
|
||||
@if [[ "$(GOOS)" == "windows" ]]; then
|
||||
@output_file="$${output_file}.exe"
|
||||
@fi
|
||||
|
||||
@echo "-- Building CLI for $(GOOS) $(GOARCH) at $$output_file"
|
||||
|
||||
./scripts/build_go.sh \
|
||||
--version "$(VERSION)" \
|
||||
--output "$$output_file" \
|
||||
--os "$(GOOS)" \
|
||||
--arch "$(GOARCH)"
|
||||
|
||||
@echo
|
||||
.PHONY: install
|
||||
|
||||
lint: lint/shellcheck lint/go
|
||||
.PHONY: lint
|
||||
|
||||
lint/go:
|
||||
golangci-lint run
|
||||
@@ -72,6 +123,7 @@ lint/go:
|
||||
lint/shellcheck: $(shell shfmt -f .)
|
||||
@echo "--- shellcheck"
|
||||
shellcheck --external-sources $(shell shfmt -f .)
|
||||
.PHONY: lint/shellcheck
|
||||
|
||||
peerbroker/proto/peerbroker.pb.go: peerbroker/proto/peerbroker.proto
|
||||
protoc \
|
||||
@@ -99,28 +151,28 @@ provisionersdk/proto/provisioner.pb.go: provisionersdk/proto/provisioner.proto
|
||||
|
||||
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
|
||||
./scripts/yarn_install.sh
|
||||
cd site && yarn typegen
|
||||
cd site && yarn build
|
||||
cd site
|
||||
yarn typegen
|
||||
yarn build
|
||||
# Restores GITKEEP files!
|
||||
git checkout HEAD site/out
|
||||
git checkout HEAD out
|
||||
|
||||
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk -type f -name '*.go')
|
||||
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
|
||||
cd site && yarn run format:types
|
||||
cd site
|
||||
yarn run format:types
|
||||
|
||||
.PHONY: test
|
||||
test: test-clean
|
||||
gotestsum -- -v -short ./...
|
||||
.PHONY: test
|
||||
|
||||
.PHONY: test-postgres
|
||||
test-postgres: test-clean
|
||||
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \
|
||||
-covermode=atomic -coverprofile="gotests.coverage" -timeout=30m \
|
||||
-coverpkg=./...,github.com/coder/coder/codersdk \
|
||||
-count=1 -race -failfast
|
||||
.PHONY: test-postgres
|
||||
|
||||
|
||||
.PHONY: test-postgres-docker
|
||||
test-postgres-docker:
|
||||
docker run \
|
||||
--env POSTGRES_PASSWORD=postgres \
|
||||
@@ -138,7 +190,8 @@ test-postgres-docker:
|
||||
-c fsync=off \
|
||||
-c synchronous_commit=off \
|
||||
-c full_page_writes=off
|
||||
.PHONY: test-postgres-docker
|
||||
|
||||
.PHONY: test-clean
|
||||
test-clean:
|
||||
go clean -testcache
|
||||
.PHONY: test-clean
|
||||
|
||||
Reference in New Issue
Block a user