Skip to content

Add Java release API hashes from staged sources - #51391

Open
Weidong Xu (weidongxu-microsoft) wants to merge 4 commits into
mainfrom
weidongxu/java-release-api-hash
Open

Weidong Xu (weidongxu-microsoft) wants to merge 4 commits into
mainfrom
weidongxu/java-release-api-hash

Conversation

@weidongxu-microsoft

@weidongxu-microsoft Weidong Xu (weidongxu-microsoft) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Changes

Calculate PackageInfo ApiHash locally from staged sources JARs using ARH's generator. Cover shared PR/service builds and the separate source-built patch pipeline; preserve existing package metadata through artifact transfers.

No ARH submissions, approval gates, review labels, or release-policy changes. Patch hashing prepares migration of its existing post-release APIView call, not a new approval check.

Validation

Coverage Result
Focused PowerShell tests and analyzer 22 tests passed; analyzer passed. All 10 hash tests also passed with CI's UnitTest filter.
Batch build-only CI Passed after one playback-test retry. Published hash independently matched the exact staged sources JAR. Signing, release, and integration stages skipped.
Normal PR CI Passed. Selected tooling package's published hash independently matched its sources JAR.
Multi-origin test PR, CI run Passed after retrying only one Batch playback-test job. All five modules selected by README changes; published hashes, versions, and paths independently verified against every exact staged sources JAR. Build, analysis, SDL, source-built tests, and Java CodeQL passed.

These completed CI runs precede the warning-only update in e0c4038; CI for that commit is pending.

Multi-origin coverage: data-plane azure-compute-batch, control-plane azure-resourcemanager-compute, core azure-core, JSON azure-json, and tooling api-review-maven-plugin. Tooling built once (~38 seconds); hashing all five took ~26 seconds.

Considerations

Case Handling / evidence
POM-only package Skipped without changing metadata or adding ApiHash. Verified with actual local azure-sdk-bom 1.3.10 build output; its dedicated BOM pipeline is unchanged.
Binary JAR without sources Warn and skip hashing. Existing required Maven artifact validation remains unchanged. Covered by focused tests, including continuing with another valid package. Multiple sources JARs still fail.
API generation failure Warn and skip hashing, leaving metadata unchanged and clearing the handled native exit code. Verified with the actual archetype sources JAR's template parsing failure and a focused test.
Internal JAR-only tooling Actual azure-openrewrite-compiler-maven-plugin build produced a binary without sources, but it is not a release artifact and has no releasable PackageInfo, so it is not a hash candidate.
Metadata without staged artifacts Skipped; covered by focused tests.
JDK selection Uses the image's existing JAVA_HOME_17_X64, scoped to hash-tool tasks; does not change other SDK/test tasks' Java selection.

Live patch/signing flows and full-repository scale have not been validated. The disposable multi-origin test PR was closed without merging.

Reuse the ARH executable for release PackageInfo ApiHash metadata, including source-built patch packages. Preserve metadata through existing signed-artifact transfers without adding approval or publication gates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b
Copilot AI balanced review requested due to automatic review settings November 24, 2026 03:22
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

Add sdk-api-review-ready when this working PR is ready for API review of api-review-maven-plugin. No eligible baseline release exists for target version 1.0.0-beta.1, so the review will use an empty baseline and include all APIs. If you need a different comparison, use the Azure SDK CLI (azsdk apireview create).

@github-actions github-actions Bot added the Azure SDK Tools Label for tracking issues related to Azure SDK Tools label Nov 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
33 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

3 open issues
What changed in this PR

Adds automation to compute and persist Java API review hashes into staged PackageInfo metadata, and ensures tooling can be staged from sparse checkouts.

Changes:

  • Introduces Save-Package-ApiHash-Property.ps1 (and Pester tests) to compute ApiHash from staged *-sources.jar without rebuilding packages.
  • Updates Stage-ApiReviewTools.ps1 to optionally expand sparse checkouts to include required tooling sources.
  • Integrates API-hash saving into CI/release pipelines via a reusable pipeline step template.
File Description
sdk/​tools/​api-review-maven-plugin/​README.md Documents how SDK pipelines use the tool to persist ApiHash into PackageInfo.
eng/​scripts/​tests/​Save-Package-ApiHash-Property.tests.ps1 Adds test coverage for saving/skipping/rejecting API hashes and preserving PackageInfo fields.
eng/​scripts/​tests/​ApiReviewHub.tests.ps1 Adds coverage for sparse-checkout expansion behavior and -WhatIf behavior.
eng/​scripts/​Stage-ApiReviewTools.ps1 Adds -ExpandSparseCheckout option and git sparse-checkout mutation logic.
eng/​scripts/​Save-Package-ApiHash-Property.ps1 New script that runs the tooling against staged sources JARs and writes ApiHash into PackageInfo.
eng/​pipelines/​templates/​steps/​save-package-api-hash.yml New pipeline step template to build tooling + save hashes (Java 17 + PowerShell scripts).
eng/​pipelines/​templates/​stages/​archetype-sdk-client-patch.yml Wires the new step template into the patch archetype stage.
eng/​pipelines/​templates/​jobs/​ci.yml Wires the new step template into CI job flow.

Review effort: Lite

Comment thread eng/scripts/Stage-ApiReviewTools.ps1 Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b
Copilot AI balanced review requested due to automatic review settings November 24, 2026 03:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human verification is needed because normal CI and end-to-end signing and artifact-transfer checks remain pending, leaving published PackageInfo ApiHash retention unverified across shared normal and patch release pipelines.

3 open issues

Review effort: Balanced

@weidongxu-microsoft

Copy link
Copy Markdown
Member Author

The task-scoped JDK selection follows existing repository practice: build-and-test.yml sets JAVA_HOME for individual PowerShell/Maven tasks, and Set-PowerShellJavaHome.ps1 obtains the path from the preinstalled JAVA_HOME_<version>_X64 variable.

Hashing uses JAVA_HOME_17_X64 without changing the Java environment of later steps. Batch validation 7107178 passed, and the published ApiHash matched independent rendering of the exact built sources JAR.

This retains the repository’s existing preinstalled-JDK assumption, not a guarantee for future images. An image without JDK 17 would require corresponding provisioning or configuration changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b
Copilot AI balanced review requested due to automatic review settings November 24, 2026 04:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Hash generation now affects every staged binary package, but CI, published PackageInfo verification, and real signing remain unverified, requiring human validation of end-to-end signed artifact metadata.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

-Artifacts ('$(ArtifactsJsonEscaped)' | ConvertFrom-Json | Where-Object -Not skipPublishPackage)
-InformationAction Continue

- template: /eng/pipelines/templates/steps/save-package-api-hash.yml

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the existing APIView lifecycle: the patch pipeline calls APIView after publication to mark packages as shipped. We generate ApiHash here so the metadata is ready when that call is replaced by ARH's mark-released operation. This prepares the planned migration without adding an ARH call or a new release gate today.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d47c40e0-dce3-4856-b258-f62b42922e1b
Copilot AI balanced review requested due to automatic review settings November 24, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the staged-source API hashing changes.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure SDK Tools Label for tracking issues related to Azure SDK Tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants