Skip to content

Commit

Permalink
allow a pool to instantly run processes/runs (#15)
Browse files Browse the repository at this point in the history
* allow a pool to instantly run processes/runs

* update makefile to current best practice

* add composer php version setting

* set composer file to php version

* some fixes, tidy makefile a tiny bit

* doc comment tidy

* handle multple lines as response

* split child output on new line

* filter out blank lines
  • Loading branch information
Harry Bragg authored May 22, 2018
1 parent c649ab1 commit 71b5802
Show file tree
Hide file tree
Showing 10 changed files with 678 additions and 408 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ language: php

dist: trusty

## Cache composer bits
cache:
directories:
- $HOME/.composer/cache/files

php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- 7.2
- nightly

env:
Expand All @@ -24,6 +22,7 @@ matrix:
- php: nightly

before_script:
- composer config platform.php $(php -r "echo PHP_VERSION;")
- travis_retry composer update --no-interaction --prefer-dist $PREFER_LOWEST

script:
Expand Down
67 changes: 30 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
SHELL = /bin/sh

DOCKER ?= $(shell which docker)
PHP_VER := 7.2
IMAGE := graze/php-alpine:${PHP_VER}-test
VOLUME := /srv
IMAGE ?= graze/php-alpine:test
DOCKER_RUN := ${DOCKER} run --rm -t -v $$(pwd):${VOLUME} -w ${VOLUME} ${IMAGE}
DOCKER_RUN_BASE := ${DOCKER} run --rm -t -v $$(pwd):${VOLUME} -w ${VOLUME}
DOCKER_RUN := ${DOCKER_RUN_BASE} ${IMAGE}

PREFER_LOWEST ?=

.PHONY: build build-update composer-% clean help run
.PHONY: lint lint-fix
.PHONY: test test-unit test-lowest test-matrix test-coverage test-coverage-html test-coverage-clover
.PHONY: install composer clean help run
.PHONY: test lint lint-fix test-unit test-integration test-matrix test-coverage test-coverage-html test-coverage-clover

.SILENT: help

# Building

build: ## Download the dependencies then build the image :rocket:.
make 'composer-install --prefer-dist --optimize-autoloader'
build: ## Install the dependencies
build: ensure-composer-file
make 'composer-install --optimize-autoloader --prefer-dist ${PREFER_LOWEST}'

build-update: ## Update all dependencies
make 'composer-update --prefer-dist --optimize-autoloader ${PREFER_LOWEST}'
build-update: ## Update the dependencies
build-update: ensure-composer-file
make 'composer-update --optimize-autoloader --prefer-dist ${PREFER_LOWEST}'

ensure-composer-file: # Update the composer file
make 'composer-config platform.php ${PHP_VER}'

composer-%: ## Run a composer command, `make "composer-<command> [...]"`.
${DOCKER} run -t --rm \
-v $$(pwd):/app \
-v ~/.composer:/tmp \
-v $$(pwd):/app:delegated \
-v ~/.composer:/tmp:delegated \
-v ~/.ssh:/root/.ssh:ro \
composer --ansi --no-interaction $* $(filter-out $@,$(MAKECMDGOALS))

# Testing

test: ## Run the unit and integration testsuites.
test: ## Run the unit testsuites.
test: lint test-unit

lint: ## Run phpcs against the code.
Expand All @@ -39,40 +46,26 @@ lint-fix: ## Run phpcsf and fix possible lint errors.
${DOCKER_RUN} vendor/bin/phpcbf -p src/ tests/

test-unit: ## Run the unit testsuite.
${DOCKER_RUN} vendor/bin/phpunit --testsuite unit

test-examples: ## Test the pre-build examples
test-examples: test-example-table test-example-lines

test-example-table: ## Run the example application
${DOCKER_RUN} php tests/example/table.php
${DOCKER_RUN} vendor/bin/phpunit --colors=always --testsuite unit

test-example-lines: ## Run the example application
${DOCKER_RUN} php tests/example/lines.php

test-lowest: ## Test using the lowest possible versions of the dependencies
test-lowest: PREFER_LOWEST=--prefer-lowest --prefer-stable
test-lowest: build-update test
test-matrix-lowest: ## Test all version, with the lowest version
${MAKE} test-matrix PREFER_LOWEST=--prefer-lowest
${MAKE} build-update

test-matrix: ## Run the unit tests against multiple targets.
${MAKE} IMAGE="php:5.6-alpine" test
${MAKE} IMAGE="php:7.0-alpine" test
${MAKE} IMAGE="php:7.1-alpine" test
${MAKE} IMAGE="hhvm/hhvm:latest" test

test-matrix-lowest: ## Run the unit tests against
${MAKE} build-update PREFER_LOWEST='--prefer-lowest --prefer-stable'
${MAKE} test-matrix
${MAKE} build-update
${MAKE} PHP_VER="5.6" build-update test
${MAKE} PHP_VER="7.0" build-update test
${MAKE} PHP_VER="7.1" build-update test
${MAKE} PHP_VER="7.2" build-update test

test-coverage: ## Run all tests and output coverage to the console.
${DOCKER_RUN} phpdbg7 -qrr vendor/bin/phpunit --coverage-text
${DOCKER_RUN_BASE} ${IMAGE} phpdbg7 -qrr vendor/bin/phpunit --coverage-text

test-coverage-html: ## Run all tests and output coverage to html.
${DOCKER_RUN} phpdbg7 -qrr vendor/bin/phpunit --coverage-html=./tests/report/html
${DOCKER_RUN_BASE} ${IMAGE} phpdbg7 -qrr vendor/bin/phpunit --coverage-html=./tests/report/html

test-coverage-clover: ## Run all tests and output clover coverage to file.
${DOCKER_RUN} phpdbg7 -qrr vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover
${DOCKER_RUN_BASE} ${IMAGE} phpdbg7 -qrr vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover

# Help

Expand Down
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"graze/console-diff-renderer": "^0.6.1"
},
"require-dev": {
"phpunit/phpunit": "^4.2 | ^5.2",
"squizlabs/php_codesniffer": "^2.9",
"graze/standards": "^1.0",
"symfony/console": "^3.1",
"mockery/mockery": "^0.9.9"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^5.7.21|^6|^7",
"squizlabs/php_codesniffer": "^3",
"graze/standards": "^2",
"symfony/console": "^3.1 | ^4"
},
"suggest": {
"symfony/console": "To use the Table to print current runs"
Expand All @@ -47,5 +47,10 @@
"Graze\\ParallelProcess\\Test\\Unit\\": "tests/unit",
"Graze\\ParallelProcess\\Test\\Integration\\": "tests/integration"
}
},
"config": {
"platform": {
"php": "7.2"
}
}
}
Loading

0 comments on commit 71b5802

Please sign in to comment.