-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (50 loc) · 1.9 KB
/
Copy pathMakefile
File metadata and controls
65 lines (50 loc) · 1.9 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
55
56
57
58
59
60
61
62
63
64
# By default, Makefiles are executed with /bin/sh, which may not support certain
# features like `$(shell ...)` or `$(if ...)`. To ensure compatibility, we
# explicitly set the shell to bash.
SHELL := /bin/bash
# Set bash shell flags for strict error handling
# -e: Exit immediately if a command exits with a non-zero status.
# -u: Treat unset variables as an error and exit immediately.
# -o pipefail: Make pipelines (e.g. `printenv | sort` ) fail if any command in the pipeline fails.
# -c: read the command from the following string (required).
.SHELLFLAGS := -euo pipefail -c
.DEFAULT_GOAL := all
BUILD_DIR := build
BUILD_DIR_STAMP := $(BUILD_DIR)/.install
# Detect if we are in a TTY
IS_TTY := $(shell [ -t 1 ] && echo 1 || echo 0)
DOCKER_USER ?= $(shell id -u):$(shell id -g)
DOCKER_RUN_IMAGE ?= composer:latest
DOCKER_RUN_PULL_IMAGE ?= missing
DOCKER_RUN_FLAGS = --rm $(if $(IS_TTY),--tty) --pull="$(DOCKER_RUN_PULL_IMAGE)" --volume="./:/app"
docker-run = docker run $(DOCKER_RUN_FLAGS) --user="$(DOCKER_USER)" $(DOCKER_RUN_IMAGE)
.PHONY: all
all: vendor/autoload.php $(BUILD_DIR_STAMP)
$(BUILD_DIR_STAMP):
mkdir --parents build
echo $(date --iso-8601=seconds --utc) > $(BUILD_DIR_STAMP)
vendor/autoload.php: $(BUILD_DIR_STAMP)
$(MAKE) install
touch "$@"
.PHONY: clean
clean:
rm -rf ./build ./vendor
bash: DOCKER_RUN_FLAGS += --interactive
bash: $(BUILD_DIR_STAMP)
$(docker-run) bash
.PHONY: install
install: $(BUILD_DIR_STAMP)
$(docker-run) composer install
.PHONY: update
update: vendor/autoload.php
$(docker-run) composer update --with-all-dependencies
.PHONY: upgrade
upgrade: vendor/autoload.php
$(docker-run) composer require --update-with-all-dependencies \
dealerdirect/phpcodesniffer-composer-installer \
slevomat/coding-standard \
squizlabs/php_codesniffer
.PHONY: test
test: vendor/autoload.php
$(docker-run) find ./tests -type f -name *.php -exec php -l {} +
$(docker-run) vendor/bin/phpcs