Skip to content

Commit ca50e8a

Browse files
committed
ci: update package build script
1 parent 3c0d1f3 commit ca50e8a

File tree

3 files changed

+63
-57
lines changed

3 files changed

+63
-57
lines changed

.github/workflows/isolated-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
7676
- name: Install dependencies
7777
run: |
78-
./bin/build-changed-packages
78+
./bin/build-packages
7979
cd "packages/${{ matrix.package.basename }}"
8080
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --ignore-platform-reqs
8181

bin/build-changed-packages

Lines changed: 0 additions & 56 deletions
This file was deleted.

bin/build-packages

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/**
5+
* Though this script attempts to simplify, it borrows heavily from Symfony's approach.
6+
*
7+
* @see https://github.com/symfony/symfony/blob/7.2/.github/build-packages.php
8+
*/
9+
10+
$output = shell_exec(__DIR__ . '/get-packages');
11+
$tempestPackages = json_decode($output, associative: true);
12+
13+
// Determine the dev version from inter-package dependencies.
14+
// This ensures we bundle packages with the same version that deps expect.
15+
$devVersion = 'dev-main';
16+
17+
foreach ($tempestPackages as $package) {
18+
$composerPath = sprintf('%s/composer.json', $package['directory']);
19+
$composerFile = json_decode(file_get_contents($composerPath), true);
20+
21+
foreach ($composerFile['require'] ?? [] as $dep => $version) {
22+
if (str_starts_with($dep, 'tempest/') && str_starts_with($version, 'dev-')) {
23+
$devVersion = $version;
24+
break 2;
25+
}
26+
}
27+
}
28+
29+
$composerPackages = [
30+
'packages' => [],
31+
];
32+
33+
foreach ($tempestPackages as $package) {
34+
$composerPath = sprintf('%s/composer.json', $package['directory']);
35+
$composerFile = json_decode(file_get_contents($composerPath), true);
36+
37+
// Bundle ALL packages as tar files to ensure consistent versions.
38+
// This ensures all inter-package dependencies (e.g., dev-3.x) can be
39+
// resolved from the local repository.
40+
passthru(sprintf("cd %s && tar -cf package.tar --exclude='package.tar' *", $package['directory']));
41+
42+
$composerFile['version'] = $devVersion;
43+
$composerFile['dist']['type'] = 'tar';
44+
$composerFile['dist']['url'] = 'file://'. $package['directory'] . '/package.tar';
45+
46+
// Add the package details to the root "packages.json."
47+
$composerPackages['packages'][$composerFile['name']][$composerFile['version']] = $composerFile;
48+
49+
// Load the packages from the root "packages.json" file we will write in a second.
50+
$composerFile['repositories'] = [
51+
[
52+
'type' => 'composer',
53+
'url' => realpath(__DIR__ . '/../'),
54+
]
55+
];
56+
57+
file_put_contents($composerPath, json_encode($composerFile, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
58+
}
59+
60+
file_put_contents(__DIR__ . '/../packages.json', json_encode($composerPackages, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
61+
62+
var_dump(file_get_contents(__DIR__ . '/../packages.json'));

0 commit comments

Comments
 (0)