-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (77 loc) · 1.71 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
#
# Makefile config
#
MAKEFLAGS += --warn-undefined-variables
SHELL := /usr/bin/env bash
.DEFAULT_GOAL := help
.SHELLFLAGS := -e -o pipefail -c
.DELETE_ON_ERROR:
.SUFFIXES:
.NOTPARALLEL:
#
# Makefile help page
#
define HELP_USAGE
@echo Usage: make help
endef
define HELP_ERROR
@echo
@if [ -n "$(ERROR)" ]; then \
printf "\033[31m%s\033[0m\n" "$(ERROR)"; \
echo; \
exit 1; \
fi
endef
# @echo Variables:
# @echo
# @printf " \033[36m%-15s\033[0m %-35s %s\n" "VARNAME" "VAR DESCRIPTION" "VALUE"
define HELP_PREFIX
@echo
@echo Variables:
@echo
endef
define HELP_TARGETS
@echo
@echo Targets:
@echo
@grep -hE '^[a-zA-Z_\-\.]+(.%)?:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
endef
define usage
$(HELP_USAGE)
$(HELP_PREFIX)
$(HELP_TARGETS)
$(HELP_ERROR)
endef
#
# Default variables
#
CI ?=
COMMIT ?= $(shell git rev-parse HEAD)
ERROR ?=
PROJECT_ROOT ?= $(shell git rev-parse --show-toplevel)
PROJECT_NAME ?= $(shell basename ${PROJECT_ROOT})
TEST_IMAGE ?= ${PROJECT_NAME}:test
#
# Targets
#
.PHONY: .phony
.phony:
help: ## Display usage information
help: .phony
$(usage)
lint: ## Run buildkite linter
lint: .phony
docker run --rm -v "${PWD}:/plugin:ro" buildkite/plugin-linter --id boostsecurityio/boostsec-scanner
test: ## Run test suite
test: jobs := 4
test: args :=
test:
@docker run --rm -i -v $${PWD}:/app ${TEST_IMAGE} --jobs ${jobs} ${args} tests
test.build: ## Build test image
test.build:
@docker build -f tests/Dockerfile -t ${TEST_IMAGE} .
test.shell: ## Execute shell in test image
test.shell: test.build
docker run --rm -ti -v $${PWD}:/app --entrypoint bash ${TEST_IMAGE}