-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (42 loc) · 1.93 KB
/
Makefile
File metadata and controls
49 lines (42 loc) · 1.93 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
.PHONY: build test gate docker-build run smoke-buildinfo
# Build-time metadata injected into instant.dev/common/buildinfo via -ldflags.
# Override on the make line if needed. GIT_SHA falls back to "dev" when not
# in a git checkout (e.g. CI tarball builds).
GIT_SHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev)
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
VERSION ?= dev
build:
go build ./...
test:
go test ./... -race -count=1
# PR/deploy gate: runs EXACTLY what .github/workflows/deploy.yml runs as its
# test gate (`go test ./... -short -count=1`, see the deploy.yml "Run unit
# tests" step), preceded by build + vet as a fast-fail. A green `make gate`
# locally == a green CI test step — the local gate cannot pass while CI fails.
gate:
go build ./...
go vet ./...
go test ./... -short -count=1
@echo "gate: green — matches deploy.yml test step"
docker-build:
docker build -f Dockerfile -t instant-provisioner:local \
--build-arg GIT_SHA=$(GIT_SHA) \
--build-arg BUILD_TIME=$(BUILD_TIME) \
--build-arg VERSION=$(VERSION) \
..
run:
go run .
# Verifies the -ldflags injection wires through to instant.dev/common/buildinfo.
# Builds the smoke helper with override values and asserts they appear at
# runtime. CI runs this on every PR to catch a regression where someone
# breaks the ldflag path.
smoke-buildinfo:
@tmpdir=$$(mktemp -d) && \
go build -ldflags "-X instant.dev/common/buildinfo.GitSHA=smoke-sha -X instant.dev/common/buildinfo.BuildTime=smoke-time -X instant.dev/common/buildinfo.Version=smoke-ver" \
-o $$tmpdir/smoke ./cmd/smoke-buildinfo && \
out=$$($$tmpdir/smoke) && \
echo "$$out" | grep -q "GitSHA=smoke-sha" || (echo "FAIL: $$out" && exit 1) && \
echo "$$out" | grep -q "BuildTime=smoke-time" || (echo "FAIL: $$out" && exit 1) && \
echo "$$out" | grep -q "Version=smoke-ver" || (echo "FAIL: $$out" && exit 1) && \
echo "smoke-buildinfo: OK ($$out)" && \
rm -rf $$tmpdir