Skip to content

Commit

Permalink
Expanded test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ace411 committed Aug 6, 2021
2 parents e811d69 + 13387c4 commit b96b7d9
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4']
php: ['7.2', '7.3', '7.4', '8.0']
name: PHP ${{ matrix.php }}
steps:
- uses: actions/checkout@v1
Expand Down
23 changes: 23 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->exclude(['vendor', 'cache', 'bin'])
->in(__DIR__);

$config = new Config;

return $config
->setRules([
'@PSR12' => true,
'linebreak_after_opening_tag' => true,
'binary_operator_spaces' => [
'operators' => ['=>' => 'align', '=' => 'align'],
],
])
->setFinder($finder)
->setIndent(' ');
41 changes: 0 additions & 41 deletions .php_cs

This file was deleted.

14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"concurrently",
"concurrent processes",
"concurrent execution",
"single terminal",
"single console window",
"js concurrently",
"asynchronous",
"reactive programming",
"rxphp",
Expand All @@ -25,7 +28,7 @@
],
"require": {
"alecrabbit/php-cli-snake": "~0",
"chemem/bingo-functional": "~1",
"chemem/bingo-functional": "~2",
"clue/mq-react": "~1",
"mmarica/display-table": "~1",
"php-parallel-lint/php-console-color": "~1",
Expand All @@ -40,8 +43,8 @@
"seregazhuk/react-promise-testing": "~0"
},
"suggest": {
"ext-uv": "A high performance event-loop written in C",
"ext-event": "An interface to the event library written in C"
"ext-event": "An interface to the event library written in C",
"ext-uv": "A high performance event-loop written in C"
},
"autoload": {
"psr-4": {
Expand All @@ -62,8 +65,7 @@
"concurrently"
],
"scripts": {
"cs:fix": "php-cs-fixer fix --config=.php_cs --diff --verbose --allow-risky=yes",
"cs:fix-dry": "php-cs-fixer fix --config=.php_cs --diff --verbose --dry-run --allow-risky=yes",
"cs:fix": "php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose --allow-risky=yes",
"test": "phpunit -c phpunit.xml.dist"
}
}
}
2 changes: 1 addition & 1 deletion concurrently
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use React\EventLoop\Factory;
use Rx\Scheduler;
use Chemem\{
Concurrently\Console as c,
Bingo\Functional\Algorithms as f,
Bingo\Functional as f,
Bingo\Functional\Functors\Monads\IO,
};

Expand Down
2 changes: 1 addition & 1 deletion src/Console/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* constants.php
* Important Console constants
*
*
* @author Lochemem Bruno Michael
* @license Apache-2.0
*/
Expand Down
98 changes: 46 additions & 52 deletions src/Console/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Console functions
*
*
* @author Lochemem Bruno Michael
* @license Apache-2.0
*/
Expand All @@ -11,38 +11,32 @@

namespace Chemem\Concurrently\Console;

use \Chemem\Bingo\Functional\{
Algorithms as f,
Functors\Either,
Functors\Monads\IO,
Functors\Monads as m,
PatternMatching as p,
};
use Chemem\Concurrently\Proc\{
Handler,
TransientObservable,
};
use \AlecRabbit\Snake\{
Spinner,
Contracts\Color,
};
use \Mmarica\DisplayTable;
use \Rx\Observer\CallbackObserver;
use \React\EventLoop\LoopInterface;
use \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
use Chemem\Bingo\Functional as f;
use Chemem\Bingo\Functional\Functors\Monads\Either;
use Chemem\Bingo\Functional\Functors\Monads\IO;
use Chemem\Bingo\Functional\Functors\Monads as m;
use Chemem\Bingo\Functional\PatternMatching as p;
use Chemem\Concurrently\Proc\Handler;
use Chemem\Concurrently\Proc\TransientObservable;
use AlecRabbit\Snake\Spinner;
use AlecRabbit\Snake\Contracts\Color;
use Mmarica\DisplayTable;
use Rx\Observer\CallbackObserver;
use React\EventLoop\LoopInterface;
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;

/**
* parse
* parse Console input
*
* parse :: String -> IO ()
*
*
* @param string $input
* @return IO
* @example
*
*
* parse('--help')
* // => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
* => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
*/
function parse(LoopInterface $loop, string $input): IO
{
Expand All @@ -54,7 +48,7 @@ function parse(LoopInterface $loop, string $input): IO
});
// IO-composed help info print functions
$help = $print(parseHelpCmd);

