From 3bb8dd9a0be67527e9e10f0aa2c9b27172ead933 Mon Sep 17 00:00:00 2001 From: Junyi Ou Date: Tue, 27 Oct 2026 10:52:49 -0400 Subject: [PATCH] ci: test the oracle marker check only when it changes The oracle marker check tests install Pester from PSGallery, and that download fails at times, failing CI for commits that never touched the check. The tests now run only when the commit changes the check or its tests, compared with the commit's first parent, which for a pull request is its base branch. Manual and release runs still run them every time. The steps are skipped rather than the job, because the success job requires every job to succeed. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8013a3fdc..aa5161393 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -259,12 +259,34 @@ jobs: uses: actions/checkout@v6 with: ref: ${{ needs.preflight.outputs.ref }} + # Detecting changes compares the commit with its first parent. + fetch-depth: 2 + + # Installing Pester from PSGallery fails at times, so a commit that leaves the check alone skips its tests. + # The steps are skipped rather than the job, because the success job requires every job to succeed. + - name: Detect changes to the check + id: changes + run: | + $Changed = 'true' + if (('${{ github.event_name }}' -In 'pull_request', 'push') -And -Not '${{ inputs.ref }}') { + $Files = git diff --name-only HEAD^1 HEAD -- ci/check-oracle-markers.ps1 ci/check-oracle-markers.Tests.ps1 + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + if (-Not $Files) { + $Changed = 'false' + } + } + echo "changed=$Changed" >> $Env:GITHUB_OUTPUT + shell: pwsh - name: Install Pester + if: ${{ steps.changes.outputs.changed == 'true' }} run: Install-Module Pester -RequiredVersion 5.6.0 -Force shell: pwsh - name: Pester tests + if: ${{ steps.changes.outputs.changed == 'true' }} run: | Import-Module Pester -RequiredVersion 5.6.0 $Result = Invoke-Pester ci/check-oracle-markers.Tests.ps1 -PassThru