@@ -5,42 +5,47 @@ PSALM := php build/psalm.phar
55CMDS = $(wildcard src/Command/* .php)
66
77.PHONY :test
8- test : test-fixer psalm test-phpunit check-docs
8+ test : check-init test-fixer psalm test-phpunit check-docs
99
1010.PHONY :test-fixer
11- test-fixer : build/php-cs-fixer.phar
11+ test-fixer : check-init
1212 $(FIXER ) fix -v || true
1313
1414.PHONY :test-phpunit
15- test-phpunit : vendor/autoload.php
15+ test-phpunit : check-init
1616 $(PHPUNIT ) --verbose
1717
1818.PHONY :validate
19- validate : build/php-cs-fixer.phar vendor/autoload.php psalm check-docs
19+ validate : check-init psalm check-docs
2020 $(FIXER ) fix --dry-run --stop-on-violation
2121 $(COMPOSER ) validate
2222 phpdbg --version
2323 phpdbg -d memory_limit=-1 -qrr $(PHPUNIT ) --coverage-text
2424
25+ .PHONY :build
26+ build : build/moodle-plugin-ci.phar
27+
2528.PHONY :psalm
26- psalm : build/psalm.phar
29+ psalm : check-init
2730 $(PSALM )
2831
2932.PHONY :psalm-update-baseline
30- psalm-update-baseline : build/psalm.phar
33+ psalm-update-baseline : check-init
3134 $(PSALM ) --update-baseline
3235
3336.PHONY :check-docs
3437check-docs : docs/CLI.md
3538 @echo " CHECKING if 'docs/CLI.md' needs to be committed due to changes. If this fails, simply commit the changes."
3639 git diff-files docs/CLI.md
3740
38- # Downloads everything we need for testing, used by Travis .
41+ # Setup for testing.
3942.PHONY : init
40- init : vendor/autoload.php build/php-cs-fixer.phar build/psalm.phar
43+ init : build/php-cs-fixer.phar build/psalm.phar composer.lock composer.json
44+ $(COMPOSER ) selfupdate
45+ $(COMPOSER ) install --no-suggest --no-progress
4146
4247.PHONY : update
43- update : build/php-cs-fixer.phar
48+ update : check-init build/php-cs-fixer.phar build/psalm .phar
4449 $(COMPOSER ) selfupdate
4550 $(FIXER ) selfupdate
4651 $(COMPOSER ) update
@@ -52,6 +57,12 @@ clean:
5257 rm -rf vendor
5358 rm -f .php_cs.cache
5459
60+ # Output error if not initialised.
61+ check-init :
62+ ifeq (, $(wildcard vendor) )
63+ $(error Run 'make init' first)
64+ endif
65+
5566# Update download URL from https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases
5667build/php-cs-fixer.phar :
5768 curl -LSs https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.14.2/php-cs-fixer.phar -o build/php-cs-fixer.phar
@@ -65,14 +76,9 @@ build/box.phar:
6576
6677build/moodle-plugin-ci.phar : build/box.phar
6778 $(COMPOSER ) install --no-dev --prefer-dist --classmap-authoritative --quiet
68- php -d phar.readonly=false build/box.phar build
79+ php -d memory_limit=-1 -d phar.readonly=false build/box.phar build
6980 $(COMPOSER ) install --prefer-dist --quiet
7081
71- vendor/autoload.php : composer.lock composer.json
72- $(COMPOSER ) self-update
73- $(COMPOSER ) install --no-suggest --no-progress
74- touch $@
75-
7682docs/CLI.md : $(CMDS )
7783 @rm -f $@
7884 @echo " ---" >> $@
0 commit comments