Skip to content

Commit 1af8fd1

Browse files
committed
[CI] Add packages normalizer
1 parent 59e840d commit 1af8fd1

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.github/get-ux-packages.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
require __DIR__.'/../vendor/autoload.php';
4+
5+
use Symfony\Component\Finder\Finder;
6+
7+
$finder = (new Finder())
8+
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/'])
9+
->depth(0)
10+
->name('composer.json')
11+
;
12+
13+
// 1. Find all UX packages
14+
$uxPackages = [];
15+
foreach ($finder as $composerFile) {
16+
$json = file_get_contents($composerFile->getPathname());
17+
if (null === $packageData = json_decode($json, true)) {
18+
passthru(sprintf('composer validate %s', $composerFile->getPathname()));
19+
exit(1);
20+
}
21+
22+
if (str_starts_with($composerFile->getPathname(), __DIR__ . '/../src/')) {
23+
$packageName = $packageData['name'];
24+
25+
$uxPackages[] = [
26+
'path' => realpath($composerFile->getPath()),
27+
];
28+
}
29+
}
30+
31+
echo json_encode($uxPackages, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;

.github/workflows/code-quality.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,15 @@ jobs:
8181
source .github/workflows/.utils.sh
8282
8383
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'"
84+
85+
normalize-package-php:
86+
name: Normalize PHP Packages
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v4
90+
- name: Setup PHP
91+
uses: shivammathur/setup-php@v2
92+
with:
93+
php-version: '8.1'
94+
- run: composer install --no-progress --no-interaction --ansi
95+
- run: composer packages-normalize-check

composer.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
"php": ">=8.1",
99
"symfony/filesystem": "^6.4|^7.0",
1010
"symfony/finder": "^6.4|^7.0",
11-
"php-cs-fixer/shim": "^3.62"
11+
"php-cs-fixer/shim": "^3.62",
12+
"ergebnis/composer-normalize": "^2.47"
13+
},
14+
"config": {
15+
"allow-plugins": {
16+
"ergebnis/composer-normalize": true
17+
}
18+
},
19+
"scripts": {
20+
"packages-normalize": "php .github/get-ux-packages.php | jq -r '.[] | .path' | while read -r path; do composer normalize \"$path/composer.json\" --no-check-lock; done",
21+
"packages-normalize-check": "php .github/get-ux-packages.php | jq -r '.[] | .path' | while read -r path; do composer normalize \"$path/composer.json\" --no-check-lock --dry-run || echo \"\\033[41mFile $path is not normalized.\\033[0m\n\\033[41mPlease run \"composer packages-normalize\" in Symfony UX root repository.\\033[0m\n\"; done"
1222
}
1323
}

0 commit comments

Comments
 (0)