From 4cff454f3caec1436abab939fe2ab2a5244e0495 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 17 Mar 2025 14:01:55 +0100 Subject: [PATCH 1/3] Made the step code mandatory to avoid problems and corrected the configuration sent using the cloud command --- src/Cloud/Workflow.php | 24 +++++++++++++----------- src/Runtime/Pipeline/Configuration.php | 1 + src/Service.php | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Cloud/Workflow.php b/src/Cloud/Workflow.php index fec07ff9..1121e13c 100644 --- a/src/Cloud/Workflow.php +++ b/src/Cloud/Workflow.php @@ -34,10 +34,9 @@ public static function fromLegacyConfiguration(array $configuration): DTO\Workfl $configuration['code'] ?? sprintf('workflow%s', $random), new DTO\JobList( ...array_map( - function (array $config, int $order) { + function (string $code, array $config, int $order) { if (\array_key_exists('pipeline', $config)) { $name = $config['pipeline']['name'] ?? sprintf('pipeline%d', $order); - $code = $config['pipeline']['code'] ?? sprintf('pipeline%d', $order); unset($config['pipeline']['name'], $config['pipeline']['code']); array_walk_recursive($config, function (&$value): void { @@ -50,13 +49,16 @@ function (array $config, int $order) { $name, new JobCode($code), new StepList( - ...array_map(fn (array $step, int $order) => new Step( - $step['name'] ?? sprintf('step%d', $order), - new StepCode($step['code'] ?? sprintf('step%d', $order)), - $step, - new ProbeList(), - $order - ), + ...array_map(function (string $code, array $step, int $order) { + return new Step( + $step['name'] ?? sprintf('step%d', $order), + new StepCode($code ?? sprintf('step%d', $order)), + $step, + new ProbeList(), + $order + ); + }, + array_keys($config['pipeline']['steps']), $config['pipeline']['steps'], range(0, (is_countable($config['pipeline']['steps']) ? \count($config['pipeline']['steps']) : 0) - 1) ), @@ -67,7 +69,6 @@ function (array $config, int $order) { if (\array_key_exists('action', $config)) { $name = $config['action']['name'] ?? sprintf('action%d', $order); - $code = $config['action']['code'] ?? sprintf('action%d', $order); unset($config['action']['name'], $config['action']['code']); array_walk_recursive($config, function (&$value): void { @@ -90,8 +91,9 @@ function (array $config, int $order) { throw new \RuntimeException('This type is currently not supported.'); }, + array_keys($configuration['workflow']['jobs']), $configuration['workflow']['jobs'], - range(0, (is_countable($configuration['workflow']['jobs']) ? \count($configuration['workflow']['jobs']) : 0) - 1) + range(0, (is_countable($configuration['workflow']['jobs']) ? \count($configuration['workflow']['jobs']) : 0) - 1), ) ), new Composer( diff --git a/src/Runtime/Pipeline/Configuration.php b/src/Runtime/Pipeline/Configuration.php index a3086eeb..e73d9103 100644 --- a/src/Runtime/Pipeline/Configuration.php +++ b/src/Runtime/Pipeline/Configuration.php @@ -44,6 +44,7 @@ public function getStepsTreeBuilder(): TreeBuilder /* @phpstan-ignore-next-line */ $builder->getRootNode() + ->useAttributeAsKey('code') ->requiresAtLeastOneElement() ->cannotBeEmpty() ->isRequired() diff --git a/src/Service.php b/src/Service.php index e73fe8b2..7534b3c1 100644 --- a/src/Service.php +++ b/src/Service.php @@ -350,7 +350,9 @@ private function compilePipelineJob(array $config): Satellite\Builder\Repository } } - foreach ($config['pipeline']['steps'] as $step) { + foreach ($config['pipeline']['steps'] as $code => $step) { + $step['code'] = $code; + $plugins = array_intersect_key($this->plugins, $step); foreach ($plugins as $plugin) { $plugin->appendTo($step, $repository); From 41e7419a46b7179561776ff8f63da559a815ae6a Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 17 Mar 2025 13:08:44 +0000 Subject: [PATCH 2/3] [rector] Rector fixes --- src/Cloud/Workflow.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Cloud/Workflow.php b/src/Cloud/Workflow.php index 1121e13c..128cbf6f 100644 --- a/src/Cloud/Workflow.php +++ b/src/Cloud/Workflow.php @@ -49,15 +49,13 @@ function (string $code, array $config, int $order) { $name, new JobCode($code), new StepList( - ...array_map(function (string $code, array $step, int $order) { - return new Step( - $step['name'] ?? sprintf('step%d', $order), - new StepCode($code ?? sprintf('step%d', $order)), - $step, - new ProbeList(), - $order - ); - }, + ...array_map(fn(string $code, array $step, int $order) => new Step( + $step['name'] ?? sprintf('step%d', $order), + new StepCode($code ?? sprintf('step%d', $order)), + $step, + new ProbeList(), + $order + ), array_keys($config['pipeline']['steps']), $config['pipeline']['steps'], range(0, (is_countable($config['pipeline']['steps']) ? \count($config['pipeline']['steps']) : 0) - 1) From cecef7f8274ef9410ff50dfc43da11167f943817 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 17 Mar 2025 14:37:25 +0100 Subject: [PATCH 3/3] Updated github actions --- .github/workflows/infection.yaml | 2 +- .github/workflows/phpstan-5.yaml | 4 ++-- .github/workflows/phpstan-6.yaml | 4 ++-- .github/workflows/phpstan-7.yaml | 4 ++-- .github/workflows/phpstan-8.yaml | 4 ++-- .github/workflows/phpunit.yaml | 2 +- .github/workflows/quality.yaml | 6 +++--- .github/workflows/rector.yaml | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/infection.yaml b/.github/workflows/infection.yaml index c5adb1e1..53d8c96a 100644 --- a/.github/workflows/infection.yaml +++ b/.github/workflows/infection.yaml @@ -4,7 +4,7 @@ jobs: infection: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: '8.2' diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-5.yaml index df9cb01b..0bb9a9bd 100644 --- a/.github/workflows/phpstan-5.yaml +++ b/.github/workflows/phpstan-5.yaml @@ -4,8 +4,8 @@ jobs: phpstan5: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: '**/vendor' key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/phpstan-6.yaml b/.github/workflows/phpstan-6.yaml index 1dd1abfa..5e7a696a 100644 --- a/.github/workflows/phpstan-6.yaml +++ b/.github/workflows/phpstan-6.yaml @@ -4,8 +4,8 @@ jobs: phpstan6: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: '**/vendor' key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/phpstan-7.yaml b/.github/workflows/phpstan-7.yaml index a2f393ca..4aef471d 100644 --- a/.github/workflows/phpstan-7.yaml +++ b/.github/workflows/phpstan-7.yaml @@ -4,8 +4,8 @@ jobs: phpstan7: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: '**/vendor' key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/phpstan-8.yaml b/.github/workflows/phpstan-8.yaml index addb6be2..852ec308 100644 --- a/.github/workflows/phpstan-8.yaml +++ b/.github/workflows/phpstan-8.yaml @@ -4,8 +4,8 @@ jobs: phpstan8: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: '**/vendor' key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/phpunit.yaml b/.github/workflows/phpunit.yaml index cc4fc195..8c1744cc 100644 --- a/.github/workflows/phpunit.yaml +++ b/.github/workflows/phpunit.yaml @@ -4,7 +4,7 @@ jobs: phpunit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: '8.2' diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index 75470482..ffae34e1 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -4,7 +4,7 @@ jobs: cs-fixer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: '8.2' @@ -19,8 +19,8 @@ jobs: phpstan: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: '**/vendor' key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml index 3dc0f50a..67109a7a 100644 --- a/.github/workflows/rector.yaml +++ b/.github/workflows/rector.yaml @@ -11,7 +11,7 @@ jobs: steps: - if: github.event.pull_request.head.repo.full_name == github.repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2