Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events events events #16

Merged
merged 15 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: php

dist: trusty

## Cache composer bits
cache:
directories:
- $HOME/.composer/cache/files
Expand Down
30 changes: 22 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL = /bin/sh

DOCKER ?= $(shell which docker)
DOCKER = $(shell which docker)
PHP_VER := 7.2
IMAGE := graze/php-alpine:${PHP_VER}-test
VOLUME := /srv
Expand All @@ -9,8 +9,9 @@ DOCKER_RUN := ${DOCKER_RUN_BASE} ${IMAGE}

PREFER_LOWEST ?=

.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
.PHONY: build build-update composer-% clean help run
.PHONY: lint lint-fix
.PHONY: test test-unit test-integration test-lowest test-matrix test-coverage test-coverage-html test-coverage-clover

.SILENT: help

Expand All @@ -36,7 +37,7 @@ composer-%: ## Run a composer command, `make "composer-<command> [...]"`.

# Testing

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

lint: ## Run phpcs against the code.
Expand All @@ -46,7 +47,11 @@ 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 --colors=always --testsuite unit
${DOCKER_RUN} vendor/bin/phpunit --testsuite unit

test-lowest: ## Test using the lowest possible versions of the dependencies
test-lowest: PREFER_LOWEST=--prefer-lowest
test-lowest: build-update test

test-matrix-lowest: ## Test all version, with the lowest version
${MAKE} test-matrix PREFER_LOWEST=--prefer-lowest
Expand All @@ -59,13 +64,22 @@ test-matrix: ## Run the unit tests against multiple targets.
${MAKE} PHP_VER="7.2" build-update test

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

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

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


# Examples

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

example-table: ## Run the table example
${DOCKER_RUN} php tests/example/table.php

# Help

Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ Run multiple `Synfony\Process`'s at the same time.

Via Composer

``` bash
```bash
$ composer require graze/parallel-process
```

If you want to use Tables or Lines to output to the console, include:

```bash
$ composer require graze/console-diff-renderer
```

## Usage

``` php
Expand All @@ -41,11 +47,12 @@ $pool->run(); // blocking that will run till it finishes
Visual output of the parallel processes

```php
$table = new Table($output);
$pool = new \Graze\ParallelProcess\Pool();
for ($i = 0; $i < 5; $i++) {
$time = $i + 5;
$table->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' => $time]);
$pool->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' => $time]);
}
$table = new \Graze\ParallelProcess\Table($output, $pool);
$table->run();
```

Expand All @@ -58,11 +65,11 @@ Write the output of each process to the screen
```php
$pool = new \Graze\ParallelProcess\Pool();
$pool->setMaxSimultaneous(3);
$lines = new Lines($output, $pool);
for ($i = 0; $i < 5; $i++) {
$time = $i + 5;
$lines->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' . $time]);
$pool->add(new Process(sprintf('for i in `seq 1 %d` ; do date ; sleep 1 ; done', $time)), ['sleep' . $time]);
}
$lines = new \Graze\ParallelProcess\Lines($output, $pool);
$lines->run();
```

Expand Down
106 changes: 54 additions & 52 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
{
"name": "graze/parallel-process",
"description": "run a pool of processes simultaneously",
"keywords": [
"graze",
"parallel-process"
],
"homepage": "https://github.com/graze/parallel-process",
"license": "MIT",
"authors": [
{
"name": "Harry Bragg",
"email": "harry.bragg@graze.com",
"role": "Developer"
},
{
"name": "Graze Developers",
"email": "developers@graze.com",
"homepage": "http://www.graze.com",
"role": "Development Team"
}
],
"require": {
"php": "^5.5 | ^7.0",
"symfony/process": "^2.8 | ^3.2 | ^4.0",
"graze/data-structure": "^2.0",
"graze/console-diff-renderer": "^0.6.1"
"name": "graze/parallel-process",
"description": "run a pool of processes simultaneously",
"keywords": [
"graze",
"parallel-process"
],
"homepage": "https://github.com/graze/parallel-process",
"license": "MIT",
"authors": [
{
"name": "Harry Bragg",
"email": "harry.bragg@graze.com",
"role": "Developer"
},
"require-dev": {
"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"
},
"autoload": {
"psr-4": {
"Graze\\ParallelProcess\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Graze\\ParallelProcess\\Test\\": "tests/src",
"Graze\\ParallelProcess\\Test\\Unit\\": "tests/unit",
"Graze\\ParallelProcess\\Test\\Integration\\": "tests/integration"
}
},
"config": {
"platform": {
"php": "7.2"
}
{
"name": "Graze Developers",
"email": "developers@graze.com",
"homepage": "http://www.graze.com",
"role": "Development Team"
}
],
"require": {
"php": "^5.5 | ^7.0",
"symfony/process": "^2.8 | ^3.2 | ^4.0",
"graze/data-structure": "^2.0",
"symfony/event-dispatcher": "^2.8 | ^3.2 | ^4.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^5.7.21|^6|^7",
"squizlabs/php_codesniffer": "^3",
"graze/standards": "^2",
"symfony/console": "^3.1 | ^4",
"graze/console-diff-renderer": "^0.6.1"
},
"suggest": {
"symfony/console": "To use the Table to print current runs",
"graze/console-diff-renderer": "required to use Table and Lines"
},
"autoload": {
"psr-4": {
"Graze\\ParallelProcess\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Graze\\ParallelProcess\\Test\\": "tests/src",
"Graze\\ParallelProcess\\Test\\Unit\\": "tests/unit",
"Graze\\ParallelProcess\\Test\\Integration\\": "tests/integration"
}
},
"config": {
"platform": {
"php": "7.2"
}
}
}
65 changes: 64 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ This file is part of graze/parallel-process.
~
~ Copyright (c) 2017 Nature Delivered Ltd. <https://www.graze.com>
~ Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com>
~
~ For the full copyright and license information, please view the LICENSE
~ file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
~ This file is part of graze/parallel-process.
~
~ Copyright (c) 2017 Nature Delivered Ltd. <https://www.graze.com>
~ Copyright © 2018 Nature Delivered Ltd. <https://www.graze.com>
~
~ For the full copyright and license information, please view the LICENSE
~ file that was distributed with this source code.
Expand Down
Loading