From 7fb08c7ce7941485e90e34ae4bc5e549a13006a8 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 7 Mar 2023 17:05:12 +0100 Subject: [PATCH 1/5] Added actions state management --- src/StateOutput/Action.php | 41 ++++++++++++++++++++++++++++++++++++ src/StateOutput/Workflow.php | 15 ++++++++----- 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/StateOutput/Action.php diff --git a/src/StateOutput/Action.php b/src/StateOutput/Action.php new file mode 100644 index 0000000..f00b28b --- /dev/null +++ b/src/StateOutput/Action.php @@ -0,0 +1,41 @@ + */ + private array $metrics = []; + private ConsoleSectionOutput $section; + + public function __construct( + private ConsoleOutput $output, + string $index, + string $label, + ) + { + $this->section = $this->output->section(); + $this->section->writeln(''); + $this->section->writeln(sprintf(' % 2s. %-50s', $index, $label)); + } + + public function addMetric(string $label, callable $callback): self + { + $this->metrics[$label] = $callback; + + return $this; + } + + public function update(): void + { + $this->section + ->writeln(' ' . implode(', ', array_map( + fn(string $label, callable $callback) => sprintf('%s %d', $label, ($callback)()), + array_keys($this->metrics), + array_values($this->metrics), + ))); + } +} diff --git a/src/StateOutput/Workflow.php b/src/StateOutput/Workflow.php index 13dcc72..ba7681e 100644 --- a/src/StateOutput/Workflow.php +++ b/src/StateOutput/Workflow.php @@ -8,8 +8,8 @@ final class Workflow { - /** @var list */ - private array $pipelines = []; + /** @var list */ + private array $jobs = []; private string $index = 'A'; public function __construct( @@ -19,13 +19,18 @@ public function __construct( public function withPipeline(string $label): Pipeline { - return $this->pipelines[] = new Pipeline($this->output, $this->index++, $label); + return $this->jobs[] = new Pipeline($this->output, $this->index++, $label); + } + + public function withAction(string $label): Action + { + return $this->jobs[] = new Action($this->output, $this->index++, $label); } public function update(): void { - foreach ($this->pipelines as $pipeline) { - $pipeline->update(); + foreach ($this->jobs as $job) { + $job->update(); } } } From f3f9e37280d3e6db67d2b10e27fa5fad340524ac Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 14 Apr 2023 12:13:15 +0000 Subject: [PATCH 2/5] [rector] Rector fixes --- src/StateOutput/Action.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StateOutput/Action.php b/src/StateOutput/Action.php index f00b28b..5d98bca 100644 --- a/src/StateOutput/Action.php +++ b/src/StateOutput/Action.php @@ -9,10 +9,10 @@ final class Action { /** @var array */ private array $metrics = []; - private ConsoleSectionOutput $section; + private readonly ConsoleSectionOutput $section; public function __construct( - private ConsoleOutput $output, + private readonly ConsoleOutput $output, string $index, string $label, ) From 5fba5a9df17ee24b5a8aa0ca16a42d98cb5353fc Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 18 Apr 2023 17:10:52 +0200 Subject: [PATCH 3/5] Updated dependencies --- composer.lock | 140 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 98 insertions(+), 42 deletions(-) diff --git a/composer.lock b/composer.lock index 687af51..4d4d136 100644 --- a/composer.lock +++ b/composer.lock @@ -62,21 +62,22 @@ }, { "name": "php-etl/pipeline-contracts", - "version": "v0.4.0", + "version": "v0.4.1", "source": { "type": "git", "url": "https://github.com/php-etl/pipeline-contracts.git", - "reference": "47e1e32aedb425c4624c1f6d9acf5ae839287fdf" + "reference": "b5c45090ed92f93530f3f69782bb016b52627b1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-etl/pipeline-contracts/zipball/47e1e32aedb425c4624c1f6d9acf5ae839287fdf", - "reference": "47e1e32aedb425c4624c1f6d9acf5ae839287fdf", + "url": "https://api.github.com/repos/php-etl/pipeline-contracts/zipball/b5c45090ed92f93530f3f69782bb016b52627b1a", + "reference": "b5c45090ed92f93530f3f69782bb016b52627b1a", "shasum": "" }, "require": { "php": "^8.2", - "php-etl/bucket-contracts": "0.2.0" + "php-etl/bucket-contracts": "0.2.*", + "php-etl/satellite-contracts": "0.1.*" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.0", @@ -111,9 +112,61 @@ "description": "This library describes contracts for the Extract-Transform-Load pattern.", "support": { "issues": "https://github.com/php-etl/pipeline-contracts/issues", - "source": "https://github.com/php-etl/pipeline-contracts/tree/v0.4.0" + "source": "https://github.com/php-etl/pipeline-contracts/tree/v0.4.1" }, - "time": "2023-04-06T10:08:37+00:00" + "time": "2023-04-18T14:32:57+00:00" + }, + { + "name": "php-etl/satellite-contracts", + "version": "v0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-etl/satellite-contracts.git", + "reference": "1d2bc6822bfdb3efc6a1f490e706db995c99ef41" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-etl/satellite-contracts/zipball/1d2bc6822bfdb3efc6a1f490e706db995c99ef41", + "reference": "1d2bc6822bfdb3efc6a1f490e706db995c99ef41", + "shasum": "" + }, + "require": { + "php": "^8.2" + }, + "require-dev": { + "rector/rector": "^0.15.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Kiboko\\Contract\\Satellite\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kiboko SAS", + "homepage": "http://kiboko.fr" + }, + { + "name": "Grégory Planchat", + "email": "gregory@kiboko.fr" + } + ], + "description": "This library describes contracts for defining satellite formats", + "support": { + "issues": "https://github.com/php-etl/satellite-contracts/issues", + "source": "https://github.com/php-etl/satellite-contracts/tree/v0.1.0" + }, + "time": "2023-04-18T13:53:22+00:00" }, { "name": "psr/container", @@ -1632,16 +1685,16 @@ }, { "name": "infection/infection", - "version": "0.26.19", + "version": "0.26.20", "source": { "type": "git", "url": "https://github.com/infection/infection.git", - "reference": "bd7351c88f3a797ea8977e68fe6a3f4d4c5f457f" + "reference": "37dd2f590bec3d0058e11dbeefc8f93fc9132c62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infection/infection/zipball/bd7351c88f3a797ea8977e68fe6a3f4d4c5f457f", - "reference": "bd7351c88f3a797ea8977e68fe6a3f4d4c5f457f", + "url": "https://api.github.com/repos/infection/infection/zipball/37dd2f590bec3d0058e11dbeefc8f93fc9132c62", + "reference": "37dd2f590bec3d0058e11dbeefc8f93fc9132c62", "shasum": "" }, "require": { @@ -1659,7 +1712,7 @@ "justinrainbow/json-schema": "^5.2.10", "nikic/php-parser": "^4.15.1", "ondram/ci-detector": "^4.1.0", - "php": "^8.0", + "php": "^8.1", "sanmai/later": "^0.1.1", "sanmai/pipeline": "^5.1 || ^6", "sebastian/diff": "^3.0.2 || ^4.0 || ^5.0", @@ -1671,6 +1724,7 @@ "webmozart/assert": "^1.11" }, "conflict": { + "antecedent/patchwork": "<2.1.25", "dg/bypass-finals": "<1.4.1", "phpunit/php-code-coverage": ">9,<9.1.4 || >9.2.17,<9.2.21" }, @@ -1679,6 +1733,7 @@ "ext-simplexml": "*", "fidry/makefile": "^0.2.0", "helmich/phpunit-json-assert": "^3.0", + "phpspec/prophecy": "^1.15", "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.1.0", "phpstan/phpstan": "^1.3.0", @@ -1744,7 +1799,7 @@ ], "support": { "issues": "https://github.com/infection/infection/issues", - "source": "https://github.com/infection/infection/tree/0.26.19" + "source": "https://github.com/infection/infection/tree/0.26.20" }, "funding": [ { @@ -1756,7 +1811,7 @@ "type": "open_collective" } ], - "time": "2023-02-05T21:47:26+00:00" + "time": "2023-04-14T21:39:46+00:00" }, { "name": "justinrainbow/json-schema", @@ -2134,16 +2189,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.12", + "version": "1.10.13", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "7b2aaf999e522e2b10011a594cf06dc37de7fbd8" + "reference": "f07bf8c6980b81bf9e49d44bd0caf2e737614a70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7b2aaf999e522e2b10011a594cf06dc37de7fbd8", - "reference": "7b2aaf999e522e2b10011a594cf06dc37de7fbd8", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f07bf8c6980b81bf9e49d44bd0caf2e737614a70", + "reference": "f07bf8c6980b81bf9e49d44bd0caf2e737614a70", "shasum": "" }, "require": { @@ -2192,20 +2247,20 @@ "type": "tidelift" } ], - "time": "2023-04-12T10:33:29+00:00" + "time": "2023-04-12T19:29:52+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.0.2", + "version": "10.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4" + "reference": "884a0da7f9f46f28b2cb69134217fd810b793974" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/20800e84296ea4732f9a125e08ce86b4004ae3e4", - "reference": "20800e84296ea4732f9a125e08ce86b4004ae3e4", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/884a0da7f9f46f28b2cb69134217fd810b793974", + "reference": "884a0da7f9f46f28b2cb69134217fd810b793974", "shasum": "" }, "require": { @@ -2224,7 +2279,7 @@ "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^10.1" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -2233,7 +2288,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.0-dev" + "dev-main": "10.1-dev" } }, "autoload": { @@ -2261,7 +2316,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.0.2" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.1" }, "funding": [ { @@ -2269,7 +2325,7 @@ "type": "github" } ], - "time": "2023-03-06T13:00:19+00:00" + "time": "2023-04-17T12:15:40+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2514,16 +2570,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.0.19", + "version": "10.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "20c23e85c86e5c06d63538ba464e8054f4744e62" + "reference": "0d9401b7e8245d71079e249e3cb868e9d2337887" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/20c23e85c86e5c06d63538ba464e8054f4744e62", - "reference": "20c23e85c86e5c06d63538ba464e8054f4744e62", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d9401b7e8245d71079e249e3cb868e9d2337887", + "reference": "0d9401b7e8245d71079e249e3cb868e9d2337887", "shasum": "" }, "require": { @@ -2537,7 +2593,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=8.1", - "phpunit/php-code-coverage": "^10.0", + "phpunit/php-code-coverage": "^10.1.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-invoker": "^4.0", "phpunit/php-text-template": "^3.0", @@ -2563,7 +2619,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.0-dev" + "dev-main": "10.1-dev" } }, "autoload": { @@ -2595,7 +2651,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.0.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.1" }, "funding": [ { @@ -2611,7 +2667,7 @@ "type": "tidelift" } ], - "time": "2023-03-27T11:46:33+00:00" + "time": "2023-04-17T12:17:05+00:00" }, { "name": "psr/cache", @@ -2883,20 +2939,20 @@ }, { "name": "sanmai/pipeline", - "version": "v6.4", + "version": "v6.5", "source": { "type": "git", "url": "https://github.com/sanmai/pipeline.git", - "reference": "9260c4d05da37d67a69075858f41a6e7fff43743" + "reference": "dd7c3c890b6d2d40a2ea1cf0d49281c17832de2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sanmai/pipeline/zipball/9260c4d05da37d67a69075858f41a6e7fff43743", - "reference": "9260c4d05da37d67a69075858f41a6e7fff43743", + "url": "https://api.github.com/repos/sanmai/pipeline/zipball/dd7c3c890b6d2d40a2ea1cf0d49281c17832de2d", + "reference": "dd7c3c890b6d2d40a2ea1cf0d49281c17832de2d", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.8", @@ -2936,7 +2992,7 @@ "description": "General-purpose collections pipeline", "support": { "issues": "https://github.com/sanmai/pipeline/issues", - "source": "https://github.com/sanmai/pipeline/tree/v6.4" + "source": "https://github.com/sanmai/pipeline/tree/v6.5" }, "funding": [ { @@ -2944,7 +3000,7 @@ "type": "github" } ], - "time": "2023-04-12T06:45:27+00:00" + "time": "2023-04-15T00:28:41+00:00" }, { "name": "sebastian/cli-parser", From 4da2b0c947730f4990216f2ddce253ce7419cb26 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 18 Apr 2023 17:18:26 +0200 Subject: [PATCH 4/5] Ran php-cs-fixer --- src/StateOutput/Action.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/StateOutput/Action.php b/src/StateOutput/Action.php index 5d98bca..68e629a 100644 --- a/src/StateOutput/Action.php +++ b/src/StateOutput/Action.php @@ -1,4 +1,6 @@ -section = $this->output->section(); $this->section->writeln(''); $this->section->writeln(sprintf(' % 2s. %-50s', $index, $label)); @@ -32,10 +33,11 @@ public function addMetric(string $label, callable $callback): self public function update(): void { $this->section - ->writeln(' ' . implode(', ', array_map( - fn(string $label, callable $callback) => sprintf('%s %d', $label, ($callback)()), + ->writeln(' '.implode(', ', array_map( + fn (string $label, callable $callback) => sprintf('%s %d', $label, ($callback)()), array_keys($this->metrics), array_values($this->metrics), - ))); + ))) + ; } } From 79354df41029b5dc429db738db1800fc8380b469 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 18 Apr 2023 17:23:09 +0200 Subject: [PATCH 5/5] Renamed action --- .github/workflows/phpstan-5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-5.yaml index 825fe4b..906b4c9 100644 --- a/.github/workflows/phpstan-5.yaml +++ b/.github/workflows/phpstan-5.yaml @@ -1,4 +1,4 @@ -name: PHPStan level 6 +name: PHPStan level 5 on: push jobs: phpstan: