Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (41 loc) · 2.09 KB
/
Copy pathMakefile
File metadata and controls
54 lines (41 loc) · 2.09 KB
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
.PHONY: all build versions size test test-php test-js lint clean help
ENGINE ?= podman
IMAGE ?= privatebin/unit-testing:local
PRIVATEBIN ?= $(HOME)/git/PrivateBin
LOG = log
RUN = $(ENGINE) run --rm --read-only -v $(PRIVATEBIN):/srv:ro --tmpfs /tmp
# fail a recipe if any command in a pipe fails, not just the final tee
SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -c
all: build versions size test lint ## Equivalent to running `make build versions size test lint`.
$(LOG):
mkdir -p $(LOG)
build: | $(LOG) ## Build the image, using the dependencies of the PrivateBin repository, logs into log/build.log.
$(ENGINE) build --build-context privatebin=$(PRIVATEBIN) -t $(IMAGE) . 2>&1 | tee $(LOG)/build.log
versions: | $(LOG) ## Log installed PHP, extension, node & module versions into log/versions.log.
$(ENGINE) run --rm --entrypoint /bin/sh $(IMAGE) -c ' \
cat /etc/alpine-release; \
php -v; php -m; \
/usr/local/vendor/bin/phpunit --version; \
echo "node $$(node -v)"; \
node -e "const d = \"/usr/local/lib/\"; \
for (const m of Object.keys(require(d + \"package.json\").devDependencies)) \
console.log(m, require(d + \"node_modules/\" + m + \"/package.json\").version)"' \
2>&1 | tee $(LOG)/versions.log
size: | $(LOG) ## Log the image size into log/size.log.
$(ENGINE) image ls $(IMAGE) 2>&1 | tee $(LOG)/size.log
test: | $(LOG) ## Run both test suites, logs into log/test.log.
$(RUN) $(IMAGE) 2>&1 | tee $(LOG)/test.log
test-php: | $(LOG) ## Run phpunit only, logs into log/test-php.log.
$(RUN) $(IMAGE) phpunit 2>&1 | tee $(LOG)/test-php.log
test-js: | $(LOG) ## Run mocha only, logs into log/test-js.log.
$(RUN) $(IMAGE) mocha 2>&1 | tee $(LOG)/test-js.log
lint: | $(LOG) ## Run eslint, logs into log/lint.log.
$(RUN) $(IMAGE) eslint . 2>&1 | tee $(LOG)/lint.log
clean: ## Remove the logs.
rm -rf $(LOG)
help: ## Displays these usage instructions.
@echo "Usage: make <target(s)>"
@echo
@echo "Specify one or multiple of the following targets and they will be processed in the given order:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "%-16s%s\n", $$1, $$2}' $(MAKEFILE_LIST)