⚙️ [Maintenance]: Validate prerelease version format in test workflow#20
Conversation
|
Marius Storhaug (@MariusStorhaug) I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you. |
The prerelease version assertion in the test workflow was matching
against a hardcoded list of identifiers (`preview|rc|alpha|beta`),
making it brittle and incomplete.
## Changes
- **`.github/workflows/Action-Test.yml`**: Replace specific identifier
regex with a simple hyphen presence check — consistent with how
prerelease detection works elsewhere in `action.yml`
```diff
- if ($installed -notmatch '-(preview|rc|alpha|beta)\.') {
- throw "Prerelease validation failed: installed version '$installed' does not contain a prerelease identifier (-preview, -rc, -alpha, -beta)."
+ if ($installed -notmatch '-') {
+ throw "Prerelease validation failed: installed version '$installed' does not contain a prerelease segment."
```
<!-- START COPILOT CODING AGENT TIPS -->
---
🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds validation to the test workflow to ensure that when testing with the 'prerelease' matrix entry, the installed PowerShell version is actually a prerelease build and not a stable release. This addresses issue #18 by preventing tests from silently passing if the prerelease resolution falls back to a stable version.
Changes:
- Added prerelease format validation that checks if the installed version contains a hyphen (indicating a prerelease segment) when testing the 'prerelease' matrix entry
- The validation throws an error if a prerelease test installs a version without a prerelease identifier
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # contains a prerelease segment so we never silently fall back to stable. | ||
| $matrixVersion = '${{ matrix.version }}' | ||
| if ($matrixVersion.Trim().ToLower() -eq 'prerelease') { | ||
| if ($installed -notmatch '-') { |
There was a problem hiding this comment.
The regex pattern -notmatch '-' is less strict than what was specified in both the PR description and the issue requirements.
The PR description states the check should be:
$installed -notmatch '-(preview|rc|alpha|beta)\.'
The issue #18 also specifies:
$installed -match '-preview|-(rc|alpha|beta)\.'
The current implementation only checks for the presence of any hyphen, which could match invalid prerelease identifiers. According to the stored memories about prerelease format, PowerShell prerelease versions should contain specific identifiers like 'preview', 'rc', 'alpha', or 'beta' followed by a dot and number (e.g., '7.4.0-preview.5').
The pattern should be stricter to ensure it matches only valid prerelease identifiers, not any string with a hyphen.
| $matrixVersion = '${{ matrix.version }}' | ||
| if ($matrixVersion.Trim().ToLower() -eq 'prerelease') { | ||
| if ($installed -notmatch '-') { | ||
| throw "Prerelease validation failed: installed version '$installed' does not contain a prerelease segment." | ||
| } | ||
| Write-Host "Prerelease check passed: '$installed' contains a prerelease segment." | ||
| } |
There was a problem hiding this comment.
The prerelease validation only checks for $matrixVersion -eq 'prerelease', but the test matrix also includes a pinned prerelease version '7.4.0-preview.5' (line 25). According to the issue requirements, pinned versions should only do exact-match comparison, which is already done on lines 99-101. However, if this pinned prerelease version is being tested, there's an inconsistency in validation rigor.
Consider whether pinned prerelease versions should also validate the prerelease format. If the intent is to only validate the dynamically-resolved 'prerelease' entry, this is correct. Otherwise, you could also check if the matrix version itself contains a prerelease identifier and validate that the installed version matches that pattern.
The prerelease test verification now additionally asserts that the installed version string contains a prerelease identifier (
-preview,-rc,-alpha,-beta), ensuring the test never silently passes when falling back to a stable build.latestandprereleaseversions live and validate preview version format #18Prerelease version format validation
After verifying that the installed version matches the resolved version (existing behaviour), the test now performs an additional regex check for prerelease matrix entries:
This catches scenarios where the prerelease resolution might accidentally return a stable version string, or where the install falls back to stable without error.
Stable (
latest) and pinned version tests are unaffected — they continue to use exact-match comparison only.