Support PEP440 Post-Releases in SemVer.ps1#14495
Open
JennyPng wants to merge 16 commits intoAzure:mainfrom
Open
Support PEP440 Post-Releases in SemVer.ps1#14495JennyPng wants to merge 16 commits intoAzure:mainfrom
JennyPng wants to merge 16 commits intoAzure:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Python PEP 440 post-release (.postN) support to the shared SemVer parsing/sorting logic used across eng scripts, and mirrors that behavior in the TypeScript semver parser used by spec-gen-sdk.
Changes:
- Extend
AzureEngSemanticVersion(PowerShell) to recognize/normalize/sort Python post-releases and update changelog parsing to use a Python-aware title regex when$Language == "python". - Refactor
copy-docs-to-blobstorage.ps1to reuseAzureEngSemanticVersionrather than maintaining a separate semver regex/sort implementation. - Update the TypeScript
parseSemverVersionStringimplementation + tests to support post-releases; add/extend Pester tests for SemVer, changelog parsing, and docs version sorting.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/spec-gen-sdk/src/utils/parseSemverVersionString.ts | Add Python-specific regex/logic for PEP 440 post-releases and return post-release metadata. |
| tools/spec-gen-sdk/test/utils/parseSemverVersionString.test.ts | Add Vitest coverage for Python post-release parsing and non-Python behavior. |
| eng/common/scripts/SemVer.ps1 | Add PYTHON_SEMVER_REGEX and post-release parsing/normalization/sorting in AzureEngSemanticVersion. |
| eng/common/scripts/ChangeLog-Operations.ps1 | Use Python-aware release title regex when $Language indicates Python. |
| eng/common/scripts/copy-docs-to-blobstorage.ps1 | Replace local semver regex parsing with AzureEngSemanticVersion and rely on its comparer for sorting. |
| eng/common/scripts/artifact-metadata-parsing.ps1 | Update SDist filename parsing regex to allow Python post-releases. |
| eng/scripts/python_version_check.py | Extend version extraction to allow .postN versions. |
| eng/common-tests/SemVer.Tests.ps1 | Add Pester coverage for post-release parsing/normalization/sorting/increment behavior. |
| eng/common-tests/ChangeLog-Operations.Tests.ps1 | Add Pester coverage for parsing/sorting changelogs containing post-releases. |
| eng/common-tests/copy-docs-to-blobstorage.Tests.ps1 | Add Pester coverage for docs version parsing/sorting with post-releases. |
You can also share your feedback on Copilot code review. Take the survey.
Member
|
/azp run tools - sync-eng-common |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
Collaborator
|
The following pipelines have been queued for testing: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5916
PYTHON_SEMVER_REGEXwhich is conditionally used when the language is Python. Regex validation: https://regex101.com/r/rAdOg0/2 . Post-release handling logic is placed in the constructor of theAzureEngSemanticVersionclassKnown downstream consumers of SemVer :
SDIST_SEMVER_REGEXinartifact-metadata-parsing.ps1is only used by Python's Language-Settings inGet-python-PackageInfoFromPackageFileto match the package name - directly modifying this shouldn't affect other languageseng/common/scripts/Update-DevOps-Release-WorkItem.ps1constructs semver to check VersionType - should be fine, since the constructor is where post-release parsing is handledChangeLog-Operationsused the SEMVER_REGEX to construct a release title match and get entries from the changelog - this was updated to conditionally use the Python version. Pester tests were addedcopy-docs-to-blobstorage.ps1had an identical copy of the SEMVER_REGEX to parse prerelease metadata and sort - I refactored this to use SemVer because it seemed redundant, and added testsparseSemverVersionString.ts- seems to be a rewrite of SemVer.ps1 but in TypeScript. Edited this and its tests to model after changes made to SemVerQuestions
python-version-check- has its own regex to extract version from changelog and used in apistub's CI for validation, but the current regex doesn't even support pre-release, so unsure if this needs to account for post-release