2021-02-13 00:54:06 +03:00
|
|
|
SHELL := /bin/bash
|
2021-08-12 23:46:06 +03:00
|
|
|
GIT_HASH := $(shell git rev-parse HEAD)
|
2021-10-26 20:22:22 +03:00
|
|
|
GIT_VERSION ?= $(shell git describe --tags --always --dirty)
|
|
|
|
SOURCE_DATE_EPOCH=$(shell git log --date=iso8601-strict -1 --pretty=%ct)
|
2021-02-24 22:46:41 +03:00
|
|
|
IMAGE_NAME = scorecard
|
2021-02-25 22:51:57 +03:00
|
|
|
OUTPUT = output
|
2021-11-08 18:55:58 +03:00
|
|
|
PLATFORM="linux/amd64,linux/arm64,linux/386,linux/arm"
|
2021-10-25 22:30:13 +03:00
|
|
|
LDFLAGS=$(shell ./scripts/version-ldflags)
|
2022-02-18 23:27:24 +03:00
|
|
|
|
|
|
|
|
2021-07-27 20:37:27 +03:00
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
############################### make help #####################################
|
2021-02-22 02:35:39 +03:00
|
|
|
.PHONY: help
|
|
|
|
help: ## Display this help
|
2022-01-31 05:23:40 +03:00
|
|
|
@awk 'BEGIN {FS = ":.*##"; \
|
|
|
|
printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ \
|
|
|
|
{ printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } \
|
|
|
|
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
###############################################################################
|
|
|
|
|
2022-09-22 18:58:10 +03:00
|
|
|
##@ Tools
|
2021-05-15 23:58:01 +03:00
|
|
|
################################ make install #################################
|
2022-09-22 18:58:10 +03:00
|
|
|
TOOLS_DIR := tools
|
|
|
|
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
|
|
|
|
GOBIN := $(shell go env GOBIN)
|
|
|
|
|
|
|
|
# Golang binaries.
|
|
|
|
|
|
|
|
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
|
|
|
|
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
|
|
|
|
KO := $(TOOLS_BIN_DIR)/ko
|
|
|
|
$(KO): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/google/ko
|
|
|
|
|
|
|
|
STUNNING_TRIBBLE := $(TOOLS_BIN_DIR)/stunning-tribble
|
|
|
|
$(STUNNING_TRIBBLE): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/naveensrinivasan/stunning-tribble
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2022-09-22 18:58:10 +03:00
|
|
|
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
|
|
|
|
$(MOCKGEN): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/golang/mock/mockgen
|
|
|
|
|
|
|
|
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
|
|
|
|
$(GINKGO): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/onsi/ginkgo/v2/ginkgo
|
|
|
|
|
|
|
|
GORELEASER := $(TOOLS_BIN_DIR)/goreleaser
|
|
|
|
$(GORELEASER): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install github.com/goreleaser/goreleaser
|
|
|
|
|
|
|
|
PROTOC_GEN_GO := $(TOOLS_BIN_DIR)/protoc-gen-go
|
|
|
|
$(PROTOC_GEN_GO): $(TOOLS_DIR)/go.mod
|
|
|
|
cd $(TOOLS_DIR); GOBIN=$(TOOLS_BIN_DIR) go install google.golang.org/protobuf/cmd/protoc-gen-go
|
|
|
|
|
|
|
|
# Non-Golang binaries.
|
|
|
|
# TODO: Figure out how to install these binaries automatically.
|
|
|
|
|
|
|
|
PROTOC := $(shell which protoc)
|
2021-05-15 23:58:01 +03:00
|
|
|
$(PROTOC):
|
|
|
|
ifeq (,$(PROTOC))
|
|
|
|
$(error download and install protobuf compiler package - https://developers.google.com/protocol-buffers/docs/downloads)
|
|
|
|
endif
|
2022-09-22 18:58:10 +03:00
|
|
|
|
|
|
|
# Installs required binaries into $(TOOLS_BIN_DIR) wherever possible.
|
|
|
|
# Keeping a local copy instead of a global install allows for:
|
|
|
|
# i) Controlling the binary version Scorecard depends on leading to consistent
|
|
|
|
# behavior across users.
|
|
|
|
# ii) Avoids installing a whole bunch of otherwise unnecessary tools in the user's workspace.
|
|
|
|
.PHONY: install
|
|
|
|
install: ## Installs required binaries.
|
|
|
|
install: $(GOLANGCI_LINT) \
|
|
|
|
$(KO) \
|
|
|
|
$(STUNNING_TRIBBLE) \
|
|
|
|
$(PROTOC_GEN_GO) $(PROTOC) \
|
|
|
|
$(MOCKGEN) \
|
|
|
|
$(GINKGO) \
|
|
|
|
$(GORELEASER)
|
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
###############################################################################
|
|
|
|
|
2022-01-31 05:23:40 +03:00
|
|
|
##@ Build
|
2021-05-15 23:58:01 +03:00
|
|
|
################################## make all ###################################
|
2021-02-22 02:35:39 +03:00
|
|
|
all: ## Runs build, test and verify
|
2022-10-21 01:28:55 +03:00
|
|
|
all-targets = build unit-test unit-test-attestor check-linter validate-docs add-projects validate-projects
|
2021-12-02 23:20:27 +03:00
|
|
|
.PHONY: all all-targets-update-dependencies $(all-targets) update-dependencies tree-status
|
|
|
|
all-targets-update-dependencies: $(all-targets) | update-dependencies
|
|
|
|
all: update-dependencies all-targets-update-dependencies tree-status
|
2021-05-15 23:58:01 +03:00
|
|
|
|
|
|
|
update-dependencies: ## Update go dependencies for all modules
|
|
|
|
# Update root go modules
|
|
|
|
go mod tidy && go mod verify
|
2022-09-12 23:33:52 +03:00
|
|
|
cd tools; go mod tidy && go mod verify; cd ../
|
|
|
|
cd attestor; go mod tidy && go mod verify; cd ../
|
2021-05-15 23:58:01 +03:00
|
|
|
|
|
|
|
check-linter: ## Install and run golang linter
|
2022-09-22 18:58:10 +03:00
|
|
|
check-linter: | $(GOLANGCI_LINT)
|
2021-05-15 23:58:01 +03:00
|
|
|
# Run golangci-lint linter
|
2022-09-22 18:58:10 +03:00
|
|
|
$(GOLANGCI_LINT) run -c .golangci.yml
|
2021-05-15 23:58:01 +03:00
|
|
|
|
2022-05-26 01:37:22 +03:00
|
|
|
add-projects: ## Adds new projects to ./cron/internal/data/projects.csv
|
|
|
|
add-projects: ./cron/internal/data/projects.csv | build-add-script
|
|
|
|
# Add new projects to ./cron/internal/data/projects.csv
|
|
|
|
./cron/internal/data/add/add ./cron/internal/data/projects.csv ./cron/internal/data/projects.new.csv
|
|
|
|
mv ./cron/internal/data/projects.new.csv ./cron/internal/data/projects.csv
|
2021-06-10 23:24:33 +03:00
|
|
|
|
2022-05-26 01:37:22 +03:00
|
|
|
validate-projects: ## Validates ./cron/internal/data/projects.csv
|
|
|
|
validate-projects: ./cron/internal/data/projects.csv | build-validate-script
|
|
|
|
# Validate ./cron/internal/data/projects.csv
|
|
|
|
./cron/internal/data/validate/validate ./cron/internal/data/projects.csv
|
2021-02-22 02:35:39 +03:00
|
|
|
|
2021-12-02 23:20:27 +03:00
|
|
|
tree-status: | all-targets-update-dependencies ## Verify tree is clean and all changes are committed
|
2021-05-15 23:58:01 +03:00
|
|
|
# Verify the tree is clean and all changes are commited
|
|
|
|
./scripts/tree-status
|
2021-05-17 22:20:28 +03:00
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
###############################################################################
|
|
|
|
|
2021-06-10 23:24:33 +03:00
|
|
|
################################## make build #################################
|
2021-10-21 23:08:56 +03:00
|
|
|
## Build all cron-related targets
|
2021-11-18 20:04:07 +03:00
|
|
|
build-cron: build-controller build-worker build-cii-worker \
|
|
|
|
build-shuffler build-bq-transfer build-github-server \
|
|
|
|
build-webhook build-add-script build-validate-script build-update-script
|
2021-10-21 23:08:56 +03:00
|
|
|
|
2022-09-22 18:58:10 +03:00
|
|
|
build-targets = generate-mocks generate-docs build-scorecard build-cron build-proto
|
2021-05-15 23:58:01 +03:00
|
|
|
.PHONY: build $(build-targets)
|
2021-09-04 18:39:10 +03:00
|
|
|
build: ## Build all binaries and images in the repo.
|
2021-05-15 23:58:01 +03:00
|
|
|
build: $(build-targets)
|
|
|
|
|
|
|
|
build-proto: ## Compiles and generates all required protobufs
|
2022-10-20 00:01:42 +03:00
|
|
|
build-proto: cron/data/request.pb.go cron/data/metadata.pb.go
|
|
|
|
cron/data/request.pb.go: cron/data/request.proto | $(PROTOC) $(PROTOC_GEN_GO)
|
|
|
|
$(PROTOC) --plugin=$(PROTOC_GEN_GO) --go_out=. --go_opt=paths=source_relative cron/data/request.proto
|
|
|
|
cron/data/metadata.pb.go: cron/data/metadata.proto | $(PROTOC) $(PROTOC_GEN_GO)
|
|
|
|
$(PROTOC) --plugin=$(PROTOC_GEN_GO) --go_out=. --go_opt=paths=source_relative cron/data/metadata.proto
|
2021-05-15 23:58:01 +03:00
|
|
|
|
2021-11-13 01:16:22 +03:00
|
|
|
generate-mocks: ## Compiles and generates all mocks using mockgen.
|
2022-09-22 18:58:10 +03:00
|
|
|
generate-mocks: clients/mockclients/repo_client.go \
|
|
|
|
clients/mockclients/repo.go \
|
|
|
|
clients/mockclients/cii_client.go \
|
|
|
|
checks/mockclients/vulnerabilities.go \
|
|
|
|
cmd/packagemanager_mockclient.go
|
|
|
|
clients/mockclients/repo_client.go: clients/repo_client.go | $(MOCKGEN)
|
2021-11-13 01:16:22 +03:00
|
|
|
# Generating MockRepoClient
|
2021-11-15 05:46:41 +03:00
|
|
|
$(MOCKGEN) -source=clients/repo_client.go -destination=clients/mockclients/repo_client.go -package=mockrepo -copyright_file=clients/mockclients/license.txt
|
2022-09-22 18:58:10 +03:00
|
|
|
clients/mockclients/repo.go: clients/repo.go | $(MOCKGEN)
|
2021-11-15 05:46:41 +03:00
|
|
|
# Generating MockRepo
|
|
|
|
$(MOCKGEN) -source=clients/repo.go -destination=clients/mockclients/repo.go -package=mockrepo -copyright_file=clients/mockclients/license.txt
|
2022-09-22 18:58:10 +03:00
|
|
|
clients/mockclients/cii_client.go: clients/cii_client.go | $(MOCKGEN)
|
2021-11-15 05:46:41 +03:00
|
|
|
# Generating MockCIIClient
|
|
|
|
$(MOCKGEN) -source=clients/cii_client.go -destination=clients/mockclients/cii_client.go -package=mockrepo -copyright_file=clients/mockclients/license.txt
|
2022-09-22 18:58:10 +03:00
|
|
|
checks/mockclients/vulnerabilities.go: clients/vulnerabilities.go | $(MOCKGEN)
|
2022-01-03 04:43:38 +03:00
|
|
|
# Generating MockCIIClient
|
|
|
|
$(MOCKGEN) -source=clients/vulnerabilities.go -destination=clients/mockclients/vulnerabilities.go -package=mockrepo -copyright_file=clients/mockclients/license.txt
|
2022-09-22 18:58:10 +03:00
|
|
|
cmd/packagemanager_mockclient.go: cmd/packagemanager_client.go | $(MOCKGEN)
|
2022-03-09 08:36:23 +03:00
|
|
|
# Generating MockPackageManagerClient
|
2022-03-11 18:28:10 +03:00
|
|
|
$(MOCKGEN) -source=cmd/packagemanager_client.go -destination=cmd/packagemanager_mockclient.go -package=cmd -copyright_file=clients/mockclients/license.txt
|
2022-09-22 18:58:10 +03:00
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
generate-docs: ## Generates docs
|
2021-11-10 19:56:44 +03:00
|
|
|
generate-docs: validate-docs docs/checks.md
|
2021-09-10 01:09:39 +03:00
|
|
|
docs/checks.md: docs/checks/internal/checks.yaml docs/checks/internal/*.go docs/checks/internal/generate/*.go
|
2021-05-15 23:58:01 +03:00
|
|
|
# Generating checks.md
|
2021-09-10 18:26:27 +03:00
|
|
|
go run ./docs/checks/internal/generate/main.go docs/checks.md
|
2021-05-15 23:58:01 +03:00
|
|
|
|
2021-11-10 19:56:44 +03:00
|
|
|
validate-docs: docs/checks/internal/generate/main.go
|
|
|
|
# Validating checks.yaml
|
|
|
|
go run ./docs/checks/internal/validate/main.go
|
|
|
|
|
2022-09-24 22:58:50 +03:00
|
|
|
SCORECARD_DEPS = $(shell find . -iname "*.go" | grep -v tools/ | grep -v attestor/)
|
|
|
|
build-scorecard: ## Build Scorecard CLI
|
|
|
|
build-scorecard: scorecard
|
|
|
|
scorecard: $(SCORECARD_DEPS)
|
2021-05-15 23:58:01 +03:00
|
|
|
# Run go build and generate scorecard executable
|
2021-09-29 01:02:58 +03:00
|
|
|
CGO_ENABLED=0 go build -trimpath -a -tags netgo -ldflags '$(LDFLAGS)'
|
2022-09-24 22:58:50 +03:00
|
|
|
scorecard-docker: ## Build Scorecard CLI Docker image
|
|
|
|
scorecard-docker: scorecard.docker
|
|
|
|
scorecard.docker: Dockerfile $(SCORECARD_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . --file Dockerfile \
|
|
|
|
--tag $(IMAGE_NAME) && \
|
|
|
|
touch scorecard.docker
|
|
|
|
|
|
|
|
build-releaser: ## Build goreleaser for the Scorecard CLI
|
|
|
|
build-releaser: scorecard.releaser
|
|
|
|
scorecard.releaser: .goreleaser.yml $(SCORECARD_DEPS) | $(GORELEASER)
|
2021-11-23 19:56:21 +03:00
|
|
|
# Run go releaser on the Scorecard repo
|
2022-09-24 22:58:50 +03:00
|
|
|
$(GORELEASER) check && \
|
|
|
|
VERSION_LDFLAGS="$(LDFLAGS)" $(GORELEASER) release \
|
|
|
|
--snapshot --rm-dist --skip-publish --skip-sign && \
|
|
|
|
touch scorecard.releaser
|
|
|
|
|
|
|
|
CRON_CONTROLLER_DEPS = $(shell find cron/internal/ -iname "*.go")
|
|
|
|
build-controller: ## Build cron controller
|
|
|
|
build-controller: cron/internal/controller/controller
|
|
|
|
cron/internal/controller/controller: $(CRON_CONTROLLER_DEPS)
|
2021-11-18 20:04:07 +03:00
|
|
|
# Run go build on the cron PubSub controller
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/controller && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o controller
|
2022-09-24 22:58:50 +03:00
|
|
|
cron-controller-docker: ## Build cron controller Docker image
|
|
|
|
cron-controller-docker: cron/internal/controller/controller.docker
|
|
|
|
cron/internal/controller/controller.docker: cron/internal/controller/Dockerfile $(CRON_CONTROLLER_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . --file cron/internal/controller/Dockerfile \
|
|
|
|
--tag $(IMAGE_NAME)-batch-controller \
|
|
|
|
&& touch cron/internal/controller/controller.docker
|
2021-11-18 20:04:07 +03:00
|
|
|
|
|
|
|
build-worker: ## Runs go build on the cron PubSub worker
|
|
|
|
# Run go build on the cron PubSub worker
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/worker && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o worker
|
2021-05-19 01:18:08 +03:00
|
|
|
|
2022-09-24 22:58:50 +03:00
|
|
|
CRON_CII_DEPS = $(shell find cron/internal/ clients/ -iname "*.go")
|
|
|
|
build-cii-worker: ## Build cron CII worker
|
|
|
|
build-cii-worker: cron/internal/cii/cii-worker
|
|
|
|
cron/internal/cii/cii-worker: $(CRON_CII_DEPS)
|
2021-11-16 07:23:00 +03:00
|
|
|
# Run go build on the CII worker
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/cii && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o cii-worker
|
2022-09-24 22:58:50 +03:00
|
|
|
cron-cii-worker-docker: # Build cron CII worker Docker image
|
|
|
|
cron-cii-worker-docker: cron/internal/cii/cii-worker.docker
|
|
|
|
cron/internal/cii/cii-worker.docker: cron/internal/cii/Dockerfile $(CRON_CII_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . --file cron/internal/cii/Dockerfile \
|
|
|
|
--tag $(IMAGE_NAME)-cii-worker && \
|
|
|
|
touch cron/internal/cii/cii-worker.docker
|
|
|
|
|
2022-10-20 00:01:42 +03:00
|
|
|
CRON_SHUFFLER_DEPS = $(shell find cron/data/ cron/internal/shuffle/ -iname "*.go")
|
2022-09-24 22:58:50 +03:00
|
|
|
build-shuffler: ## Build cron shuffle script
|
|
|
|
build-shuffler: cron/internal/shuffle/shuffle
|
|
|
|
cron/internal/shuffle/shuffle: $(CRON_SHUFFLER_DEPS)
|
2021-11-18 20:04:07 +03:00
|
|
|
# Run go build on the cron shuffle script
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/shuffle && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o shuffle
|
2021-11-18 20:04:07 +03:00
|
|
|
|
2022-10-20 00:01:42 +03:00
|
|
|
CRON_TRANSFER_DEPS = $(shell find cron/data/ cron/config/ cron/internal/bq/ -iname "*.go")
|
2022-09-24 22:58:50 +03:00
|
|
|
build-bq-transfer: ## Build cron BQ transfer worker
|
|
|
|
build-bq-transfer: cron/internal/bq/data-transfer
|
|
|
|
cron/internal/bq/data-transfer: $(CRON_TRANSFER_DEPS)
|
2021-06-15 02:25:32 +03:00
|
|
|
# Run go build on the Copier cron job
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/bq && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o data-transfer
|
2022-09-24 22:58:50 +03:00
|
|
|
cron-bq-transfer-docker: ## Build cron BQ transfer worker Docker image
|
|
|
|
cron-bq-transfer-docker: cron/internal/bq/data-transfer.docker
|
|
|
|
cron/internal/bq/data-transfer.docker: cron/internal/bq/Dockerfile $(CRON_TRANSFER_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . --file cron/internal/bq/Dockerfile \
|
|
|
|
--tag $(IMAGE_NAME)-bq-transfer && \
|
|
|
|
touch cron/internal/bq/data-transfer.docker
|
|
|
|
|
|
|
|
TOKEN_SERVER_DEPS = $(shell find clients/githubrepo/roundtripper/tokens/ -iname "*.go")
|
|
|
|
build-github-server: ## Build GitHub token server
|
|
|
|
build-github-server: clients/githubrepo/roundtripper/tokens/server/github-auth-server
|
|
|
|
clients/githubrepo/roundtripper/tokens/server/github-auth-server: $(TOKEN_SERVER_DEPS)
|
2021-10-15 06:03:51 +03:00
|
|
|
# Run go build on the GitHub auth server
|
|
|
|
cd clients/githubrepo/roundtripper/tokens/server && \
|
|
|
|
CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o github-auth-server
|
2022-09-24 22:58:50 +03:00
|
|
|
cron-github-server-docker: ## Build GitHub token server Docker image
|
|
|
|
cron-github-server-docker: clients/githubrepo/roundtripper/tokens/server/github-auth-server.docker
|
|
|
|
clients/githubrepo/roundtripper/tokens/server/github-auth-server.docker: \
|
|
|
|
clients/githubrepo/roundtripper/tokens/server/Dockerfile $(TOKEN_SERVER_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . \
|
|
|
|
--file clients/githubrepo/roundtripper/tokens/server/Dockerfile \
|
|
|
|
--tag ${IMAGE_NAME}-github-server && \
|
|
|
|
touch clients/githubrepo/roundtripper/tokens/server/github-auth-server.docker
|
|
|
|
|
2022-10-20 00:01:42 +03:00
|
|
|
CRON_WEBHOOK_DEPS = $(shell find cron/internal/webhook/ cron/data/ -iname "*.go")
|
2022-09-24 22:58:50 +03:00
|
|
|
build-webhook: ## Build cron webhook server
|
|
|
|
build-webhook: cron/internal/webhook/webhook
|
|
|
|
cron/internal/webhook/webhook: $(CRON_WEBHOOK_DEPS)
|
2021-08-11 04:45:01 +03:00
|
|
|
# Run go build on the cron webhook
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/webhook && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o webhook
|
2022-09-24 22:58:50 +03:00
|
|
|
cron-webhook-docker: ## Build cron webhook server Docker image
|
|
|
|
cron-webhook-docker: cron/internal/webhook/webhook.docker
|
|
|
|
cron/internal/webhook/webhook.docker: cron/internal/webhook/Dockerfile $(CRON_WEBHOOK_DEPS)
|
|
|
|
DOCKER_BUILDKIT=1 docker build . --file cron/internal/webhook/Dockerfile \
|
|
|
|
--tag ${IMAGE_NAME}-webhook && \
|
|
|
|
touch cron/internal/webhook/webhook.docker
|
|
|
|
|
2021-08-11 04:45:01 +03:00
|
|
|
|
2021-06-10 23:24:33 +03:00
|
|
|
build-add-script: ## Runs go build on the add script
|
2022-05-26 01:37:22 +03:00
|
|
|
build-add-script: cron/internal/data/add/add
|
2022-10-20 00:01:42 +03:00
|
|
|
cron/internal/data/add/add: cron/internal/data/add/*.go cron/data/*.go cron/internal/data/projects.csv
|
2021-06-10 23:24:33 +03:00
|
|
|
# Run go build on the add script
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/data/add && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o add
|
2021-06-10 23:24:33 +03:00
|
|
|
|
2021-06-09 02:55:43 +03:00
|
|
|
build-validate-script: ## Runs go build on the validate script
|
2022-05-26 01:37:22 +03:00
|
|
|
build-validate-script: cron/internal/data/validate/validate
|
2022-10-20 00:01:42 +03:00
|
|
|
cron/internal/data/validate/validate: cron/internal/data/validate/*.go cron/data/*.go cron/internal/data/projects.csv
|
2021-06-09 02:55:43 +03:00
|
|
|
# Run go build on the validate script
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/data/validate && CGO_ENABLED=0 go build -trimpath -a -ldflags '$(LDFLAGS)' -o validate
|
2021-06-09 02:55:43 +03:00
|
|
|
|
|
|
|
build-update-script: ## Runs go build on the update script
|
2022-05-26 01:37:22 +03:00
|
|
|
build-update-script: cron/internal/data/update/projects-update
|
2022-10-20 00:01:42 +03:00
|
|
|
cron/internal/data/update/projects-update: cron/internal/data/update/*.go cron/data/*.go
|
2021-06-09 02:55:43 +03:00
|
|
|
# Run go build on the update script
|
2022-05-26 01:37:22 +03:00
|
|
|
cd cron/internal/data/update && CGO_ENABLED=0 go build -trimpath -a -tags netgo -ldflags '$(LDFLAGS)' -o projects-update
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-12-02 23:20:27 +03:00
|
|
|
docker-targets = scorecard-docker cron-controller-docker cron-worker-docker cron-cii-worker-docker cron-bq-transfer-docker cron-webhook-docker cron-github-server-docker
|
|
|
|
.PHONY: dockerbuild $(docker-targets)
|
|
|
|
dockerbuild: $(docker-targets)
|
|
|
|
|
|
|
|
cron-worker-docker:
|
2022-05-26 01:37:22 +03:00
|
|
|
DOCKER_BUILDKIT=1 docker build . --file cron/internal/worker/Dockerfile --tag $(IMAGE_NAME)-batch-worker
|
2021-05-15 23:58:01 +03:00
|
|
|
###############################################################################
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2022-01-31 05:23:40 +03:00
|
|
|
##@ Tests
|
2021-05-15 23:58:01 +03:00
|
|
|
################################# make test ###################################
|
2022-09-12 23:33:52 +03:00
|
|
|
test-targets = unit-test unit-test-attestor e2e-pat e2e-gh-token ci-e2e
|
2021-05-15 23:58:01 +03:00
|
|
|
.PHONY: test $(test-targets)
|
|
|
|
test: $(test-targets)
|
2020-12-23 00:43:24 +03:00
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
unit-test: ## Runs unit test without e2e
|
|
|
|
# Run unit tests, ignoring e2e tests
|
2022-01-20 00:52:45 +03:00
|
|
|
# run the go tests and gen the file coverage-all used to do the integration with codecov
|
2022-02-16 02:38:23 +03:00
|
|
|
SKIP_GINKGO=1 go test -race -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`
|
2021-02-13 00:54:06 +03:00
|
|
|
|
2022-09-12 23:33:52 +03:00
|
|
|
unit-test-attestor: ## Runs unit tests on scorecard-attestor
|
2022-09-19 18:26:13 +03:00
|
|
|
cd attestor; SKIP_GINKGO=1 go test -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`; cd ..;
|
2022-09-12 23:33:52 +03:00
|
|
|
|
2021-05-15 23:58:01 +03:00
|
|
|
check-env:
|
|
|
|
ifndef GITHUB_AUTH_TOKEN
|
|
|
|
$(error GITHUB_AUTH_TOKEN is undefined)
|
|
|
|
endif
|
2022-02-15 22:27:45 +03:00
|
|
|
|
2022-04-12 03:35:44 +03:00
|
|
|
e2e-pat: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to GitHub personal access token
|
|
|
|
e2e-pat: build-scorecard check-env | $(GINKGO)
|
2022-02-15 22:27:45 +03:00
|
|
|
# Run e2e tests. GITHUB_AUTH_TOKEN with personal access token must be exported to run this
|
2022-09-19 18:26:13 +03:00
|
|
|
TOKEN_TYPE="PAT" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
|
2022-04-12 03:35:44 +03:00
|
|
|
|
|
|
|
e2e-gh-token: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to default GITHUB_TOKEN
|
|
|
|
e2e-gh-token: build-scorecard check-env | $(GINKGO)
|
|
|
|
# Run e2e tests. GITHUB_AUTH_TOKEN set to secrets.GITHUB_TOKEN must be used to run this.
|
2022-09-19 18:26:13 +03:00
|
|
|
TOKEN_TYPE="GITHUB_TOKEN" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
|
2021-05-15 23:58:01 +03:00
|
|
|
###############################################################################
|
2022-09-22 18:58:10 +03:00
|
|
|
|
|
|
|
##@ TODO(#744)
|
|
|
|
################################## make ko-images #############################
|
|
|
|
ko-targets = scorecard-ko cron-controller-ko cron-worker-ko cron-cii-worker-ko cron-bq-transfer-ko cron-webhook-ko cron-github-server-ko
|
|
|
|
.PHONY: ko-images $(ko-targets)
|
|
|
|
ko-images: $(ko-targets)
|
|
|
|
|
|
|
|
KOCACHE_PATH=/tmp/ko
|
|
|
|
|
|
|
|
$(KOCACHE_PATH):
|
|
|
|
mkdir -p $(KOCACHE_PATH)
|
|
|
|
|
|
|
|
scorecard-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/${IMAGE_NAME}
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KO_CACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4
|
|
|
|
|
|
|
|
cron-controller-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-batch-controller \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/cron/internal/controller
|
|
|
|
|
|
|
|
cron-worker-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-batch-worker \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/cron/internal/worker
|
|
|
|
|
|
|
|
cron-cii-worker-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-cii-worker \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM)\
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/cron/internal/cii
|
|
|
|
|
|
|
|
cron-bq-transfer-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-bq-transfer \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/cron/internal/bq
|
|
|
|
|
|
|
|
cron-webhook-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-cron-webhook \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/cron/internal/webhook
|
|
|
|
|
|
|
|
cron-github-server-ko: | $(KO) $(KOCACHE_PATH)
|
|
|
|
KO_DATA_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
|
|
|
|
KO_DOCKER_REPO=${KO_PREFIX}/$(IMAGE_NAME)-github-server \
|
|
|
|
LDFLAGS="$(LDFLAGS)" \
|
|
|
|
KOCACHE=$(KOCACHE_PATH) \
|
|
|
|
$(KO) build -B \
|
|
|
|
--push=false \
|
|
|
|
--sbom=none \
|
|
|
|
--platform=$(PLATFORM) \
|
|
|
|
--tags latest,$(GIT_VERSION),$(GIT_HASH) \
|
|
|
|
github.com/ossf/scorecard/v4/clients/githubrepo/roundtripper/tokens/server
|
|
|
|
|
|
|
|
###############################################################################
|