Skip to content

Commit 1386749

Browse files
Kocalkbond
authored andcommitted
[CI] Test ux.symfony.com with local UX packages
1 parent 92ad2de commit 1386749

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

.github/build-packages.php

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,50 @@
99
use Symfony\Component\Finder\Finder;
1010

1111
$finder = (new Finder())
12-
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/'])
12+
->in([__DIR__.'/../src/*/', __DIR__.'/../src/*/src/Bridge/*/', __DIR__.'/../ux.symfony.com/'])
1313
->depth(0)
1414
->name('composer.json')
1515
;
1616

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

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

26-
if (isset($packageData['require']['symfony/ux-twig-component'])
27-
|| isset($packageData['require-dev']['symfony/ux-twig-component'])
28-
) {
29-
$repositories[] = [
30-
'type' => 'path',
31-
'url' => '../TwigComponent',
29+
$uxPackages[$packageName] = [
30+
'path' => realpath($composerFile->getPath()),
3231
];
33-
$key = isset($packageData['require']['symfony/ux-twig-component']) ? 'require' : 'require-dev';
34-
$packageData[$key]['symfony/ux-twig-component'] = '@dev';
3532
}
33+
}
3634

37-
if (isset($packageData['require']['symfony/stimulus-bundle'])
38-
|| isset($packageData['require-dev']['symfony/stimulus-bundle'])
39-
) {
40-
$repositories[] = [
41-
'type' => 'path',
42-
'url' => '../StimulusBundle',
43-
];
44-
$key = isset($packageData['require']['symfony/stimulus-bundle']) ? 'require' : 'require-dev';
45-
$packageData[$key]['symfony/stimulus-bundle'] = '@dev';
35+
// 2. Update all composer.json files from the repository, to use the local version of the UX packages
36+
foreach ($finder as $composerFile) {
37+
$json = file_get_contents($composerFile->getPathname());
38+
if (null === $packageData = json_decode($json, true)) {
39+
passthru(sprintf('composer validate %s', $composerFile->getPathname()));
40+
exit(1);
4641
}
47-
48-
if (isset($packageData['require']['symfony/ux-map'])
49-
|| isset($packageData['require-dev']['symfony/ux-map'])
50-
) {
51-
$repositories[] = [
52-
'type' => 'path',
53-
'url' => '../../../',
54-
];
55-
$key = isset($packageData['require']['symfony/ux-map']) ? 'require' : 'require-dev';
56-
$packageData[$key]['symfony/ux-map'] = '@dev';
42+
43+
$repositories = $packageData['repositories'] ?? [];
44+
45+
foreach ($uxPackages as $packageName => $packageInfo) {
46+
if (isset($packageData['require'][$packageName])
47+
|| isset($packageData['require-dev'][$packageName])
48+
) {
49+
$repositories[] = [
50+
'type' => 'path',
51+
'url' => $packageInfo['path'],
52+
];
53+
$key = isset($packageData['require'][$packageName]) ? 'require' : 'require-dev';
54+
$packageData[$key][$packageName] = '@dev';
55+
}
5756
}
5857

5958
if ($repositories) {

.github/workflows/ux.symfony.com.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ on:
44
push:
55
paths:
66
- 'ux.symfony.com/**'
7+
- 'src/*/**'
8+
- '!src/*/doc/**'
9+
- '.github/**'
710
pull_request:
811
paths:
912
- 'ux.symfony.com/**'
13+
- 'src/*/**'
14+
- '!src/*/doc/**'
15+
- '.github/**'
1016

1117
jobs:
1218

@@ -58,10 +64,18 @@ jobs:
5864
- uses: shivammathur/setup-php@v2
5965
with:
6066
php-version: '8.3'
67+
- name: Install root dependencies
68+
uses: ramsey/composer-install@v3
69+
with:
70+
working-directory: ${{ github.workspace }}
71+
- name: Build root packages
72+
run: php .github/build-packages.php
73+
working-directory: ${{ github.workspace }}
6174
- name: Install dependencies
6275
uses: ramsey/composer-install@v3
6376
with:
6477
working-directory: ux.symfony.com
78+
dependency-versions: 'highest'
6579
- name: Importmap dependencies
6680
run: php bin/console importmap:install
6781
- name: Build Sass assets

0 commit comments

Comments
 (0)