From 6cf7e0b698b8a48eabdacbf045b7f6937cf23e3d Mon Sep 17 00:00:00 2001 From: Tracy Barlow Date: Sat, 5 Dec 2026 21:17:30 +0000 Subject: [PATCH] BUG: Build every package even when the plan releases only some In the rc nightly on 5 December only fiftyone_pipeline_did was in the release plan, so that was all the build made and all that package/pre-publish-requirements.txt listed. The integration tests install whatever the build made and then test each product's packages, so the tests of fiftyone_pipeline_cloudrequestengine and every other package had nothing to import and failed with ModuleNotFoundError (run 47545022469). Any plan that names only some packages would do that. The build now makes every published package whatever the plan says. Planned packages get their planned versions and the rest are built at their released version, which is what already happened when nothing was planned. Publishing now removes the distributions of packages that aren't in the plan before it uploads, so PyPI still gets only the planned ones. Until now that held because the build made nothing else. --- ci/packages.Tests.ps1 | 58 ++++++++++++++++++++++++++++++++++++++++-- ci/packages.ps1 | 35 ++++++++++++++++++++----- ci/publish-package.ps1 | 10 ++++++++ 3 files changed, 94 insertions(+), 9 deletions(-) diff --git a/ci/packages.Tests.ps1 b/ci/packages.Tests.ps1 index 63066049..60a26519 100644 --- a/ci/packages.Tests.ps1 +++ b/ci/packages.Tests.ps1 @@ -317,12 +317,28 @@ Source = "https://github.com/51Degrees/51degrees-python" } Describe 'Get-BuildPlan' { - It 'is the release plan when a package is to be released' { + It 'is the release plan and every other package at its released version' { $script:Repo = New-Repo $script:AllFiles ($script:AllTags + 'ipi/4.5.0') Add-Commit $script:Repo @('pipeline/engines/a.py') + @(Get-ReleasePlan $script:Repo $script:Graph).Name | + Should -Be @('engines', 'dd', 'ipi') $plan = @(Get-BuildPlan $script:Repo $script:Graph) - $plan.Name | Should -Be @('engines', 'dd', 'ipi') + $plan.Name | Should -Be @('core', 'did', 'engines', 'location', 'dd', 'ipi') ($plan | Where-Object Name -eq 'engines').Version | Should -Be '4.5.39' + ($plan | Where-Object Name -eq 'core').Version | Should -Be '4.5.38' + ($plan | Where-Object Name -eq 'core').Reason | + Should -Be 'already released, built for the tests' + ($plan | Where-Object Name -eq 'location').Version | Should -Be '4.5.4' + } + + It 'builds every package when only one is to be released' { + $script:Repo = New-Repo $script:AllFiles ($script:AllTags + 'ipi/4.5.0') + Add-Commit $script:Repo @('location/a.py') + @(Get-ReleasePlan $script:Repo $script:Graph).Name | Should -Be @('location') + $plan = @(Get-BuildPlan $script:Repo $script:Graph) + $plan.Count | Should -Be 6 + ($plan | Where-Object Name -eq 'location').Version | Should -Be '4.5.5' + ($plan | Where-Object Name -eq 'dd').Version | Should -Be '4.5.96' } It 'builds every published package at its released version when nothing changed' { @@ -346,6 +362,44 @@ Describe 'Get-BuildPlan' { } } +Describe 'Get-UnplannedDistributions' { + BeforeAll { + $script:Dir = Join-Path $TestDrive 'package' + New-Item -ItemType Directory -Path $script:Dir -Force | Out-Null + @( + 'fiftyone_pipeline_did-4.6.3.tar.gz', + 'fiftyone_pipeline_did-4.6.3-py3-none-any.whl', + 'fiftyone_pipeline_core-4.6.2.tar.gz', + 'fiftyone_pipeline_core-4.6.2-py3-none-any.whl', + 'fiftyone_pipeline_did-4.6.2.tar.gz', + 'fiftyone_pipeline_did_extra-4.6.3.tar.gz', + 'fiftyone_pipeline_did-4.6.30.tar.gz', + 'fiftyone_pipeline_did-4.6.3-1-py3-none-any.whl', + 'pre-publish-requirements.txt', + 'fiftyone_devicedetection-4.6.3.tar.gz' + ) | ForEach-Object { New-Item -ItemType File -Path (Join-Path $script:Dir $_) | Out-Null } + } + + It 'gives every file that is not a planned package at its planned version' { + $plan = @( + [pscustomobject]@{ Name = 'fiftyone_pipeline_did'; Version = '4.6.3' }, + [pscustomobject]@{ Name = 'fiftyone-devicedetection'; Version = '4.6.3' } + ) + @(Get-UnplannedDistributions $script:Dir $plan).Name | Sort-Object | + Should -Be (@( + 'fiftyone_pipeline_core-4.6.2-py3-none-any.whl', + 'fiftyone_pipeline_core-4.6.2.tar.gz', + 'fiftyone_pipeline_did-4.6.2.tar.gz', + 'fiftyone_pipeline_did-4.6.30.tar.gz', + 'fiftyone_pipeline_did_extra-4.6.3.tar.gz', + 'pre-publish-requirements.txt') | Sort-Object) + } + + It 'gives every file when nothing is planned' { + @(Get-UnplannedDistributions $script:Dir @()).Count | Should -Be 10 + } +} + Describe 'the real packages.json' { BeforeAll { $script:Real = Get-Packages (Split-Path $PSScriptRoot) diff --git a/ci/packages.ps1 b/ci/packages.ps1 index 886c2fbc..4bd6cc2c 100644 --- a/ci/packages.ps1 +++ b/ci/packages.ps1 @@ -127,20 +127,24 @@ function Get-AffectedProducts([string]$RepoPath, [string]$Branch = 'main') { return Resolve-AffectedProducts $packages $changed } -# What a build of HEAD makes: the release plan, or, when nothing changed since -# the last release, every published package at its released version. Nothing -# is published then, because package-update-required.ps1 finds the release -# plan empty, but the publish's tests still have the packages to install. +# What a build of HEAD makes: the release plan, and every other published +# package at its released version. The integration tests install every +# package from the build, whichever product they test, so a package left out +# would leave its own tests nothing to import. When the release plan is empty +# nothing is published, because package-update-required.ps1 finds it empty, +# and when it isn't, publish-package.ps1 uploads only the packages it plans. function Get-BuildPlan([string]$RepoPath, $Packages = $null) { if ($null -eq $Packages) { $Packages = Get-Packages $RepoPath } $plan = @(Get-ReleasePlan $RepoPath $Packages) - if ($plan.Count -gt 0) { - return $plan - } $published = @($Packages | Where-Object { $_.Publish -eq $true }) foreach ($name in (Sort-ByDependency $published @($published.Name))) { + $release = $plan | Where-Object { $_.Name -eq $name } + if ($null -ne $release) { + $release + continue + } $package = $published | Where-Object { $_.Name -eq $name } $last = @(Get-ReleasedVersions $RepoPath $name)[-1] [pscustomobject]@{ @@ -152,3 +156,20 @@ function Get-BuildPlan([string]$RepoPath, $Packages = $null) { } } } + +# The files in $PackageDir that aren't a distribution of a package in $Plan +# at its planned version. The build makes every package, so that the tests +# have them all, and these are the ones not to upload. A distribution's file +# name starts with the package name, with - . and _ written as _, then a - +# and the version. +function Get-UnplannedDistributions([string]$PackageDir, $Plan) { + $planned = @($Plan | ForEach-Object { + (($_.Name -replace '[-_.]+', '_').ToLowerInvariant()) + '-' + $_.Version + }) + Get-ChildItem -Path $PackageDir -File | Where-Object { + $file = $_.Name.ToLowerInvariant() + -not ($planned | Where-Object { + $file.StartsWith("$_.") -or $file.StartsWith("$_-") + }) + } +} diff --git a/ci/publish-package.ps1 b/ci/publish-package.ps1 index fc9f233b..5da241db 100644 --- a/ci/publish-package.ps1 +++ b/ci/publish-package.ps1 @@ -11,6 +11,16 @@ $PSNativeCommandUseErrorActionPreference = $true # change what the plan would say. $plan = @(Get-ReleasePlan $RepoName) +# The build makes every package, at its released version where it isn't +# planned, so that the tests have them all. Only the planned ones go up. With +# no plan, which happens only if another run released HEAD first, every file +# is a released version, which --skip-existing skips, as before. +$unplanned = $plan.Count -gt 0 ? @(Get-UnplannedDistributions 'package' $plan) : @() +foreach ($file in $unplanned) { + Write-Output "Not uploading $($file.Name), built only for the tests" + Remove-Item $file.FullName +} + ./python/publish-package-pypi.ps1 -DryRun $DryRun # One tag and one GitHub release per package, '/', in place