-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (46 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
62 lines (46 loc) · 1.97 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
# gitdr, build, test, lint. Release binaries are static and Linux-only.
BINARY := gitdr
PKG := gitdr.io/gitdr
CMD := ./cmd/gitdr
GO ?= go
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X $(PKG)/internal/cli.Version=$(VERSION)
# Tools run via pinned `go run` so they stay out of go.mod (keeps the dep graph minimal).
GOLANGCI_VERSION ?= v2.12.2
GOVULN_VERSION ?= v1.3.0
ACTIONLINT_VERSION ?= v1.7.9
.PHONY: build build-dist test test-integration lint vuln actionlint semgrep image fmt tidy ci clean
build:
CGO_ENABLED=0 $(GO) build -trimpath -ldflags '$(LDFLAGS)' -o bin/$(BINARY) $(CMD)
# Static release binaries: linux/amd64 + linux/arm64. No other targets.
build-dist:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -trimpath -ldflags '$(LDFLAGS)' -o dist/$(BINARY)_linux_amd64 $(CMD)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -trimpath -ldflags '$(LDFLAGS)' -o dist/$(BINARY)_linux_arm64 $(CMD)
test:
$(GO) test ./...
# Needs an object-lock MinIO/S3; set GITDR_TEST_S3_ENDPOINT (and AWS_* creds).
test-integration:
$(GO) test -tags integration -count=1 ./...
lint:
$(GO) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_VERSION) run
vuln:
$(GO) run golang.org/x/vuln/cmd/govulncheck@$(GOVULN_VERSION) ./...
# The mirror's workflows. A bad one only shows up as a red run on a public main, so parse
# them here, where it costs nothing.
actionlint:
$(GO) run github.com/rhysd/actionlint/cmd/actionlint@$(ACTIONLINT_VERSION) -color
# SAST. Requires semgrep on PATH (pip install semgrep / brew install semgrep).
semgrep:
semgrep scan --error
IMAGE ?= gitdr
PLATFORMS ?= linux/amd64,linux/arm64
# Hardened multi-arch image (needs Docker buildx). Append --push to publish.
image:
docker buildx build --platform $(PLATFORMS) --build-arg VERSION=$(VERSION) -t $(IMAGE):$(VERSION) .
fmt:
$(GO) fmt ./...
tidy:
$(GO) mod tidy
ci: tidy fmt lint test vuln actionlint
clean:
rm -rf bin dist