Skip to content

Made the step code mandatory to avoid problems #168

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

Merged
merged 4 commits into from
Mar 17, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/infection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -29,6 +29,6 @@ jobs:
./infection.phar

- name: Store infection log
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: infection.log
4 changes: 2 additions & 2 deletions .github/workflows/phpstan-5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan-6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -25,6 +25,6 @@ jobs:
run: bin/phpunit --coverage-html var/coverage

- name: Store coverage files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: var/coverage
6 changes: 3 additions & 3 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/Cloud/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -50,13 +49,14 @@ function (array $config, int $order) {
$name,
new JobCode($code),
new StepList(
...array_map(fn (array $step, int $order) => new Step(
...array_map(fn(string $code, array $step, int $order) => new Step(
$step['name'] ?? sprintf('step%d', $order),
new StepCode($step['code'] ?? 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)
),
Expand All @@ -67,7 +67,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 {
Expand All @@ -90,8 +89,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(
Expand Down
1 change: 1 addition & 0 deletions src/Runtime/Pipeline/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function getStepsTreeBuilder(): TreeBuilder

/* @phpstan-ignore-next-line */
$builder->getRootNode()
->useAttributeAsKey('code')
->requiresAtLeastOneElement()
->cannotBeEmpty()
->isRequired()
Expand Down
4 changes: 3 additions & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading