This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (75 loc) · 2.07 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
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
# Recursive wildcard.
# Usage: $(call rwildcard, dir_to_search, pattern_to_search_for)
# Example: $(call rwildcard, ., *.go)
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
# Go executable to use, i.e. `make GO=/usr/bin/go1.18`
# Defaults to first found in PATH
GO?=go
#########
# BUILD #
#########
bin/bindl:
OUTDIR=bin ./bootstrap.sh
.PHONY: bin/bindl-min
bin/bindl-min:
${GO} build -o bin/bindl ./cmd/bindl
.PHONY: bin/bindl-dev
bin/bindl-dev: bin/goreleaser
bin/goreleaser build \
--output bin/bindl \
--single-target \
--snapshot \
--rm-dist
include Makefile.*
.PHONY: program/bootstrap/cosign-lock.yaml
program/bootstrap/cosign-lock.yaml: bin/bindl
bin/bindl sync \
--config program/bootstrap/cosign.yaml \
--lock program/bootstrap/cosign-lock.yaml
###########
# RELEASE #
###########
.PHONY: release
release: bin/goreleaser bin/cosign bin/syft
PATH=${PWD}/bin:${PATH} bin/goreleaser release --rm-dist
#########
# TESTS #
#########
program/testdata/myprogram.tar.gz:
@./program/testdata/generate.sh
.PHONY: testdata
testdata: program/testdata/myprogram.tar.gz
.PHONY: test/unit
test/unit: testdata
${GO} test -race -short -v ./...
.PHONY: test/integration
test/integration:
${GO} test -race -run ".*[Ii]ntegration.*" -v ./...
# Manually build bindl and then download cosign because Makefile
# would not understand the dependency without bin/bindl existing.
.PHONY: test/functional
test/functional:
PATH=${PWD}/bin:${PATH} ${MAKE} bin/bindl
PATH=${PWD}/bin:${PATH} ${MAKE} bin/cosign
PATH=${PWD}/bin:${PATH} ${GO} test -race -run ".*[Ff]unctional.*" -v ./...
.PHONY: test/all
test/all:
${GO} test -race -v ./...
###########
# LINTERS #
###########
.PHONY: license
license: bin/addlicense
bin/addlicense \
-c "Bindl Authors" \
-l apache \
$(call rwildcard, ., *.go)
.PHONY: lint
lint: bin/golangci-lint
bin/golangci-lint run
.PHONY: lint/fix
lint/fix: bin/golangci-lint
bin/golangci-lint run --fix
.PHONY: lint/gh-actions
lint/gh-actions: bin/golangci-lint
bin/golangci-lint run --out-format github-actions