-
Notifications
You must be signed in to change notification settings - Fork 46
/
Makefile
92 lines (75 loc) · 2.25 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
COMPOSER := composer
PHPUNIT := vendor/bin/phpunit
FIXER := vendor/bin/php-cs-fixer
PSALM := vendor/bin/psalm
CMDS = $(wildcard src/Command/*.php)
.PHONY:test
test: check-init test-fixer psalm test-phpunit check-docs
.PHONY:test-fixer
test-fixer: check-init
$(FIXER) fix -v || true
.PHONY:test-phpunit
test-phpunit: check-init
$(PHPUNIT) --verbose
.PHONY:validate
validate: check-init validate-version psalm check-docs
$(FIXER) fix --dry-run --stop-on-violation
$(COMPOSER) validate
XDEBUG_MODE=coverage $(PHPUNIT) --verbose --coverage-text
.PHONY:coverage-phpunit
coverage-phpunit: check-init
XDEBUG_MODE=coverage $(PHPUNIT) --verbose --coverage-clover build/logs/clover.xml
.PHONY:build
build: build/moodle-plugin-ci.phar
.PHONY:validate-version
validate-version:
bin/validate-version
.PHONY:psalm
psalm: check-init
$(PSALM) --show-info=true
.PHONY:psalm-update-baseline
psalm-update-baseline: check-init
$(PSALM) --update-baseline
.PHONY:check-docs
check-docs: docs/CLI.md
@echo "CHECKING if 'docs/CLI.md' needs to be committed due to changes. If this fails, simply commit the changes."
git diff-files docs/CLI.md
# Setup for testing.
.PHONY: init
init: composer.lock composer.json
$(COMPOSER) selfupdate
$(COMPOSER) install --no-progress
.PHONY: update
update: check-init
$(COMPOSER) selfupdate
$(FIXER) selfupdate
$(COMPOSER) update
.PHONY: clean
clean:
rm -f build/*.phar
rm -rf build/logs
rm -rf vendor
rm -f .php_cs.cache
rm -rf .psalm.cache
# Output error if not initialised.
check-init:
ifeq (, $(wildcard vendor))
$(error Run 'make init' first)
endif
build/box.phar:
curl -LSs https://github.com/box-project/box/releases/download/4.3.8/box.phar -o build/box.phar
build/moodle-plugin-ci.phar: build/box.phar
$(COMPOSER) install --no-dev --prefer-dist --classmap-authoritative --quiet
php -d memory_limit=-1 -d phar.readonly=false build/box.phar compile
$(COMPOSER) install --prefer-dist --quiet
docs/CLI.md: $(CMDS)
@rm -f $@
@echo "---" >> $@
@echo "layout: page" >> $@
@echo "title: Moodle Plugin CI Commands" >> $@
@echo "---" >> $@
@echo "" >> $@
@echo "<!-- AUTOMATICALLY GENERATED VIA: make $@ -->" >> $@
@php bin/moodle-plugin-ci list --format md | sed 1,2d >> $@
@sed -i "s~${PWD}~/path/to~" $@
@echo "REGENERATED $@"