[CI] Fix package-tests workflow checks for contracts
This commit is contained in:
parent
81c2bfdc1b
commit
fb3f4e403c
|
@ -17,9 +17,33 @@ usort($allPackages, function($a, $b) {
|
|||
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 = [];
|
||||
|
@ -43,7 +67,7 @@ foreach ($modifiedFiles as $file) {
|
|||
$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);
|
||||
|
|
|
@ -63,13 +63,18 @@ 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
|
||||
|
||||
|
@ -77,7 +82,7 @@ jobs:
|
|||
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"
|
||||
localExit=1
|
||||
|
|
Reference in New Issue