Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (78 loc) · 4.16 KB
/
Copy pathMakefile
File metadata and controls
91 lines (78 loc) · 4.16 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
GOBIN ?= $$(go env GOPATH)/bin
# Safety net: every `go test` inherits a hard timeout so no test run hangs.
# Target-specific -timeout flags still override this. Unknown flags are
# silently ignored by go build/vet, so this is safe to scope to all commands.
export GOFLAGS ?= -timeout=300s
# CGO-free surface guard: asserts every package builds with CGO_ENABLED=0
# except the documented cgo allowlist, so cgo creep fails here rather than at a
# downstream companion publish. See docs/cgo.md.
.PHONY: check-cgo-free
check-cgo-free:
./scripts/check_cgo_free.sh
# Version guard: version/info.codefly.yaml drives composition's
# minimum-codefly-version gate, and nothing else in CI notices when it falls
# behind the published tags. See scripts/check_version_tag.sh.
.PHONY: check-version-tag
check-version-tag:
./scripts/check_version_tag.sh
# go-test-coverage must be the one the workflow's coverage gate runs: at
# @latest the local check answers from whatever upstream tagged that morning,
# so it stops being a verdict on the gate the moment the two diverge — silently,
# because nothing looks broken while they happen to coincide.
# internal/ciguard's TestWorkflowCoverageToolMatchesTheMakefile fails when this
# pin and the action pinned in the workflow disagree.
GO_TEST_COVERAGE_VERSION := v2.20.0
.PHONY: install-go-test-coverage
install-go-test-coverage:
go install github.com/vladopajic/go-test-coverage/v2@$(GO_TEST_COVERAGE_VERSION)
.PHONY: check-coverage
check-coverage: install-go-test-coverage
go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
${GOBIN}/go-test-coverage --config=./.testcoverage.yaml
# buf must be the one CI's schema gate and the proto companion's generator both
# run: a check that answers from a different buf is not a verdict on the gate
# that decides whether a schema lands. internal/ciguard's
# TestWorkflowBufMatchesTheCompanionImage fails when this pin, the workflow's
# buf-setup-action input and companions/proto/Dockerfile disagree.
#
# Invoked through `go run`, so the version is fixed by construction and a stray
# buf on PATH cannot be what answers.
BUF_VERSION := 1.73.0
BUF := go run github.com/bufbuild/buf/cmd/buf@v$(BUF_VERSION)
.PHONY: buf-lint
buf-lint:
cd proto && $(BUF) lint
# `codefly generate proto --local` execs whatever `buf` is on PATH
# (codefly-dev/cli#744), and that buf is the one whose output gets committed.
# `go run` puts nothing on PATH, so the check targets cannot serve that path —
# this installs the same pin where generation will find it.
.PHONY: buf-install
buf-install:
go install github.com/bufbuild/buf/cmd/buf@v$(BUF_VERSION)
# proto/buf.lock pins the BSR commits buf resolves the external schemas from;
# go.mod pins the generated SDKs the Go runtime registers the same descriptors
# from. Only this target moves the first, and go.mod's side moves on its own —
# Dependabot proposes it, and minimum version selection raises it whenever
# another module requiring the same SDK bumps — so buf.lock is the side brought
# back alongside. internal/ciguard's TestProtovalidatePinsAgree is red while
# they disagree.
.PHONY: buf-dep-update
buf-dep-update:
cd proto && $(BUF) dep update
# The remote holding the canonical repo, which is not always `origin`: on a fork
# checkout `origin` is the fork, whose main can be arbitrarily stale, and a
# baseline taken from it reports clean on a real break. Checked, not assumed.
BASE_REMOTE ?= origin
# The baseline is the MERGE BASE, not $(BASE_REMOTE)/main. CI checks out the
# pull request merged into main, so a package main gained after this branch was
# cut is present on both sides there. Compared against main's tip instead, that
# same package is missing from this branch only, and buf reports it as a
# deletion: `make buf-breaking` exits 100 naming a package the branch never
# touched. The merge base is what the branch actually changed, so it answers the
# question CI answers. Fetch first, or the merge base is computed against
# wherever the ref last pointed.
.PHONY: buf-breaking
buf-breaking:
BASE_REMOTE=$(BASE_REMOTE) BUF="$(BUF)" ./scripts/check_proto_breaking.sh
# Companions: build images with scripts (run from core/)
# ./companions/scripts/build_companions.sh