Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (114 loc) · 5.54 KB
/
Copy pathMakefile
File metadata and controls
139 lines (114 loc) · 5.54 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
BINARY_NAME=bomly
LITE_BUILD_TAGS=bomly_external_syft,bomly_external_grype
GOLANGCI_LINT_VERSION=v2.15.0
GO_LICENSES_VERSION=v1.6.0
GOPATH_BIN=$(shell go env GOPATH)/bin
EXE_SUFFIX=$(if $(filter Windows_NT,$(OS)),.exe,)
GOLANGCI_LINT=$(GOPATH_BIN)/golangci-lint$(EXE_SUFFIX)
GUARDCHECK=bin/guardcheck$(EXE_SUFFIX)
FUZZTIME?=60s
.PHONY: build build-full build-lite fmt fmt-check lint guardcheck install-hooks test smoke fuzz verify run generate assurance-catalog assurance-report sdk-local sdk-pinned sdk-status benchmark benchmark-samples benchmark-report licenses
build: build-full build-lite
build-full:
go build -o bin/$(BINARY_NAME)$(EXE_SUFFIX) ./cmd/bomly
build-lite:
go build -tags "$(LITE_BUILD_TAGS)" -o bin/$(BINARY_NAME)-lite$(EXE_SUFFIX) ./cmd/bomly
fmt:
go run ./internal/tools/gofmtcheck -w
fmt-check:
go run ./internal/tools/gofmtcheck
$(GOLANGCI_LINT): Makefile
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
# lint is every static house rule: golangci-lint (with the depguard import
# bans and forbidigo identifier bans in .golangci.yml) and the structural
# analyzers in internal/tools/guardcheck. CI runs the same three steps.
lint: $(GOLANGCI_LINT) guardcheck
$(GOLANGCI_LINT) run
# composition_lite.go is the one file under internal/ behind the lite
# build tags, and golangci-lint sees one tag set per run.
$(GOLANGCI_LINT) run --build-tags "$(LITE_BUILD_TAGS)" ./internal/composition/...
# The structural house rules run as a vet tool, so package scope and build
# tags come from the go command and results ride the build cache. A package
# pattern that matches nothing is only a warning to go vet, and a rule that
# reached nothing reads exactly like a rule that passed, so reach is asserted
# first (ADR-0044 rule 4).
guardcheck:
go build -o $(GUARDCHECK) ./internal/tools/guardcheck
@test -n "$$(go list ./internal/...)" || { echo "guardcheck: no packages under internal/" >&2; exit 1; }
@test -n "$$(go list ./internal/detectors/...)" || { echo "guardcheck: no packages under internal/detectors/" >&2; exit 1; }
go vet -vettool=$(GUARDCHECK) -nodeinsert -purlstring ./internal/...
go vet -vettool=$(GUARDCHECK) -attributed ./internal/detectors/...
go vet -tags "$(LITE_BUILD_TAGS)" -vettool=$(GUARDCHECK) -nodeinsert -purlstring ./internal/composition/...
install-hooks:
git config core.hooksPath .githooks
test:
go test ./...
smoke:
go test -tags "smoke" ./test/smoke/ -v -count=1 -timeout 15m $(if $(ARGS),$(ARGS),)
fuzz:
FUZZTIME="$(FUZZTIME)" scripts/run-fuzz.sh
# verify runs every check CI gates on, locally, for when you want the full
# picture before pushing. The pre-push hook runs only `make test`; CI runs the
# rest on the pull request, and the smoke suite runs once it is approved.
#
# SMOKE=1 adds the network-driven smoke suite. Generated-docs drift is checked
# too: it is a CI job, and it fails for edits that look unrelated to it.
verify:
$(MAKE) fmt-check
$(MAKE) lint
go vet ./...
go vet -tags "$(LITE_BUILD_TAGS)" ./...
# The smoke suite is behind a build tag, so `go vet ./...` never compiles
# it. Running it needs the network and several minutes; compiling it costs
# a second and catches the failure that actually happens -- a smoke file
# left un-updated by a change everything else absorbed.
go vet -tags smoke ./test/smoke/...
go build ./...
go build -tags "$(LITE_BUILD_TAGS)" ./...
go test ./...
$(MAKE) generate
@git diff --quiet -- docs/ || { \
echo "verify: generated docs drifted; commit the result of 'make generate'" >&2; \
git --no-pager diff --stat -- docs/ >&2; \
exit 1; \
}
@if [ "$(SMOKE)" = "1" ]; then $(MAKE) smoke; fi
@echo "verify: passed"
# Build against a local bomly-sdk checkout (SDK=<dir>, default ../bomly-sdk)
# through an ignored go.work, so an SDK change is tested here before it is
# tagged; sdk-pinned returns to the released version go.mod pins.
sdk-local:
scripts/sdk-workspace.sh on "$(SDK)"
sdk-pinned:
scripts/sdk-workspace.sh off
sdk-status:
scripts/sdk-workspace.sh status
assurance-catalog:
go run ./internal/assurance/cmd catalog-validate $(if $(CHECK),--check $(CHECK),) $(if $(EVIDENCE),--evidence $(EVIDENCE),)
assurance-report:
go run ./internal/assurance/cmd report --results internal/assurance/testdata/fixtures/mixed-failure/results \
--catalog internal/assurance/testdata/catalog.json --out .assurance --tag v0.0.0-preview --previous none --allow-unknown
benchmark: build-full
bin/$(BINARY_NAME)$(EXE_SUFFIX) benchmark $(if $(ARGS),$(ARGS),)
benchmark-samples: build-lite
go run ./internal/assurance/perfrun -output .benchmark-runs/performance -case canonical-sbom-scan -samples 5 -network-state offline -- \
./bin/$(BINARY_NAME)-lite$(EXE_SUFFIX) scan --sbom --path test/smoke/testdata/sboms/go.spdx.json --detectors sbom --format json
benchmark-report:
go run ./internal/tools/benchmarkreport
run:
go run ./cmd/bomly $(ARGS)
generate: build-full
./bin/$(BINARY_NAME)$(EXE_SUFFIX) internal docs-gen --output docs
licenses:
go run github.com/google/go-licenses@$(GO_LICENSES_VERSION) save ./... \
--save_path=./licenses \
--ignore github.com/bomly-dev/bomly-cli \
--ignore github.com/xi2/xz \
--ignore modernc.org/mathutil \
--force
# go-licenses cannot classify modernc.org/mathutil, but its BSD-3-Clause
# terms require shipping the notice with binary distributions: copy the
# license text explicitly and fail the target if it is missing.
mkdir -p licenses/modernc.org/mathutil
cp "$$(go list -m -f '{{.Dir}}' modernc.org/mathutil)/LICENSE" licenses/modernc.org/mathutil/LICENSE
test -s licenses/modernc.org/mathutil/LICENSE