Skip to content

[CI] Test ux.symfony.com with local UX packages #2063

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
Aug 14, 2024
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
57 changes: 28 additions & 29 deletions .github/build-packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,50 @@
use Symfony\Component\Finder\Finder;

$finder = (new Finder())
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/'])
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/', __DIR__.'/../ux.symfony.com/'])
->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);
}

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

if (isset($packageData['require']['symfony/ux-twig-component'])
|| isset($packageData['require-dev']['symfony/ux-twig-component'])
) {
$repositories[] = [
'type' => 'path',
'url' => '../TwigComponent',
$uxPackages[$packageName] = [
'path' => realpath($composerFile->getPath()),
];
$key = isset($packageData['require']['symfony/ux-twig-component']) ? 'require' : 'require-dev';
$packageData[$key]['symfony/ux-twig-component'] = '@dev';
}
}

if (isset($packageData['require']['symfony/stimulus-bundle'])
|| isset($packageData['require-dev']['symfony/stimulus-bundle'])
) {
$repositories[] = [
'type' => 'path',
'url' => '../StimulusBundle',
];
$key = isset($packageData['require']['symfony/stimulus-bundle']) ? 'require' : 'require-dev';
$packageData[$key]['symfony/stimulus-bundle'] = '@dev';
// 2. Update all composer.json files from the repository, to use the local version of the UX packages
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 (isset($packageData['require']['symfony/ux-map'])
|| isset($packageData['require-dev']['symfony/ux-map'])
) {
$repositories[] = [
'type' => 'path',
'url' => '../../../',
];
$key = isset($packageData['require']['symfony/ux-map']) ? 'require' : 'require-dev';
$packageData[$key]['symfony/ux-map'] = '@dev';

$repositories = $packageData['repositories'] ?? [];

foreach ($uxPackages as $packageName => $packageInfo) {
if (isset($packageData['require'][$packageName])
|| isset($packageData['require-dev'][$packageName])
) {
$repositories[] = [
'type' => 'path',
'url' => $packageInfo['path'],
];
$key = isset($packageData['require'][$packageName]) ? 'require' : 'require-dev';
$packageData[$key][$packageName] = '@dev';
}
}

if ($repositories) {
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ux.symfony.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ on:
push:
paths:
- 'ux.symfony.com/**'
- 'src/*/**'
- '!src/*/doc/**'
- '.github/**'
pull_request:
paths:
- 'ux.symfony.com/**'
- 'src/*/**'
- '!src/*/doc/**'
- '.github/**'

jobs:

Expand Down Expand Up @@ -58,10 +64,18 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Install root dependencies
uses: ramsey/composer-install@v3
with:
working-directory: ${{ github.workspace }}
- name: Build root packages
run: php .github/build-packages.php
working-directory: ${{ github.workspace }}
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
working-directory: ux.symfony.com
dependency-versions: 'highest'
- name: Importmap dependencies
run: php bin/console importmap:install
- name: Build Sass assets
Expand Down
Loading