$matches = p\match([
'(x:_)' => function (string $opt) use ($help, $version) {
return p\patternMatch([
Expand Down Expand Up @@ -113,15 +107,15 @@ function parse(LoopInterface $loop, string $input): IO
* prints a SQL-esque table
*
* printTable :: String -> [a] -> String
*
*
* @param string $header
* @param array $body
* @param integer $vpadding
* @return string
* @example
*
*
* printTable(['Print help' => 'concurrently --help'], 1.2, 1)
* // => Print help concurrently --help
* => Print help concurrently --help
*/
function printTable(
array $body,
Expand All @@ -142,20 +136,20 @@ function printTable(
/**
* applyTextColor
* creates colored text
*
*
* applyTextColor :: String -> String -> String
*
*
* @param string $text
* @param string $color
* @return string
* @example
*
*
* applyTextColor('foo', 'cyan')
* // => \033[36foom
* => \033[36foom
*/
function applyTextColor(string $text, string $color = 'none'): string
{
return (new ConsoleColor)->apply($color, $text);
return (new ConsoleColor())->apply($color, $text);
}

const applyTextColor = __NAMESPACE__ . '\\applyTextColor';
Expand All @@ -165,12 +159,12 @@ function applyTextColor(string $text, string $color = 'none'): string
* prints help command information
*
* parseHelpCmd :: IO ()
*
*
* @return IO
* @example
*
*
* parseHelpCmd()
* // => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
* => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
*/
function parseHelpCmd(): IO
{
Expand All @@ -193,13 +187,13 @@ function parseHelpCmd(): IO
* losslessly converts console arguments to more descriptive key-value pairs
*
* encodeConsoleArgs :: String -> Array
*
*
* @param string $input
* @return array
* @example
*
*
* encodeConsoleArgs('--silent --name-separator="|" ls | composer.lock')
* // => array(4) {["silent"]=>bool(true),["name_separator"]=>string("|"),["max_processes"] ...}
* => array(4) {["silent"]=>bool(true),["name_separator"]=>string("|"),["max_processes"] ...}
*/
function encodeConsoleArgs(string $input): array
{
Expand Down Expand Up @@ -241,7 +235,7 @@ function encodeConsoleArgs(string $input): array
// "<proc a>, <proc b>" -> ['processes' => '<proc a>,<proc b>']
'_' => function () use ($directive, $acc) {
$trim = f\partialRight('ltrim', ' ');

return [
'processes' => f\concat(' ', $trim($acc['processes']), $trim($directive)),
];
Expand All @@ -257,15 +251,15 @@ function encodeConsoleArgs(string $input): array
/**
* executeProcesses
* executes processes concurrently
*
* executeProcesses :: Object -> [a] -> IO ()
*
* executeProcesses :: Object -> [a] -> IO ()
*
* @param LoopInterface $loop
* @param array $args
* @return IO
*
*
* executeProcesses($loop, DEFAULT_PROC_OPTS)
* // => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
* => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
*/
function executeProcesses(LoopInterface $loop, array $args = DEFAULT_PROC_OPTS): IO
{
Expand Down Expand Up @@ -294,7 +288,7 @@ function (array $args) use ($loop) {
);
},
// perform error checks
Either\Either::right($args)
Either::right($args)
// check if process list is an empty string
->filter(function ($args) {
return !empty($args['processes']);
Expand All @@ -319,13 +313,13 @@ function (array $args) use ($loop) {
* prints composite result of a TransientObservable
*
* printProcessResult :: TransientObservable a -> IO ()
*
*
* @param TransientObservable $transient
* @return IO
* @example
*
*
* printProcessResult(TransientObservable::fromPromise(resolve(2)))
* // => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
* => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
*/
function printProcessResult(
TransientObservable $transient,
Expand Down Expand Up @@ -370,21 +364,21 @@ function () use ($print) {
/**
* printSpinner
* prints Spinner artifact to console
*
* printSpinner :: Object -> Bool -> IO ()
*
* printSpinner :: Object -> Bool -> IO ()
*
* @param LoopInterface $loop
* @param bool $color
* @return IO
*
*
* printSpinner($loop, true)
* // => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
* => object(Chemem\Bingo\Functional\Functors\Monads\IO) {}
*/
function printSpinner(LoopInterface $loop, bool $color = true): IO
{
return IO\IO(function () use ($loop, $color) {
$spinner = new Spinner($color ? Color::COLOR_256 : Color::NO_COLOR);

return $loop->addPeriodicTimer(
$spinner->interval(),
function () use ($spinner) {
Expand Down
Loading

0 comments on commit b96b7d9

Please sign in to comment.