Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit d2e9df4

Browse files
authored
Merge pull request repejota#98 from repejota/feature/better_makefile
Feature/better makefile
2 parents 099c082 + 348657f commit d2e9df4

3 files changed

Lines changed: 35 additions & 26 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ cache:
1313
before_install:
1414
- docker run -d -p 4222:4222 --name nats nats
1515
before_script:
16+
- make dist-clean
1617
- make deps
18+
- make dev-deps
1719
script:
1820
- mkdir -p build/logs
1921
- make lint

Makefile

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1+
PHPCS_PHAR = https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
2+
COMPOSER_PHAR = https://getcomposer.org/composer.phar
3+
PHPDOCUMENTOR_PHAR_URL = https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar
4+
CLEAN_FILES = composer.phar composer.lock phpDocumentor.phar phpcs.phar phpcbf.phar
5+
CLEAN_FOLDERS = bin build cover vendor docs/api
6+
CLEAN_PATHS = $(CLEAN_FILES) $(CLEAN_FOLDERS)
7+
SOURCE_CODE_PATHS = src test examples
8+
API_DOCS_PATH = ./docs/api
9+
COVERAGE_PATH = ./cover
10+
11+
define require_phar
12+
@[ -f ./$(1) ] || wget -q $(2) -O ./$(1) && chmod +x $(1);
13+
endef
14+
115
lint: lint-php lint-psr2 lint-squiz
216

317
.PHONY: lint-php
418
lint-php:
5-
find src -name *.php -exec php -l {} \;
6-
find test -name *.php -exec php -l {} \;
7-
find spec -name *.php -exec php -l {} \;
8-
find examples -name *.php -exec php -l {} \;
19+
find $(SOURCE_CODE_PATHS) spec -name *.php -exec php -l {} \;
920

1021
.PHONY: lint-psr2
1122
lint-psr2:
12-
#./vendor/bin/phpcbf --standard=PSR2 src test examples
13-
./vendor/bin/phpcs --standard=PSR2 --colors -w -s --warning-severity=0 src test examples
23+
$(call require_phar,phpcs.phar,$(PHPCS_PHAR))
24+
./phpcs.phar --standard=PSR2 --colors -w -s --warning-severity=0 $(SOURCE_CODE_PATHS)
1425

1526
.PHONY: lint-squiz
1627
lint-squiz:
17-
# ./vendor/bin/phpcbf --standard=Squiz,./ruleset.xml src test examples
18-
./vendor/bin/phpcs --standard=Squiz,./ruleset.xml --colors -w -s --warning-severity=0 src test examples
28+
$(call require_phar,phpcs.phar,$(PHPCS_PHAR))
29+
./phpcs.phar --standard=Squiz,./ruleset.xml --colors -w -s --warning-severity=0 $(SOURCE_CODE_PATHS)
1930

2031

2132
test: test-tdd test-bdd
@@ -29,28 +40,25 @@ test-bdd:
2940
./vendor/bin/phpspec run --format=pretty -v
3041

3142
cover:
32-
./vendor/bin/phpunit --coverage-html ./cover test
43+
./vendor/bin/phpunit --coverage-html $(COVERAGE_PATH) test
3344

3445
deps:
35-
wget -q https://getcomposer.org/composer.phar -O ./composer.phar
36-
chmod +x composer.phar
37-
php composer.phar install
46+
$(call require_phar,composer.phar,$(COMPOSER_PHAR))
47+
./composer.phar install --no-dev
48+
49+
dev-deps:
50+
$(call require_phar,composer.phar,$(COMPOSER_PHAR))
51+
./composer.phar install
3852

3953
dist-clean:
40-
rm -rf bin
41-
rm -rf vendor
42-
rm -f composer.phar
43-
rm -f composer.lock
44-
rm -f phpDocumentor.phar
45-
rm -rf docs/api
54+
rm -rf $(CLEAN_PATHS)
4655

4756
docker-nats:
4857
docker run --rm -p 8222:8222 -p 4222:4222 -d --name nats-main nats
4958

5059
phpdoc:
51-
wget -q https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar -O ./phpDocumentor.phar
52-
chmod +x phpDocumentor.phar
53-
./phpDocumentor.phar -d ./src/ -t ./docs/api --template=checkstyle --template=responsive-twig
60+
$(call require_phar,phpdoc.phar,$(PHPDOCUMENTOR_PHAR_URL))
61+
./phpdoc.phar -d ./src/ -t $(API_DOCS_PATH) --template=checkstyle --template=responsive-twig
5462

5563
serve-phpdoc:
56-
cd docs/api && php -S localhost:8000 && cd ../..
64+
cd $(API_DOCS_PATH) && php -S localhost:8000 && cd ../..

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
"minimum-stability": "dev",
66
"license": "MIT",
77
"require": {
8-
"ircmaxell/random-lib": "^1.1"
8+
"ircmaxell/random-lib": "^1.2"
99
},
1010
"require-dev": {
1111
"phpunit/phpunit": "5.*",
12-
"satooshi/php-coveralls": "dev-master",
13-
"squizlabs/php_codesniffer": "~2.0",
14-
"phpspec/phpspec": "~2.0"
12+
"phpspec/phpspec": "^3.0",
13+
"satooshi/php-coveralls": "dev-master"
1514
},
1615
"authors": [
1716
{

0 commit comments

Comments
 (0)