Skip to content

Commit 78d39ee

Browse files
committed
Makefile improvements.
* `make init` is compulsory to run before any test/validate command
1 parent b3613d1 commit 78d39ee

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Build PHAR
2323
run: |
24-
make build/moodle-plugin-ci.phar
24+
make build
2525
php build/moodle-plugin-ci.phar list
2626
2727
- name: Create Release

Makefile

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,47 @@ PSALM := php build/psalm.phar
55
CMDS = $(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
3437
check-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
5667
build/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

6677
build/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-
7682
docs/CLI.md: $(CMDS)
7783
@rm -f $@
7884
@echo "---" >> $@

0 commit comments

Comments
 (0)