8000 minor #44511 [CI] Fix package-tests workflow checks for contracts (fa… · symfony/symfony@6ff1b63 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 6ff1b63

Browse files
committed
minor #44511 [CI] Fix package-tests workflow checks for contracts (fancyweb)
This PR was merged into the 5.3 branch. Discussion ---------- [CI] Fix package-tests workflow checks for contracts | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | #44506 (comment) | License | MIT | Doc PR | - Our expectations are different for contracts. Commits ------- fb3f4e4 [CI] Fix package-tests workflow checks for contracts
2 parents 81c2bfd + fb3f4e4 commit 6ff1b63

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.github/get-modified-packages.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,33 @@
1717
return strlen($b) <=> strlen($a) ?: $a <=> $b;
1818
});
1919

20-
function isComponentBridge(string $packageDir): bool
20+
function getPackageType(string $packageDir): string
2121
{
22-
return 0 < preg_match('@Symfony/Component/.*/Bridge/@', $packageDir);
22+
if (preg_match('@Symfony/Bridge/@', $packageDir)) {
23+
return 'bridge';
24+
}
25+
26+
if (preg_match('@Symfony/Bundle/@', $packageDir)) {
27+
return 'bundle';
28+
}
29+
30+
if (preg_match('@Symfony/Component/[^/]+/Bridge/@', $packageDir)) {
31+
return 'component_bridge';
32+
}
33+
34+
if (preg_match('@Symfony/Component/@', $packageDir)) {
35+
return 'component';
36+
}
37+
38+
if (preg_match('@Symfony/Contracts/@', $packageDir)) {
39+
return 'contract';
40+
}
41+
42+
if (preg_match('@Symfony/Contracts$@', $packageDir)) {
43+
return 'contracts';
44+
}
45+
46+
throw new \LogicException();
2347
}
2448

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

4973
echo json_encode($output);

.github/workflows/package-tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,26 @@ jobs:
6363
DIR=$(_jq '.directory')
6464
NAME=$(_jq '.name')
6565
echo "::group::$NAME"
66+
TYPE=$(_jq '.type')
6667
localExit=0
6768
68-
_file_exist $DIR/.gitattributes || localExit=1
69+
if [ $TYPE != 'contract' ] && [ $TYPE != 'contracts' ]; then
70+
_file_exist $DIR/.gitattributes || localExit=1
71+
fi
6972
_file_exist $DIR/.gitignore || localExit=1
7073
_file_exist $DIR/CHANGELOG.md || localExit=1
7174
_file_exist $DIR/LICENSE || localExit=1
72-
_file_exist $DIR/phpunit.xml.dist || localExit=1
75+
if [ $TYPE != 'contract' ]; then
76+
_file_exist $DIR/phpunit.xml.dist || localExit=1
77+
fi
7378
_file_exist $DIR/README.md || localExit=1
7479
_file_not_exist $DIR/phpunit.xml || localExit=1
7580
7681
if [ $(_jq '.new') == true ]; then
7782
echo "Verifying new package"
7883
_correct_license_file $DIR/LICENSE || localExit=1
7984
80-
if [ $(_jq '.component_bridge') == false ]; then
85+
if [ $TYPE == 'component_bridge' ]; then
8186
if [ ! $(cat composer.json | jq -e ".replace.\"$NAME\"|test(\"self.version\")") ]; then
8287
echo "Composer.json's replace section needs to contain $NAME"
8388
localExit=1

0 commit comments

Comments
 (0)
0