Skip to content

Commit 8bd05a5

Browse files
committed
fix(actions): add 3.x branch support for isolated tests and subsplit
1 parent ba186a9 commit 8bd05a5

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

bin/build-changed-packages

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,46 @@
55
* Though this script attempts to simplify, it borrows heavily from Symfony's approach.
66
*
77
* @see https://github.com/symfony/symfony/blob/7.2/.github/build-packages.php
8-
*
9-
* TODO: This script is not really optimized, because it runs on every unit test action.
108
*/
119

12-
$tempestPackages = json_decode(
13-
json: exec(__DIR__ . '/get-packages'),
14-
associative: true
15-
);
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+
}
1628

1729
$composerPackages = [
1830
'packages' => [],
1931
];
2032

2133
foreach ($tempestPackages as $package) {
22-
// Find out if there are changes in this package.
23-
$diff = exec(sprintf('git diff --name-only HEAD^ -- %s', $package['directory']));
24-
2534
$composerPath = sprintf('%s/composer.json', $package['directory']);
2635
$composerFile = json_decode(file_get_contents($composerPath), true);
2736

28-
// If there are changes, bundle the package and
29-
// add it to our root packages.json file.
30-
if (empty($diff) === false) {
31-
// Bundle the current package as a tar file.
32-
passthru(sprintf("cd %s && tar -cf package.tar --exclude='package.tar' *", $package['directory']));
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']));
3341

34-
// TODO: Update the package version.
35-
$composerFile['version'] = 'dev-main';
36-
$composerFile['dist']['type'] = 'tar';
37-
$composerFile['dist']['url'] = 'file://'. $package['directory'] . '/package.tar';
42+
$composerFile['version'] = $devVersion;
43+
$composerFile['dist']['type'] = 'tar';
44+
$composerFile['dist']['url'] = 'file://'. $package['directory'] . '/package.tar';
3845

39-
// Add the package details to the root "packages.json."
40-
$composerPackages['packages'][$composerFile['name']][$composerFile['version']] = $composerFile;
41-
}
46+
// Add the package details to the root "packages.json."
47+
$composerPackages['packages'][$composerFile['name']][$composerFile['version']] = $composerFile;
4248

4349
// Load the packages from the root "packages.json" file we will write in a second.
4450
$composerFile['repositories'] = [

0 commit comments

Comments
 (0)