8000 [CI] Fix package-tests workflow checks for contracts by fancyweb · Pull Request #44511 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[CI] Fix package-tests workflow checks for contracts #44511

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 1 commit into from
Dec 9, 2021
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
30 changes: 27 additions & 3 deletions .github/get-modified-packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,33 @@
return strlen($b) <=> strlen($a) ?: $a <=> $b;
});

function isComponentBridge(string $packageDir): bool
function getPackageType(string $packageDir): string
{
return 0 < preg_match('@Symfony/Component/.*/Bridge/@', $packageDir);
if (preg_match('@Symfony/Bridge/@', $packageDir)) {
return 'bridge';
}

if (preg_match('@Symfony/Bundle/@', $packageDir)) {
return 'bundle';
}

if (preg_match('@Symfony/Component/[^/]+/Bridge/@', $packageDir)) {
return 'component_bridge';
}

if (preg_match('@Symfony/Component/@', $packageDir)) {
return 'component';
}

if (preg_match('@Symfony/Contracts/@', $packageDir)) {
return 'contract';
}

if (preg_match('@Symfony/Contracts$@', $packageDir)) {
return 'contracts';
}

throw new \LogicException();
}

$newPackage = [];
Expand All @@ -43,7 +67,7 @@ function isComponentBridge(string $packageDir): bool
$output = [];
foreach ($modifiedPackages as $directory => $bool) {
$name = json_decode(file_get_contents($directory.'/composer.json'), true)['name'] ?? 'unknown';
$output[] = ['name' => $name, 'directory' => $directory, 'new' => $newPackage[$directory] ?? false, 'component_bridge' => isComponentBridge($directory)];
$output[] = ['name' => $name, 'directory' => $directory, 'new' => $newPackage[$directory] ?? false, 'type' => getPackageType($directory)];
}

echo json_encode($output);
11 changes: 8 additions & 3 deletions .github/workflows/package-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,26 @@ jobs:
DIR=$(_jq '.directory')
NAME=$(_jq '.name')
echo "::group::$NAME"
TYPE=$(_jq '.type')
localExit=0

_file_exist $DIR/.gitattributes || localExit=1
if [ $TYPE != 'contract' ] && [ $TYPE != 'contracts' ]; then
_file_exist $DIR/.gitattributes || localExit=1
fi
_file_exist $DIR/.gitignore || localExit=1
_file_exist $DIR/CHANGELOG.md || localExit=1
_file_exist $DIR/LICENSE || localExit=1
_file_exist $DIR/phpunit.xml.dist || localExit=1
if [ $TYPE != 'contract' ]; then
_file_exist $DIR/phpunit.xml.dist || localExit=1
fi
_file_exist $DIR/README.md || localExit=1
_file_not_exist $DIR/phpunit.xml || localExit=1

if [ $(_jq '.new') == true ]; then
echo "Verifying new package"
_correct_license_file $DIR/LICENSE || localExit=1

if [ $(_jq '.component_bridge') == false ]; then
if [ $TYPE == 'component_bridge' ]; then
if [ ! $(cat composer.json | jq -e ".replace.\"$NAME\"|test(\"self.version\")") ]; then
echo "Composer.json's replace section needs to contain $NAME"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this done only for component bridges ? bundles, normal bridges (other than the phpunit one which is special) and components (other than runtime which is a composer plugin) should also be replaced.

And contract type should be replaced in src/Symfony/Contracts/composer.json file

localExit=1
Expand Down
0