Patch release script, fix and simplify dependency detection#48395
Patch release script, fix and simplify dependency detection#48395XiaofeiCao wants to merge 9 commits intoAzure:mainfrom
Conversation
Verifies that when an artifact is independently released to a newer GA version, dependents are correctly flagged for patching. Without the seeding loop (commit b3148a6), the forward-looking map would only contain the old version from the dependent's POM, causing the mismatch to go undetected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…AllArtifactsThatNeedPatching Replace the two-function dance (CreateForwardLookingVersions building a complex version map from POM deps, then FindAllArtifactsThatNeedPatching comparing against it) with a single FindArtifactsThatNeedPatching function that: 1. Seeds a version map directly from each artifact's LatestGAOrPatchVersion 2. Iterates in dependency order (guaranteed by patch_release_client.txt) 3. Only checks dependencies that are in the patch list (ignores external deps) This also fixes a latent bug where external dependency version inconsistencies (e.g., different reactor-core versions across artifacts) could trigger false positive patch detections. Deletes unused ArtifactsToPatchUtil which had bugs (undefined $depId variable, infinite recursion passing wrong parameter). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Simplifies patch release dependency detection for Azure SDK for Java patch pipelines by replacing the previous multi-pass “highest version wins” dependency scan with a patch-list-scoped, seeded version map approach intended to correctly detect independent dependency releases and avoid false positives from external dependencies.
Changes:
- Replaced
CreateForwardLookingVersions+FindAllArtifactsThatNeedPatchingwith a singleFindArtifactsThatNeedPatchingimplementation. - Updated patch release scripts to call the new function.
- Added Pester unit tests covering patch detection scenarios and helper functions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| eng/scripts/patchhelpers.ps1 | Replaces the patch detection algorithm with a seeded, patch-list-only dependency check. |
| eng/scripts/patchreleases.ps1 | Switches patch detection call site to the new function. |
| eng/scripts/Update-Artifacts-List-For-Patch-Release.ps1 | Switches patch detection call site to the new function (and updates a related comment). |
| eng/scripts/tests/patchhelpers.tests.ps1 | Adds new Pester tests for patch detection, patch version bumping, and topological sort behavior. |
You can also share your feedback on Copilot code review. Take the survey.
All patch scripts hardcoded $remoteName/main as the base for creating branches. This makes end-to-end local testing impossible without being on main. Add a -UseCurrentBranch switch that, when set, creates patch branches from HEAD instead of $remoteName/main. Threaded through all entry points and internal functions: - Generate-Patches-For-Automatic-Releases.ps1 - Generate-Patch.ps1 - generatepatch.ps1 - patchreleases.ps1 - GeneratePatch() / GeneratePatches() in bomhelpers.ps1 - GenerateBOMFile() in patchhelpers.ps1 Production behavior is unchanged (default creates from main). For local testing, add the switch: ./Generate-Patch.ps1 ... -UseCurrentBranch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
554ea14 to
65f7581
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
You can also share your feedback on Copilot code review. Take the survey.
| param( | ||
| [string[]]$ArtifactIds, | ||
| [string]$ServiceDirectoryName, | ||
| [string]$BranchName, | ||
| [string]$GroupId = 'com.azure' | ||
| [string]$GroupId = 'com.azure', | ||
| # When set, creates patch branches from the current branch instead of remote main. | ||
| [switch]$UseCurrentBranch | ||
| ) |
There was a problem hiding this comment.
The comment-based help lists parameters (ArtifactIds, ServiceDirectoryName, BranchName, GroupId, etc.), but the newly added -UseCurrentBranch switch isn’t included in the help text. Add a .PARAMETER entry (and example if appropriate) so the new behavior is discoverable.
| [Parameter(Mandatory=$false)][boolean]$CreateNewBranch = $true, | ||
| # When set, creates patch branches from the current branch instead of remote main. | ||
| [Parameter(Mandatory=$false)][switch]$UseCurrentBranch | ||
| ) |
There was a problem hiding this comment.
This script has a numbered list of supported arguments in the header comments, but the newly added -UseCurrentBranch parameter isn’t documented there. Please update the header argument list so users discover the new switch and understand when to use it.
The simplified single-pass algorithm assumed patch_release_client.txt was ordered by dependency (dependencies before dependents). In reality it's alphabetical. This caused dependents like azure-messaging-eventhubs- checkpointstore-blob to be missed when they appeared before their dependency (azure-storage-blob) in the iteration order. Replace the single foreach with a do/while fixed-point loop that iterates until no new patches are found, making the algorithm correct regardless of artifact ordering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f688b8b to
5dd762a
Compare
The changelog generation was reading dependency versions from the pom.xml
after update_versions.py ran, which writes beta/preview versions for
{x-version-update;...;current} markers. For patch releases, the changelog
should show GA/released versions (column 2 from version_client.txt).
Added GetResolvedDependencyVersions function that resolves dependency
versions from version_client.txt column 2 instead of the pom.xml. Applied
the fix to both GeneratePatch() in bomhelpers.ps1 and CreatePatchRelease()
in Generate-Patch.ps1.
Fixes incorrect changelog entries like:
'Upgraded azure-messaging-eventhubs from 5.21.3 to 5.22.0-beta.1'
which should instead show the GA version from version_client.txt col 2.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GetResolvedDependencyVersions now uses a layered resolution strategy: 1. PatchVersionOverrides (highest priority) - patch versions for sibling artifacts being patched in the same run 2. version_client.txt col 2 - GA version fallback for prerelease pom versions 3. pom.xml version - used as-is for GA versions and external deps The previous approach read only from version_client.txt col 2, which was never updated with patch versions (set_versions.py --new-version only changes col 3). This caused all deps to appear unchanged, producing the generic 'Upgraded core dependencies.' message. patchreleases.ps1 now builds a PatchVersionOverrides map from ArtifactInfos and passes it through GeneratePatches/GeneratePatch to the resolver. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The auto-release pipeline uses Generate-Patches-For-Automatic-Releases.ps1 → generatepatch.ps1 → GeneratePatch. This path was not passing PatchVersionOverrides, so sibling patch versions were invisible during changelog generation, resulting in 'Upgraded core dependencies.' instead of listing specific dependency changes. Fix: - generatepatch.ps1: accept -PatchVersionOverrides parameter - Generate-Patches-For-Automatic-Releases.ps1: build override map from YAML package list by querying Maven for each artifact's latest GA version and computing the next patch version Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bbf62ee to
af4fa47
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
You can also share your feedback on Copilot code review. Take the survey.
Changes
1. Fix patch detection algorithm (existing commits)
Replaced
CreateForwardLookingVersions+FindAllArtifactsThatNeedPatchingwith a single fixed-point loop. Fixes missing patch detection for artifacts whose dependencies have no sibling dependents in the patch list.2. Fix changelog showing beta versions (cd0d46b)
Added
GetResolvedDependencyVersionswith 3-tier resolution: PatchVersionOverrides > version_client.txt col 2 (GA) > pom.xml. Also fixed artifactId collision between com.azure and com.azure.v2.3. Fix changelog showing generic message (f4d20ee)
patchreleases.ps1now builds a PatchVersionOverrides map from ArtifactInfos and passes it through GeneratePatches so changelogs list specific dependency upgrades.4. Fix auto-release pipeline path (bbf62ee)
Generate-Patches-For-Automatic-Releases.ps1now queries Maven for each artifact latest GA version, computes patch versions, and passes the override map through generatepatch.ps1. Without this fix, the auto-release pipeline still produced the generic message from #3.Files Changed
eng/scripts/patchhelpers.ps1— simplified FindArtifactsThatNeedPatchingeng/scripts/bomhelpers.ps1— added GetResolvedDependencyVersions, updated GeneratePatch signatureseng/scripts/patchreleases.ps1— builds PatchVersionOverrides from ArtifactInfoseng/scripts/Generate-Patch.ps1— uses pom + prerelease-to-col2 fallbackeng/scripts/generatepatch.ps1— accepts and passes PatchVersionOverrideseng/scripts/Generate-Patches-For-Automatic-Releases.ps1— builds override map from YAMLeng/scripts/tests/patchhelpers.tests.ps1— 23 tests