-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 1.87 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
DATE = $(shell date +%F)
REPO_URL = https://github.com/club-1/flarum-ext-chore-commands
INTERACTIVE := $(shell [ -t 0 ] && echo 1)
PHPSTANFLAGS += $(if $(INTERACTIVE),,--no-progress) $(if $(INTERACTIVE)$(CI),,--error-format=raw)
PHPUNITFLAGS += $(if $(INTERACTIVE)$(CI),--coverage-text,--colors=never)
export FLARUM_TEST_TMP_DIR ?= tests/integration/tmp
export DB_USERNAME ?= $(USER)
all: vendor;
dev: vendor;
vendor: composer.json composer.lock
composer install
touch $@
$(FLARUM_TEST_TMP_DIR): vendor
composer test:setup
touch $@
# Create a new release
bump = echo '$2' | awk 'BEGIN{FS=OFS="."} {$$$1+=1; for (i=$1+1; i<=3; i++) $$i=0} 1'
releasepatch: V := 3
releaseminor: V := 2
releasemajor: V := 1
release%: PREVTAG = $(shell git describe --tags --abbrev=0)
release%: TAG = v$(shell $(call bump,$V,$(PREVTAG:v%=%)))
release%: CONFIRM_MSG = Create release $(TAG)
releasepatch releaseminor releasemajor: release%: .confirm check all
sed -i CHANGELOG.md \
-e '/^## \[unreleased\]/s/$$/\n\n## [$(TAG)] - $(DATE)/' \
-e '/^\[unreleased\]/{s/$(PREVTAG)/$(TAG)/; s#$$#\n[$(TAG)]: $(REPO_URL)/releases/tag/$(TAG)#}'
git add CHANGELOG.md
git commit -m $(TAG)
git push
git tag $(TAG)
git push --tags
check: analyse test;
analyse: analysephp;
analysephp: vendor
vendor/bin/phpstan analyse $(PHPSTANFLAGS)
test: testintegration;
#test: testunit testintegration;
testunit testintegration: export XDEBUG_MODE=coverage
testunit testintegration: test%: vendor $(FLARUM_TEST_TMP_DIR)
composer test:$* -- --coverage-cache=tests/.phpunit.cov.cache --coverage-clover=tests/.phpunit.$*.cov.xml $(PHPUNITFLAGS)
clean: cleancache
rm -rf vendor
cleancache:
rm -rf tests/.phpunit*
.confirm:
@echo -n "$(CONFIRM_MSG)? [y/N] " && read ans && [ $${ans:-N} = y ]
.PHONY: all dev releasepatch releaseminor releasemajor check analyse analysephp test testunit testintegration clean cleancache .confirm