Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (50 loc) · 2.4 KB
/
Copy pathMakefile
File metadata and controls
59 lines (50 loc) · 2.4 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
.PHONY: build install test fmt fmt-check vet test-tools test-all local
# build produces a local ./fleetops binary (gitignored) — run it with
# ./fleetops, or `make install` to put fleetops on your PATH instead.
build:
go build -o fleetops ./cmd/fleetops
# install builds and links fleetops into $GOBIN (or $GOPATH/bin, usually
# ~/go/bin) — make sure that directory is on your PATH. Same as
# `go install github.com/jitokim/fleetops/cmd/fleetops@latest` from
# outside a clone.
install:
go install ./cmd/fleetops
test:
go test ./... -count=1 -race
fmt:
gofmt -l .
# fmt-check FAILS if any file is unformatted, unlike `fmt` (a lister that exits
# 0). This is the same gate root-test.yml runs (`test -z "$(gofmt -l .)"`);
# `local` uses it so a quick pre-push check catches what CI would reject.
fmt-check:
@test -z "$$(gofmt -l .)" || { echo "gofmt: files need formatting:"; gofmt -l .; exit 1; }
vet:
go vet ./...
# test-tools runs the gates for the standalone modules under tools/, which the
# root `test` target CANNOT reach: each is its own Go module, so the root
# `go test ./...` stops at the module boundary and never descends. Without this
# the only way to see what CI sees is to cd into the module by hand.
#
# Deliberately mirrors dupdetect-test.yml's three steps exactly, including the
# gofmt form that FAILS rather than merely listing. The root `fmt` target above
# is `gofmt -l .`, which prints offenders and still exits 0 — fine as a local
# lister, useless as a gate, and CI does not rely on it (root-test.yml runs its
# own `test -z "$(gofmt -l .)"`). Repeating that shape here would have made
# `make test-tools` pass on code CI rejects, which is the specific way a local
# target becomes worse than no target at all.
test-tools:
@for m in tools/*/; do \
echo "==> $$m"; \
( cd "$$m" && \
{ test -z "$$(gofmt -l .)" || { gofmt -l .; exit 1; }; } && \
go vet ./... && \
go test ./... -count=1 -race ) || exit 1; \
done
# test-all is what to run before pushing: the root module and every tools/
# module, the same set CI covers across its two workflows.
test-all: test test-tools
# local runs the root-module CI checks in one command — the quick pre-push
# loop, mirroring oh-my-graph's `make local`. Checks only; it does NOT run the
# app (keeping fleetops's no-runner-creep identity). Use `make test-all` before
# pushing to also cover the standalone tools/ modules.
local: fmt-check vet build test