Debian Codegraph @

Makefile

raw
1 #
2 # Copyright 2021 The Sigstore Authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 .PHONY: all pkg test test-e2e test-signer-program clean lint fuzz help
17
18 all: pkg fuzz
19
20 TOOLS_DIR := hack/tools
21 TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
22 FUZZ_DIR := ./test/fuzz
23 INTEGRATION_TEST_DIR := ./test/e2e
24 GO-FUZZ-BUILD := $(TOOLS_BIN_DIR)/go-fuzz-build
25
26 TEST_LOCALKMS_DIR := ./test/cliplugin/localkms
27 TEST_LOCALKMS_BIN_DIR := $(CURDIR)/bin
28 TEST_LOCALKMS_BIN := $(TEST_LOCALKMS_BIN_DIR)/sigstore-kms-testkms
29 ifeq ($(OS),Windows_NT)
30 TEST_LOCALKMS_BIN := $(TEST_LOCALKMS_BIN).exe
31 endif
32 PATH := $(PATH):$(TEST_LOCALKMS_BIN_DIR)
33 CLI_PLUGIN_DIR := ./pkg/signature/kms/cliplugin
34
35 LDFLAGS ?=
36
37 GO_MOD_DIRS = . ./pkg/signature/kms/aws ./pkg/signature/kms/azure ./pkg/signature/kms/gcp ./pkg/signature/kms/hashivault ./test/cliplugin/localkms ./test/fuzz ./hack/tools
38
39 lint:
40 for dir in $(GO_MOD_DIRS) ; do \
41 cd $$dir && golangci-lint run -v --new-from-rev=HEAD~ ./... && cd - ; \
42 done
43
44 pkg: ## Build pkg
45 set -o xtrace; \
46 for dir in $(GO_MOD_DIRS) ; do \
47 cd $$dir && CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" ./... && cd - >/dev/null; \
48 done
49
50 test: ## Run Tests for all Go modules.
51 set -o xtrace; \
52 for dir in $(GO_MOD_DIRS) ; do \
53 cd $$dir && go test ./... && cd - >/dev/null; \
54 done
55
56 test-signer-program: ## Run Tests for the cliplugin against a pre-compiled plugin program.
57 set -o xtrace; \
58 go -C $(TEST_LOCALKMS_DIR) build -o $(TEST_LOCALKMS_BIN) && \
59 go -C $(CLI_PLUGIN_DIR) test -tags=signer_program ./ -key-resource-id testkms://$(TEST_LOCALKMS_BIN_DIR)/key.pem
60
61 tidy: ## Run go mod tidy all Go modules.
62 set -o xtrace; \
63 for dir in $(GO_MOD_DIRS) ; do \
64 cd $$dir && go mod tidy && cd - >/dev/null; \
65 done
66
67 test-e2e: ## Run E2E Tests
68 cd $(INTEGRATION_TEST_DIR); ./e2e-test.sh
69
70 fuzz: $(GO-FUZZ-BUILD) ## Run Fuzz tests
71 cd $(FUZZ_DIR);$(GO-FUZZ-BUILD) -o pem-fuzz.zip ./pem
72 cd $(FUZZ_DIR);$(GO-FUZZ-BUILD) -o signature-fuzz.zip ./signature
73 cd $(FUZZ_DIR);$(GO-FUZZ-BUILD) -o fuzz-fuzz.zip .
74 cd $(FUZZ_DIR);$(GO-FUZZ-BUILD) -o dsse-fuzz.zip ./dsse
75
76 clean: ## Clean workspace
77 rm -rf sigstore
78 rm -f $(FUZZ_DIR)/*fuzz.zip
79 rm -rf $(TOOLS_BIN_DIR)
80
81 ## --------------------------------------
82 ## Tooling Binaries
83 ## --------------------------------------
84
85 $(GO-FUZZ-BUILD): $(TOOLS_DIR)/go.mod
86 cd $(TOOLS_DIR);go build -trimpath -tags=tools -o $(TOOLS_BIN_DIR)/go-fuzz-build github.com/dvyukov/go-fuzz/go-fuzz-build
87
88 ##################
89 # help
90 ##################
91
92 help: ## Display this help
93 @awk \
94 -v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
95 ' \
96 BEGIN { \
97 FS = ":.*##" ; \
98 printf "\nUsage:\n make %s<target>%s\n", col, nocol \
99 } \
100 /^[a-zA-Z_-]+:.*?##/ { \
101 printf " %s%-15s%s %s\n", col, $$1, nocol, $$2 \
102 } \
103 /^##@/ { \
104 printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
105 } \
106 ' $(MAKEFILE_LIST)