-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
140 lines (106 loc) · 3.49 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
ARGS_PHPUNIT ?=
DOCKER := $(if $(LRN_SDK_NO_DOCKER),,$(shell which docker))
DOCKER_COMPOSE := docker compose
# PHP Evolution
SUPPORTED_PHP_VERSIONS = 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
PHP_VERSION ?= $(lastword ${SUPPORTED_PHP_VERSIONS})
DEBIAN_VERSION-7.1 = buster
DEBIAN_VERSION-7.2 = buster
DEBIAN_VERSION-7.3 = bullseye
DEBIAN_VERSION-7.4 = bullseye
DEBIAN_VERSION-8.0 = bullseye
DEBIAN_VERSION-def = bookworm
DEBIAN_VERSION ?= $(or $(DEBIAN_VERSION-$(PHP_VERSION)),$(DEBIAN_VERSION-def))
COMPOSER_VERSION-7.1 = 2.2
COMPOSER_VERSION-def = 2.7.6
COMPOSER_VERSION ?= $(or $(COMPOSER_VERSION-$(PHP_VERSION)),$(COMPOSER_VERSION-def))
TARGETS = all build devbuild prodbuild \
quickstart check-quickstart install-vendor \
dist dist-test dist-zip release \
lint test test-coverage test-integration-env test-unit \
clean clean-dist clean-test clean-vendor
.PHONY: $(TARGETS)
.default: all
docker-build: install-vendor
$(DOCKER_COMPOSE) build php nginx
.PHONY: docker-build
# Local development targets without Docker
DIST_PREFIX = learnosity_sdk-
SRC_VERSION := $(shell git describe | sed s/^v//)
DIST = $(DIST_PREFIX)$(SRC_VERSION)
COMPOSER = composer
COMPOSER_INSTALL_FLAGS = --no-interaction --optimize-autoloader --classmap-authoritative
PHPCS= ./vendor/bin/phpcs
PHPUNIT = ./vendor/bin/phpunit
quickstart: $(if $(DOCKER),docker-build) $(if $(DOCKER),docker,local)-quickstart
docker-quickstart: VENDOR_FLAGS = --no-dev
docker-quickstart: install-vendor
$(DOCKER_COMPOSE) up -d
local-quickstart: VENDOR_FLAGS = --no-dev
local-quickstart: install-vendor
php -S localhost:8000 -t docs/quickstart
check-quickstart: vendor/autoload.php
$(COMPOSER) install $(COMPOSER_INSTALL_FLAGS) --no-dev;
###
# internal tooling rules
####
build: install-vendor
devbuild: build
prodbuild: VENDOR_FLAGS = --no-dev
prodbuild: install-vendor
release:
@./release.sh
lint: build
$(PHPCS) src
test: build
$(PHPUNIT) $(if $(subst 7.1,,$(PHP_TARGET)),--do-not-cache-result) $(ARGS_PHPUNIT)
test-coverage: build
XDEBUG_MODE=coverage $(PHPUNIT) --do-not-cache-result $(ARGS_PHPUNIT)
test-unit: build
$(PHPUNIT) --do-not-cache-result --testsuite unit $(ARGS_PHPUNIT)
test-integration-env: build
$(PHPUNIT) --do-not-cache-result --testsuite integration $(ARGS_PHPUNIT)
###
# dist rules
###
dist: dist-test
dist-zip: clean-test clean-dist
mkdir -p .$(DIST)
cp -R * .version .$(DIST)
mv .$(DIST) $(DIST)
rm -rf $(DIST)/vendor/
$(COMPOSER) install --working-dir=$(DIST) $(COMPOSER_INSTALL_FLAGS) --no-dev
rm -rf $(DIST)/release.sh
zip -qr $(DIST).zip $(DIST)
dist-test: dist-zip install-vendor
$(PHPUNIT) --do-not-cache-result --no-logging --configuration=$(DIST)/phpunit.xml
###
# install vendor rules
###
install-vendor: composer.lock
composer.lock: composer.json
$(COMPOSER) install $(COMPOSER_INSTALL_FLAGS) $(VENDOR_FLAGS)
clean: clean-dist clean-test clean-vendor
rm -rf $(DIST_PREFIX)*.zip
$(DOCKER_COMPOSE) down -v
clean-dist:
rm -rf $(DIST_PREFIX)*/
clean-test:
test ! -f tests/junit.xml || rm -f tests/junit.xml
test ! -f tests/coverage.xml || rm -f tests/coverage.xml
test ! -d tests/coverage || rm -rf tests/coverage
clean-vendor:
rm -rf vendor
rm -f composer.lock
# Package contents
PKG_CONTENTS = .version \
CONTRIBUTING.md LICENSE.md README.md REFERENCE.md ChangeLog.md \
composer.json bootstrap.php phpunit.xml \
docs src
$(DIST):
mkdir -p $(DIST)
cp -R $(PKG_CONTENTS) $(DIST)
$(DIST)/vendor: $(DIST)
cd $(DIST) && $(COMPOSER) install $(COMPOSER_INSTALL_FLAGS) --no-dev
$(DIST).zip: $(DIST)/vendor
zip -qr $(DIST).zip $(DIST)