-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (68 loc) · 2.97 KB
/
Copy pathMakefile
File metadata and controls
84 lines (68 loc) · 2.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
SHELL := /usr/bin/env bash
.SHELLFLAGS := -ec
BINDIR ?= bin
DISTDIR ?= dist
MODULE ?= github.com/pvc-explorer-operator/pvc-explorer-agent
IMAGE ?= pvc-explorer-agent:dev
ROOT ?= /tmp/testdata
PVC ?= my-pvc
RUN_ARGS ?=
.PHONY: help
help: ## Show available targets.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " %-18s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
.PHONY: fmt
fmt: ## Run go fmt.
go fmt ./...
.PHONY: vet
vet: ## Run go vet.
go vet ./...
.PHONY: test
test: ## Run go test.
go test ./...
.PHONY: test-agent
test-agent: ## Run the agent test and build checks used for dependency bumps.
go test ./...
go build -o /tmp/pvc-explorer-agent ./cmd/agent
.PHONY: run-agent
run-agent: ## Run the agent locally with configurable args.
AUTH_TOKEN="$(AUTH_TOKEN)" go run ./cmd/agent -root $(ROOT) -pvc $(PVC) $(RUN_ARGS)
.PHONY: build-agent
build-agent: ## Build the agent binary.
mkdir -p $(BINDIR)
go build -o $(BINDIR)/agent ./cmd/agent
.PHONY: build
build: build-agent ## Build the agent binary.
.PHONY: image
image: ## Build the OCI image from Dockerfile.
docker build -t $(IMAGE) .
.PHONY: check
check: fmt vet test ## Run local quality checks.
.PHONY: sbom
sbom: ## Generate CycloneDX and SPDX SBOM files.
@command -v syft >/dev/null 2>&1 || { echo "syft is not installed. Install from: https://github.com/anchore/syft"; exit 1; }
@mkdir -p $(DISTDIR)
syft scan ./ -o cyclonedx-json > $(DISTDIR)/sbom.cyclonedx.json
syft scan ./ -o spdx-json > $(DISTDIR)/sbom.spdx.json
@echo "Generated $(DISTDIR)/sbom.cyclonedx.json and $(DISTDIR)/sbom.spdx.json"
.PHONY: vuln-check
vuln-check: ## Run govulncheck across Go packages.
@command -v govulncheck >/dev/null 2>&1 || { echo "govulncheck is not installed. Run: go install golang.org/x/vuln/cmd/govulncheck@latest"; exit 1; }
govulncheck ./...
.PHONY: license-check
license-check: ## Verify dependency licenses against an allowlist.
@command -v go-licenses >/dev/null 2>&1 || { echo "go-licenses not installed. Run: go install github.com/google/go-licenses@latest"; exit 1; }
go-licenses check ./... \
--allowed_licenses=MIT,Apache-2.0,BSD-3-Clause,BSD-2-Clause,ISC,MPL-2.0,LGPL-2.1-or-later,LGPL-3.0-or-later,CDDL-1.0 \
--ignore $(MODULE)
@echo "All checked dependencies match the allowlist"
.PHONY: license-report
license-report: ## Export CSV license inventory to dist/licenses.csv.
@command -v go-licenses >/dev/null 2>&1 || { echo "go-licenses not installed. Run: go install github.com/google/go-licenses@latest"; exit 1; }
@mkdir -p $(DISTDIR)
go-licenses csv ./... | grep -v "$(MODULE)" > $(DISTDIR)/licenses.csv
@echo "Generated $(DISTDIR)/licenses.csv"
.PHONY: grype-sbom
grype-sbom: ## Scan the generated SBOM with Grype.
@command -v grype >/dev/null 2>&1 || { echo "grype is not installed. Install from: https://github.com/anchore/grype"; exit 1; }
@test -f $(DISTDIR)/sbom.cyclonedx.json || { echo "SBOM not found. Run: make sbom"; exit 1; }
grype sbom:$(DISTDIR)/sbom.cyclonedx.json