Skip to content
Closed
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
31 changes: 31 additions & 0 deletions .github/get-ux-packages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

require __DIR__.'/../vendor/autoload.php';

use Symfony\Component\Finder\Finder;

$finder = (new Finder())
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/'])
->depth(0)
->name('composer.json')
;

// 1. Find all UX packages
$uxPackages = [];
foreach ($finder as $composerFile) {
$json = file_get_contents($composerFile->getPathname());
if (null === $packageData = json_decode($json, true)) {
passthru(sprintf('composer validate %s', $composerFile->getPathname()));
exit(1);
}

if (str_starts_with($composerFile->getPathname(), __DIR__ . '/../src/')) {
$packageName = $packageData['name'];

$uxPackages[] = [
'path' => realpath($composerFile->getPath()),
];
}
}

echo json_encode($uxPackages, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;
12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,15 @@ jobs:
source .github/workflows/.utils.sh

echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'"

normalize-package-php:
name: Normalize PHP Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- run: composer install --no-progress --no-interaction --ansi
- run: composer packages-normalize-check
44 changes: 44 additions & 0 deletions .github/workflows/validate-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Validate Packages

on:
push:
paths:
- 'src/**/composer.json'
pull_request:
paths:
- 'src/**/composer.json'
- 'src/**/package.json'

jobs:
validate-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Install PHP root dependencies
run: composer install

- run: npm i -g corepack && corepack enable

- uses: actions/setup-node@v4
with:
cache: 'yarn'

- name: Install Node.js root dependencies
run: yarn install --immutable

- name: Verify packages
run: |
php .github/get-ux-packages.php | jq -r '.[] | .path' | while read -r pkg_path; do
composer normalize "$pkg_path/composer.json" --no-check-lock --dry-run || echo "\033[41mFile $pkg_path is not normalized.\033[0m\033[41mPlease run "composer packages-normalize" in Symfony UX root repository.\033[0m" && exit 1;
node <<EOF
const normalizeData = require('normalize-package-data')
const packageData = require("$pkg_path/package.json")
normalizeData(packageData, true)
EOF
done
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"php": ">=8.1",
"symfony/filesystem": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"php-cs-fixer/shim": "^3.62"
"php-cs-fixer/shim": "^3.62",
"ergebnis/composer-normalize": "^2.47"
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
}
},
"scripts": {
"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"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@symfony/stimulus-testing": "^2.0.1",
"@vitest/browser": "^2.1.1",
"lightningcss": "^1.28.2",
"normalize-package-data": "^7.0.0",
"playwright": "^1.47.0",
"rollup": "^4.22.5",
"tslib": "^2.6.3",
Expand Down
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5775,6 +5775,15 @@ __metadata:
languageName: node
linkType: hard

"hosted-git-info@npm:^8.0.0":
version: 8.1.0
resolution: "hosted-git-info@npm:8.1.0"
dependencies:
lru-cache: "npm:^10.0.1"
checksum: 10c0/53cc838ecaa7d4aa69a81d9d8edc362c9d415f67b76ad38cdd781d2a2f5b45ad0aa9f9b013fb4ea54a9f64fd2365d0b6386b5a24bdf4cb90c80477cf3175aaa2
languageName: node
linkType: hard

"html-encoding-sniffer@npm:^2.0.1":
version: 2.0.1
resolution: "html-encoding-sniffer@npm:2.0.1"
Expand Down Expand Up @@ -7873,6 +7882,17 @@ __metadata:
languageName: node
linkType: hard

"normalize-package-data@npm:^7.0.0":
version: 7.0.0
resolution: "normalize-package-data@npm:7.0.0"
dependencies:
hosted-git-info: "npm:^8.0.0"
semver: "npm:^7.3.5"
validate-npm-package-license: "npm:^3.0.4"
checksum: 10c0/d492cbc4cdd92e99cba517b08cec6adf40ff37f2e97ecf4484ccb2da1ef5bd81c6dfbd8b434d3bdc749df639492ecdc71f4a61de1a8b99fe97fdf4faac13e7f1
languageName: node
linkType: hard

"normalize-path@npm:^2.1.1":
version: 2.1.1
resolution: "normalize-path@npm:2.1.1"
Expand Down Expand Up @@ -8804,6 +8824,7 @@ __metadata:
"@symfony/stimulus-testing": "npm:^2.0.1"
"@vitest/browser": "npm:^2.1.1"
lightningcss: "npm:^1.28.2"
normalize-package-data: "npm:^7.0.0"
playwright: "npm:^1.47.0"
rollup: "npm:^4.22.5"
tslib: "npm:^2.6.3"
Expand Down Expand Up @@ -9886,7 +9907,7 @@ __metadata:
languageName: node
linkType: hard

"validate-npm-package-license@npm:^3.0.1":
"validate-npm-package-license@npm:^3.0.1, validate-npm-package-license@npm:^3.0.4":
version: 3.0.4
resolution: "validate-npm-package-license@npm:3.0.4"
dependencies:
Expand Down
Loading