Skip to content

Accept SHA-pinned action refs in update-mslearn-dates workflow tests - #2252

Merged
Roland Krummenacher (RolandKrummenacher) merged 2 commits into
devfrom
RolandKrummenacher/fix-workflow-pin-assertions
Aug 13, 2026
Merged

Accept SHA-pinned action refs in update-mslearn-dates workflow tests#2252
Roland Krummenacher (RolandKrummenacher) merged 2 commits into
devfrom
RolandKrummenacher/fix-workflow-pin-assertions

Conversation

@RolandKrummenacher

Copy link
Copy Markdown
Collaborator

🐛 Problem

The Pester job is failing on dev, and therefore on every open PR.

Two assertions in src/powershell/Tests/Unit/Action.UpdateMsLearnDates.Tests.ps1 require a floating @vN tag:

$workflowContent | Should -Match 'uses:\s*actions/checkout@v\d+'
$workflowContent | Should -Match 'uses:\s*tj-actions/changed-files@v\d+'

Pinning the workflows to full-length commit SHAs rewrote those refs in .github/workflows/update-mslearn-dates.yml:

uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5

Neither matches @v\d+, so both assertions fail:

[-] Should checkout the PR branch
    Expected regular expression 'uses:\s*actions/checkout@v\d+' to match ...
[-] Should use changed-files action
    Expected regular expression 'uses:\s*tj-actions/changed-files@v\d+' to match ...

🔧 Solution

Widen both patterns to accept either a 40-character SHA pin or a version tag:

'uses:\s*actions/checkout@(?:[0-9a-f]{40}|v\d+)'
'uses:\s*tj-actions/changed-files@(?:[0-9a-f]{40}|v\d+)'

The tests' intent — that the workflow checks out the PR branch and uses changed-files — is preserved, and the suite now passes whether an action is SHA-pinned or tag-referenced, so re-pinning in future won't break it again.

These are the only two version-tag assertions of this kind in the test suite; I grepped for others and found none.

🧪 Validation

  • Action.UpdateMsLearnDates.Tests.ps1 + Action.UpdateMsLearnDates.AwkParity.Tests.ps1: 34 pass, 0 fail (was 2 failing).
  • Confirmed the failures reproduce on a clean dev worktree before the change, so this is a dev breakage rather than a PR-specific one.
  • PSScriptAnalyzer output is unchanged from dev (the one pre-existing PSUseDeclaredVarsMoreThanAssignments on line 7 is untouched).

Test-only change; no workflow or product code is modified.

🤖 Generated with Claude Code

…ests

Two assertions in Action.UpdateMsLearnDates.Tests.ps1 required a floating @vn
tag:

    $workflowContent | Should -Match 'uses:\s*actions/checkout@v\d+'
    $workflowContent | Should -Match 'uses:\s*tj-actions/changed-files@v\d+'

Pinning the workflows to full-length commit SHAs replaced those refs with
40-character SHAs plus a trailing version comment, so both assertions now fail.
This turns the Pester job red on dev and therefore on every open PR.

The assertions accept either form now, so the suite passes whether an action is
SHA-pinned or tag-referenced. The intent of the tests -- that the workflow checks
out the PR branch and uses changed-files -- is preserved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

Pull request overview

Updates the Pester unit tests for the update-mslearn-dates workflow to tolerate hardened GitHub Action references that are pinned to full commit SHAs, while still accepting the prior @vN tag format. This keeps the test suite aligned with the repository’s workflow security posture (SHA-pinned actions) without weakening the intent of the assertions.

Changes:

  • Broadened the uses: match patterns for actions/checkout and tj-actions/changed-files to accept either a 40-character SHA pin or a vN tag.
  • Added clarifying commentary explaining why SHA pins are accepted.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/powershell/Tests/Unit/Action.UpdateMsLearnDates.Tests.ps1 Outdated
actions/checkout is GitHub-maintained rather than third-party, so the comment
covering both it and tj-actions/changed-files should not call them third-party.
Addresses review feedback on #2252. No assertion or behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@RolandKrummenacher
Roland Krummenacher (RolandKrummenacher) merged commit ab629c1 into dev Aug 13, 2026
5 checks passed
@RolandKrummenacher
Roland Krummenacher (RolandKrummenacher) deleted the RolandKrummenacher/fix-workflow-pin-assertions branch August 13, 2026 07:34
@microsoft-github-policy-service

Copy link
Copy Markdown

@allcontributors

Copy link
Copy Markdown
Contributor

@microsoft-github-policy-service[bot]

Roland Krummenacher (@RolandKrummenacher) already contributed before to code

Roland Krummenacher (RolandKrummenacher) pushed a commit that referenced this pull request Aug 13, 2026
Resolves the conflict introduced by #2244, which bumped actions/checkout in
.github/workflows/opendata-commitment-eligibility.yml while this branch was
editing the `ref:` line directly beneath it. The two changes are additive, not
contradictory: the resolution keeps #2244's new pin
(3d3c42e5... v7.0.1, up from 11d5960a... v4.4.0) and this branch's
`ref: ${{ github.event.inputs.ref || 'dev' }}` plus the workflow_dispatch inputs.

Also brings in #2252, which fixes the two update-mslearn-dates assertions that
had been failing this branch's Pester run through no fault of its own.

Verified after resolution: no conflict markers remain, the workflow YAML parses,
both `ref` and `dry_run` inputs are present, the checkout step carries dev's new
SHA, the familycounts rename is intact, and 51 unit tests pass across both the
previously failing Action.UpdateMsLearnDates suite and this branch's own.

Note the dispatch run that validated this branch used checkout v4.4.0; the
scheduled job will now run v7.0.1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Review 👀 PR that is ready to be reviewed Tool: PowerShell PowerShell scripts and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants