2021-02-13 00:54:06 +03:00
|
|
|
SHELL := /bin/bash
|
2021-02-17 04:55:36 +03:00
|
|
|
GOBIN ?= $(GOPATH)/bin
|
|
|
|
GINKGO ?= $(GOBIN)/ginkgo
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
.PHONY: help
|
|
|
|
help: ## Display this help
|
|
|
|
@awk \
|
|
|
|
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
|
|
|
|
' \
|
|
|
|
BEGIN { \
|
|
|
|
FS = ":.*##" ; \
|
|
|
|
printf "Available targets:\n"; \
|
|
|
|
} \
|
|
|
|
/^[a-zA-Z0-9_-]+:.*?##/ { \
|
|
|
|
printf " %s%-25s%s %s\n", col, $$1, nocol, $$2 \
|
|
|
|
} \
|
|
|
|
/^##@/ { \
|
|
|
|
printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
|
|
|
|
} \
|
|
|
|
' $(MAKEFILE_LIST)
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
all: ## Runs build, test and verify
|
|
|
|
.PHONY: all
|
|
|
|
all: build test verify
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build: ## Runs go build and generates executable
|
|
|
|
CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w -extldflags "-static"'
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
.PHONY: test
|
|
|
|
test: ## Runs unit test
|
|
|
|
# ignoring e2e tests
|
|
|
|
go test -covermode atomic `go list ./... | grep -v e2e`
|
2020-12-23 00:43:24 +03:00
|
|
|
|
|
|
|
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
|
|
|
|
golangci-lint:
|
2021-02-15 19:01:30 +03:00
|
|
|
rm -f $(GOLANGCI_LINT) || :
|
2020-12-23 00:43:24 +03:00
|
|
|
set -e ;\
|
2021-02-15 19:01:30 +03:00
|
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.36.0 ;\
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
lint: golangci-lint ## Runs golangci-lint linter
|
2021-02-15 19:01:30 +03:00
|
|
|
$(GOLANGCI_LINT) run -n
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-02-13 00:54:06 +03:00
|
|
|
check-env:
|
|
|
|
ifndef GITHUB_AUTH_TOKEN
|
|
|
|
$(error GITHUB_AUTH_TOKEN is undefined)
|
|
|
|
endif
|
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
e2e: ## Runs e2e tests
|
2021-01-01 23:36:31 +03:00
|
|
|
.PHONY: e2e
|
2021-02-14 20:43:21 +03:00
|
|
|
# export GITHUB_AUTH_TOKEN with personal access token to run the e2e
|
2021-02-17 04:55:36 +03:00
|
|
|
e2e: build check-env ginkgo
|
|
|
|
$(GINKGO) --skip="E2E TEST:executable" -p -v -cover ./...
|
2021-02-13 00:54:06 +03:00
|
|
|
|
2021-02-17 04:55:36 +03:00
|
|
|
ginkgo:
|
|
|
|
GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo
|
2021-02-22 02:35:39 +03:00
|
|
|
|
|
|
|
ci-e2e: ## Runs ci e2e tests
|
2021-02-13 00:54:06 +03:00
|
|
|
.PHONY: ci-e2e
|
2021-02-14 20:43:21 +03:00
|
|
|
# export GITHUB_AUTH_TOKEN with personal access token to run the e2e
|
2021-02-13 00:54:06 +03:00
|
|
|
ci-e2e: build check-env
|
|
|
|
$(call ndef, GITHUB_AUTH_TOKEN)
|
|
|
|
mkdir -p bin
|
2021-02-22 20:18:28 +03:00
|
|
|
mkdir -p cache
|
2021-02-22 23:32:39 +03:00
|
|
|
USE_DISK_CACHE=1 DISK_CACHE_PATH="./cache" ./scorecard --repo=https://github.com/ossf/scorecard --show-details --metadata=openssf --format json > ./bin/results.json
|
2021-02-23 18:01:49 +03:00
|
|
|
@sleep 30
|
|
|
|
ginkgo -p -v -cover --skip="E2E TEST:blob" ./...
|
2021-02-14 20:43:21 +03:00
|
|
|
|
2021-02-22 02:35:39 +03:00
|
|
|
|
|
|
|
# Verification targets
|
|
|
|
.PHONY: verify
|
|
|
|
verify: verify-go-mod lint ## Run all verification targets
|
|
|
|
|
|
|
|
.PHONY: verify-go-mod
|
|
|
|
verify-go-mod: ## Verify the go modules
|
|
|
|
export GO111MODULE=on && \
|
|
|
|
go mod tidy && \
|
|
|
|
go mod verify
|
|
|
|
./hack/tree-status
|