Skip to content

Commit

Permalink
Add CI run for test lowest installed deps
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jul 5, 2024
1 parent 0c34feb commit c938bc8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ jobs:
composer self-update
composer update --prefer-dist --optimize-autoloader --no-interaction --no-suggest ${{ matrix.composer-flags }}
- name: Check lowest dependencies
run: php tests/lowest-dependencies.php
if: ${{ matrix.composer-flags == '--prefer-lowest' }}

- name: Run setup tests
run: vendor/bin/phpunit --configuration tests/config/${{ matrix.db }}.phpunit.xml tests/Oro/Tests/Connection/SetupTest.php

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ phpunit.xml
vendor/
composer.lock
.idea/
.phpunit.cache/
41 changes: 41 additions & 0 deletions tests/lowest-dependencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

$content = file_get_contents(dirname(__DIR__) . '/composer.lock');

$dependencies = json_decode($content, true, \JSON_THROW_ON_ERROR);

$expectedDependencies = [
'doctrine/annotations' => '1.14.0',
'doctrine/lexer' => '2.0.0',
'doctrine/dbal' => '3.3.6',
'doctrine/orm' => '2.19.0',
];

foreach ($expectedDependencies as $expectedDependency => $expectedVersion) {
$dependency = null;
foreach ([...$dependencies['packages'], ...$dependencies['packages-dev']] as $package) {
if ($package['name'] === $expectedDependency) {
$dependency = $package;
break;
}
}

if (null === $dependency) {
throw new RuntimeException('Missing dependency: ' . $expectedDependency);
}

$dependencyVersion = $dependency['version'];

if ($dependencyVersion !== $expectedVersion) {
throw new RuntimeException(
sprintf(
"Invalid version for %s. Expected: %s. Found: %s",
$expectedDependency,
$expectedVersion,
$dependencyVersion
)
);
}
}

echo 'All dependencies are correct.' . \PHP_EOL;

0 comments on commit c938bc8

Please sign in to comment.