-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
65 lines (54 loc) · 1.75 KB
/
Makefile
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
BUILDTAGS = "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp"
BUILDFLAGS = -tags ${BUILDTAGS} -installsuffix netgo
BUILDPATHS = ./pkg/... ./cli/... ./tests/...
.PHONY: build
build: mod-tidy fmt vet
go build -o bin/sbctl sbctl.go
.PHONY: mod-tidy
mod-tidy:
go mod tidy
# Install/upgrade ginkgo. This version must be the same as
# the one on go.mod. We'll rely on dependabot to upgrade go.mod
.PHONY: ginkgo
ginkgo:
go install github.com/onsi/ginkgo/v2/ginkgo
.PHONY: test
test: fmt vet
ginkgo -v ./tests/...
go test -v ${BUILDFLAGS} ./pkg/... ./cli/...
.PHONY: fmt
fmt:
go fmt ${BUILDPATHS}
.PHONY: vet
vet:
go vet ${BUILDFLAGS} ${BUILDPATHS}
# Compile and install sbctl locally in you GOBIN path
.PHONY: install
install: build
go install ${BUILDFLAGS} sbctl.go
.PHONY: lint
lint:
ifeq (, $(shell which golangci-lint))
$(error "Install golangci-lint by either running 'make install-golangci-lint' or by other means")
endif
golangci-lint run --new -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}
.PHONY: lint-and-fix
lint-and-fix:
ifeq (, $(shell which golangci-lint))
$(error "Install golangci-lint by either running 'make install-golangci-lint' or by other means")
endif
golangci-lint run --new --fix -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS}
# Not pinning to a particular version so as not to forget updating it
# If unrelated warnings arise due to linter updates or newly introduced linters
# we'll consider pinning.
.PHONY: install-golangci-lint
install-golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
.PHONY: scan
scan:
trivy fs \
--scanners vuln \
--exit-code=1 \
--severity="HIGH,CRITICAL" \
--ignore-unfixed \
./