From 7ad128621f72ad2816d84f7e838cb1dad1f502d1 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 13:38:28 -0700 Subject: [PATCH 01/24] Add support for `github-mirror` branch in CI workflow and update conditional checks for repository owner --- .github/workflows/linux-ci.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 54282fc62f6..637d39260fd 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -9,6 +9,7 @@ on: branches: - master - release/** + - github-mirror paths: - "**" - "!.github/ISSUE_TEMPLATE/**" @@ -19,6 +20,7 @@ on: branches: - master - release/** + - github-mirror # Path filters for PRs need to go into the changes job concurrency: @@ -52,6 +54,7 @@ jobs: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 + if: github.repository_owner == 'PowerShell' id: filter with: list-files: json @@ -72,7 +75,7 @@ jobs: name: Build PowerShell runs-on: ubuntu-latest needs: changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} steps: - name: checkout uses: actions/checkout@v4 @@ -86,7 +89,7 @@ jobs: needs: - ci_build - changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -103,7 +106,7 @@ jobs: needs: - ci_build - changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -120,7 +123,7 @@ jobs: needs: - ci_build - changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -137,7 +140,7 @@ jobs: needs: - ci_build - changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -154,7 +157,7 @@ jobs: needs: - ci_build - changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -172,7 +175,7 @@ jobs: name: Analyze runs-on: ubuntu-latest needs: changes - if: ${{ needs.changes.outputs.source == 'true' }} + if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} strategy: fail-fast: false From 49551cf7db9b4c3be6cd359e76d7fc39b40b8051 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 13:47:26 -0700 Subject: [PATCH 02/24] Add GitHub token to checkout step in Linux CI workflow --- .github/workflows/linux-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 637d39260fd..7aebdf05b1c 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -45,12 +45,15 @@ jobs: # Required permissions permissions: pull-requests: read + # Set job outputs to values from filter step outputs: source: ${{ steps.filter.outputs.source }} steps: - name: checkout uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 From c2df067176b13da3edd033abed68bef8a5cf7187 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 13:50:07 -0700 Subject: [PATCH 03/24] Update Linux CI workflow to disable credential persistence during checkout --- .github/workflows/linux-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 7aebdf05b1c..4ce8a5c9e5a 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -53,7 +53,7 @@ jobs: - name: checkout uses: actions/checkout@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + persist-credentials: false # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 From 68d5b69ff1e766c8987545b7420547524a4788b7 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 13:55:49 -0700 Subject: [PATCH 04/24] Add read permission for contents in Linux CI workflow --- .github/workflows/linux-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 4ce8a5c9e5a..343ae262f84 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -45,6 +45,7 @@ jobs: # Required permissions permissions: pull-requests: read + contents: read # Set job outputs to values from filter step outputs: From 475131c8e312ece4d9525a613b4d3412656b7080 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 14:04:52 -0700 Subject: [PATCH 05/24] Remove unnecessary conditional check for repository owner in Linux CI workflow --- .github/workflows/linux-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 343ae262f84..0c00dcae628 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -58,7 +58,6 @@ jobs: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 - if: github.repository_owner == 'PowerShell' id: filter with: list-files: json From 05812d96a79c5f75cc4c7d62016b482e64d963bf Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 16:00:36 -0700 Subject: [PATCH 06/24] Update GitHub test reporter action to a specific commit version --- .github/actions/test/process-pester-results/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index 758bbdfc353..74132093f5b 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -27,7 +27,7 @@ runs: # this task only takes / as directory separators - name: Publish Test Report - uses: ctrf-io/github-test-reporter@v1 + uses: ctrf-io/github-test-reporter@d1e394283c0ca33d34c9b6d8983aaef6945b52ec with: report-path: './${{ inputs.ctrfFolder }}/*.json' exit-on-fail: true From 781152c28e6c92f3c588317899d67c0d854e3d08 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 17:09:27 -0700 Subject: [PATCH 07/24] Add conditional check for repository owner in test report action --- .github/actions/test/process-pester-results/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index 74132093f5b..a33188db729 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -27,6 +27,7 @@ runs: # this task only takes / as directory separators - name: Publish Test Report + if: github.repository_owner == 'PowerShell' uses: ctrf-io/github-test-reporter@d1e394283c0ca33d34c9b6d8983aaef6945b52ec with: report-path: './${{ inputs.ctrfFolder }}/*.json' From 53c58c908f05bb3ba25bcd795ca707c742d1d2d2 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 17:12:57 -0700 Subject: [PATCH 08/24] Add conditional check for repository owner in Linux CI workflow --- .github/workflows/linux-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 0c00dcae628..343ae262f84 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -58,6 +58,7 @@ jobs: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 + if: github.repository_owner == 'PowerShell' id: filter with: list-files: json From dd1d565a54e99aa410ec1655af46f6f1a4c4fc0b Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 17:30:40 -0700 Subject: [PATCH 09/24] Add GitHub Actions error logging to Write-Log function --- build.psm1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.psm1 b/build.psm1 index 6a809d4231d..0ace5e522ed 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2693,6 +2693,10 @@ function script:Write-Log if ($isError) { Write-Host -Foreground Red $message + if($env:GITHUB_WORKFLOW) + { + Write-Host "::error::${message}" + } } else { From dbea97edf79b8395ed45fd083d20a4edcfc1d88a Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 17:44:58 -0700 Subject: [PATCH 10/24] Add summary logging for Pester test results in GitHub Actions --- .../test/process-pester-results/action.yml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index a33188db729..59d64596ebe 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -18,7 +18,34 @@ inputs: runs: using: composite steps: + - name: Log Summary + run: | + $testCaseCount = 0 + $testErrorCount = 0 + $testFailureCount = 0 + $testDisabledCount = 0 + Get-ChildItem -Path "${{ inputs.testResultsFolder }}/*.xml" -Recurse | ForEach-Object { + $results = [xml] (get-content $_.FullName) + $testCaseCount += $results.testsuites.tests + $testErrorCount += $results.testsuites.errors + $testFailureCount += $results.testsuites.failures + $testDisabledCount += $results.testsuites.disabled + } + + @" + + # Summary of ${{ inputs.name }} + + - Total Tests: $testCaseCount + - Total Errors: $testErrorCount + - Total Failures: $testFailureCount + - Total Disabled: $testDisabledCount + + "@ >> $GITHUB_STEP_SUMMARY + shell: pwsh + - name: Convert JUnit to CTRF + if: github.repository_owner == 'PowerShell' run: |- Get-ChildItem -Path "${{ inputs.testResultsFolder }}/*.xml" -Recurse | ForEach-Object { npx --yes junit-to-ctrf $_.FullName --output ./${{ inputs.ctrfFolder }}/$($_.BaseName).json --tool Pester From 212e376eaa609f2ba74284066e79b99c04c68faf Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 17:46:41 -0700 Subject: [PATCH 11/24] Add conditional check for repository owner in Pester results publishing step --- .github/actions/test/process-pester-results/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index 59d64596ebe..b302c616c1b 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -54,7 +54,7 @@ runs: # this task only takes / as directory separators - name: Publish Test Report - if: github.repository_owner == 'PowerShell' + if: always() && github.repository_owner == 'PowerShell' uses: ctrf-io/github-test-reporter@d1e394283c0ca33d34c9b6d8983aaef6945b52ec with: report-path: './${{ inputs.ctrfFolder }}/*.json' @@ -75,7 +75,6 @@ runs: pull-request-report: false commit-report: false custom-report: false - if: always() - name: Upload testResults artifact if: always() From be38927ee5b4904df79f0b461f51112d09df1857 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 18:00:58 -0700 Subject: [PATCH 12/24] Remove JUnit to CTRF conversion and test report publishing steps for non-PowerShell repositories --- .../test/process-pester-results/action.yml | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index b302c616c1b..b1f5d228699 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -44,48 +44,9 @@ runs: "@ >> $GITHUB_STEP_SUMMARY shell: pwsh - - name: Convert JUnit to CTRF - if: github.repository_owner == 'PowerShell' - run: |- - Get-ChildItem -Path "${{ inputs.testResultsFolder }}/*.xml" -Recurse | ForEach-Object { - npx --yes junit-to-ctrf $_.FullName --output ./${{ inputs.ctrfFolder }}/$($_.BaseName).json --tool Pester - } - shell: pwsh - - # this task only takes / as directory separators - - name: Publish Test Report - if: always() && github.repository_owner == 'PowerShell' - uses: ctrf-io/github-test-reporter@d1e394283c0ca33d34c9b6d8983aaef6945b52ec - with: - report-path: './${{ inputs.ctrfFolder }}/*.json' - exit-on-fail: true - summary-report: true - test-report: false - test-list-report: false - failed-report: false - fail-rate-report: false - flaky-report: false - flaky-rate-report: false - failed-folded-report: true - previous-results-report: false - ai-report: true - skipped-report: false - suite-folded-report: false - suite-list-report: false - pull-request-report: false - commit-report: false - custom-report: false - - name: Upload testResults artifact if: always() uses: actions/upload-artifact@v4 with: name: junit-pester-${{ inputs.name }} path: ${{ runner.workspace }}/testResults - - - name: Upload ctrf artifact - if: always() - uses: actions/upload-artifact@v4 - with: - name: ctrf-pester-${{ inputs.name }} - path: ${{ inputs.ctrfFolder }} From 98bbcc2478b54b6d47115d5d3a170b683e59c3a7 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 25 Mar 2025 18:27:28 -0700 Subject: [PATCH 13/24] Add GitHub Actions filter to check for changes in workflows, actions, tools, props, tests, and main source --- .github/workflows/linux-ci.yml | 63 +++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 343ae262f84..afdee5b21e5 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -56,23 +56,62 @@ jobs: with: persist-credentials: false - # For pull requests it's not necessary to checkout the code - - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 - if: github.repository_owner == 'PowerShell' + - name: Check if GitHubWorkflowChanges is present id: filter + uses: actions/github-script@v7.0.1 with: - list-files: json - filters: .github/action-filters.yml + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // Fetch the list of files changed in the PR + let files = []; + let page = 1; + let fetchedFiles; + do { + fetchedFiles = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + per_page: 100, + page: page++ + }); + files = files.concat(fetchedFiles.data); + } while (fetchedFiles.data.length > 0); + + const actionsChanged = files.some(file => file.filename.startsWith('.github/actions')); + const workflowsChanged = files.some(file => file.filename.startsWith('.github/workflows')); + const githubChanged = actionsChanged || workflowsChanged; + + const toolsCiPsm1Changed = files.some(file => file.filename.startsWith('tools/ci.psm1')); + const toolsBuildCommonChanged = files.some(file => file.filename.startsWith('tools/buildCommon/')); + const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged; + + const propsChanged = files.some(file => file.filename.endsWith('.props')); + + const testsChanged = files.some(file => file.filename.startsWith('test/powershell/') || file.filename.startsWith('test/tools/') || file.filename.startsWith('test/xUnit/')); + + const mainSourceChanged = files.some(file => file.filename.startsWith('src/')); + + const buildModuleChanged = files.some(file => file.filename.startsWith('build.psm1')); + + const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged; + + core.setOutput('toolsChanged', toolsChanged); + core.setOutput('githubChanged', githubChanged); + core.setOutput('propsChanged', propsChanged); + core.setOutput('testsChanged', testsChanged); + core.setOutput('mainSourceChanged', mainSourceChanged); + core.setOutput('buildModuleChanged', buildModuleChanged); + core.setOutput('source', source); - name: Capture outputs run: | - "source: ${{ steps.filter.outputs.source }}" - "github: ${{ steps.filter.outputs.github }}" - "tools: ${{ steps.filter.outputs.tools }}" - "props: ${{ steps.filter.outputs.props }}" - "tests: ${{ steps.filter.outputs.tests }}" - "mainSource: ${{ steps.filter.outputs.mainSource }}" - "buildModule: ${{ steps.filter.outputs.buildModule }}" + Write-Verbose -Verbose "source: ${{ steps.filter.outputs.source }}" + Write-Verbose -Verbose "github: ${{ steps.filter.outputs.githubChanged }}" + Write-Verbose -Verbose "tools: ${{ steps.filter.outputs.toolsChanged }}" + Write-Verbose -Verbose "props: ${{ steps.filter.outputs.propsChanged }}" + Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}" + Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}" + Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}" shell: pwsh ci_build: From 167709cf78ab3beafc293e4b61bc8c143151d466 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 27 Mar 2025 13:53:02 -0700 Subject: [PATCH 14/24] Refactor conditional checks in Linux CI workflow to remove repository owner dependency --- .github/workflows/linux-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index afdee5b21e5..6e79e381696 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -118,7 +118,7 @@ jobs: name: Build PowerShell runs-on: ubuntu-latest needs: changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} steps: - name: checkout uses: actions/checkout@v4 @@ -132,7 +132,7 @@ jobs: needs: - ci_build - changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -149,7 +149,7 @@ jobs: needs: - ci_build - changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -166,7 +166,7 @@ jobs: needs: - ci_build - changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -183,7 +183,7 @@ jobs: needs: - ci_build - changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -200,7 +200,7 @@ jobs: needs: - ci_build - changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} runs-on: ubuntu-latest steps: - name: checkout @@ -218,7 +218,7 @@ jobs: name: Analyze runs-on: ubuntu-latest needs: changes - if: ${{ startsWith(github.repository_owner, 'azure') || needs.changes.outputs.source == 'true' }} + if: ${{ needs.changes.outputs.source == 'true' }} strategy: fail-fast: false From b806844bd6782d289bce4148eed83912a26284ad Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 27 Mar 2025 15:37:13 -0700 Subject: [PATCH 15/24] Add path filters action for change detection in workflows --- .../infrastructure/path-filters/action.yml | 84 +++++++++++++++++++ .github/workflows/linux-ci.yml | 58 +------------ .github/workflows/macos-ci.yml | 17 +--- .github/workflows/windows-ci.yml | 18 +--- 4 files changed, 90 insertions(+), 87 deletions(-) create mode 100644 .github/actions/infrastructure/path-filters/action.yml diff --git a/.github/actions/infrastructure/path-filters/action.yml b/.github/actions/infrastructure/path-filters/action.yml new file mode 100644 index 00000000000..9226a49ee90 --- /dev/null +++ b/.github/actions/infrastructure/path-filters/action.yml @@ -0,0 +1,84 @@ +name: Path Filters +description: 'Path Filters' +outputs: + source: + description: 'Source code changes (composite of all changes)' + value: ${{ steps.filter.outputs.source }} + githubChanged: + description: 'GitHub workflow changes' + value: ${{ steps.filter.outputs.githubChanged }} + toolsChanged: + description: 'Tools changes' + value: ${{ steps.filter.outputs.toolsChanged }} + propsChanged: + description: 'Props changes' + value: ${{ steps.filter.outputs.propsChanged }} + testsChanged: + description: 'Tests changes' + value: ${{ steps.filter.outputs.testsChanged }} + mainSourceChanged: + description: 'Main source code changes (any changes in src/)' + value: ${{ steps.filter.outputs.mainSourceChanged }} + buildModuleChanged: + description: 'Build module changes' + value: ${{ steps.filter.outputs.buildModuleChanged }} +runs: + using: composite + steps: + - name: Check if GitHubWorkflowChanges is present + id: filter + uses: actions/github-script@v7.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // Fetch the list of files changed in the PR + let files = []; + let page = 1; + let fetchedFiles; + do { + fetchedFiles = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + per_page: 100, + page: page++ + }); + files = files.concat(fetchedFiles.data); + } while (fetchedFiles.data.length > 0); + + const actionsChanged = files.some(file => file.filename.startsWith('.github/actions')); + const workflowsChanged = files.some(file => file.filename.startsWith('.github/workflows')); + const githubChanged = actionsChanged || workflowsChanged; + + const toolsCiPsm1Changed = files.some(file => file.filename.startsWith('tools/ci.psm1')); + const toolsBuildCommonChanged = files.some(file => file.filename.startsWith('tools/buildCommon/')); + const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged; + + const propsChanged = files.some(file => file.filename.endsWith('.props')); + + const testsChanged = files.some(file => file.filename.startsWith('test/powershell/') || file.filename.startsWith('test/tools/') || file.filename.startsWith('test/xUnit/')); + + const mainSourceChanged = files.some(file => file.filename.startsWith('src/')); + + const buildModuleChanged = files.some(file => file.filename.startsWith('build.psm1')); + + const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged; + + core.setOutput('toolsChanged', toolsChanged); + core.setOutput('githubChanged', githubChanged); + core.setOutput('propsChanged', propsChanged); + core.setOutput('testsChanged', testsChanged); + core.setOutput('mainSourceChanged', mainSourceChanged); + core.setOutput('buildModuleChanged', buildModuleChanged); + core.setOutput('source', source); + + - name: Capture outputs + run: | + Write-Verbose -Verbose "source: ${{ steps.filter.outputs.source }}" + Write-Verbose -Verbose "github: ${{ steps.filter.outputs.githubChanged }}" + Write-Verbose -Verbose "tools: ${{ steps.filter.outputs.toolsChanged }}" + Write-Verbose -Verbose "props: ${{ steps.filter.outputs.propsChanged }}" + Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}" + Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}" + Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}" + shell: pwsh diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 6e79e381696..b308aa0b3a0 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -56,63 +56,9 @@ jobs: with: persist-credentials: false - - name: Check if GitHubWorkflowChanges is present + - name: Change Detection id: filter - uses: actions/github-script@v7.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - // Fetch the list of files changed in the PR - let files = []; - let page = 1; - let fetchedFiles; - do { - fetchedFiles = await github.rest.pulls.listFiles({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.issue.number, - per_page: 100, - page: page++ - }); - files = files.concat(fetchedFiles.data); - } while (fetchedFiles.data.length > 0); - - const actionsChanged = files.some(file => file.filename.startsWith('.github/actions')); - const workflowsChanged = files.some(file => file.filename.startsWith('.github/workflows')); - const githubChanged = actionsChanged || workflowsChanged; - - const toolsCiPsm1Changed = files.some(file => file.filename.startsWith('tools/ci.psm1')); - const toolsBuildCommonChanged = files.some(file => file.filename.startsWith('tools/buildCommon/')); - const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged; - - const propsChanged = files.some(file => file.filename.endsWith('.props')); - - const testsChanged = files.some(file => file.filename.startsWith('test/powershell/') || file.filename.startsWith('test/tools/') || file.filename.startsWith('test/xUnit/')); - - const mainSourceChanged = files.some(file => file.filename.startsWith('src/')); - - const buildModuleChanged = files.some(file => file.filename.startsWith('build.psm1')); - - const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged; - - core.setOutput('toolsChanged', toolsChanged); - core.setOutput('githubChanged', githubChanged); - core.setOutput('propsChanged', propsChanged); - core.setOutput('testsChanged', testsChanged); - core.setOutput('mainSourceChanged', mainSourceChanged); - core.setOutput('buildModuleChanged', buildModuleChanged); - core.setOutput('source', source); - - - name: Capture outputs - run: | - Write-Verbose -Verbose "source: ${{ steps.filter.outputs.source }}" - Write-Verbose -Verbose "github: ${{ steps.filter.outputs.githubChanged }}" - Write-Verbose -Verbose "tools: ${{ steps.filter.outputs.toolsChanged }}" - Write-Verbose -Verbose "props: ${{ steps.filter.outputs.propsChanged }}" - Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}" - Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}" - Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}" - shell: pwsh + uses: "./.github/actions/infrastructure/path-filters" ci_build: name: Build PowerShell diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index fcb69332740..979f9a29ce6 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -49,23 +49,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - # For pull requests it's not necessary to checkout the code - - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 + - name: Change Detection id: filter - with: - list-files: json - filters: .github/action-filters.yml + uses: "./.github/actions/infrastructure/path-filters" - - name: Capture outputs - run: | - "source: ${{ steps.filter.outputs.source }}" - "github: ${{ steps.filter.outputs.github }}" - "tools: ${{ steps.filter.outputs.tools }}" - "props: ${{ steps.filter.outputs.props }}" - "tests: ${{ steps.filter.outputs.tests }}" - "mainSource: ${{ steps.filter.outputs.mainSource }}" - "buildModule: ${{ steps.filter.outputs.buildModule }}" - shell: pwsh ci_build: name: Build PowerShell diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index a18029bfbe0..b7c5556bb74 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -50,23 +50,9 @@ jobs: - name: checkout uses: actions/checkout@v4 - # For pull requests it's not necessary to checkout the code - - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0 + - name: Change Detection id: filter - with: - list-files: json - filters: .github/action-filters.yml - - - name: Capture outputs - run: | - "source: ${{ steps.filter.outputs.source }}" - "github: ${{ steps.filter.outputs.github }}" - "tools: ${{ steps.filter.outputs.tools }}" - "props: ${{ steps.filter.outputs.props }}" - "tests: ${{ steps.filter.outputs.tests }}" - "mainSource: ${{ steps.filter.outputs.mainSource }}" - "buildModule: ${{ steps.filter.outputs.buildModule }}" - shell: pwsh + uses: "./.github/actions/infrastructure/path-filters" ci_build: name: Build PowerShell From 749541c90c696a75e8989976d455f2ecbf869144 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 10:53:27 -0700 Subject: [PATCH 16/24] Add GITHUB_TOKEN input to path filters action for improved token handling in CI workflows --- .github/actions/infrastructure/path-filters/action.yml | 6 +++++- .github/workflows/linux-ci.yml | 2 ++ .github/workflows/macos-ci.yml | 3 ++- .github/workflows/windows-ci.yml | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/actions/infrastructure/path-filters/action.yml b/.github/actions/infrastructure/path-filters/action.yml index 9226a49ee90..58255fab55c 100644 --- a/.github/actions/infrastructure/path-filters/action.yml +++ b/.github/actions/infrastructure/path-filters/action.yml @@ -1,5 +1,9 @@ name: Path Filters description: 'Path Filters' +inputs: + GITHUB_TOKEN: + description: 'GitHub token' + required: true outputs: source: description: 'Source code changes (composite of all changes)' @@ -29,7 +33,7 @@ runs: id: filter uses: actions/github-script@v7.0.1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ inputs.GITHUB_TOKEN }} script: | // Fetch the list of files changed in the PR let files = []; diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index b308aa0b3a0..9db69784c29 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -59,6 +59,8 @@ jobs: - name: Change Detection id: filter uses: "./.github/actions/infrastructure/path-filters" + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ci_build: name: Build PowerShell diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 979f9a29ce6..7d082326610 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -52,7 +52,8 @@ jobs: - name: Change Detection id: filter uses: "./.github/actions/infrastructure/path-filters" - + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ci_build: name: Build PowerShell diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index b7c5556bb74..059381a1d0e 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -53,6 +53,8 @@ jobs: - name: Change Detection id: filter uses: "./.github/actions/infrastructure/path-filters" + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ci_build: name: Build PowerShell From c49a6da78723eab453e8ae0a4ec88abc950e1094 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 13:35:09 -0700 Subject: [PATCH 17/24] Add culture setup and capture steps to CI workflow for localization support --- .github/actions/test/nix/action.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/actions/test/nix/action.yml b/.github/actions/test/nix/action.yml index 03c44a151c7..512d1d82dfe 100644 --- a/.github/actions/test/nix/action.yml +++ b/.github/actions/test/nix/action.yml @@ -30,11 +30,11 @@ runs: continue-on-error: true run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse shell: pwsh - + - uses: actions/setup-dotnet@v4 with: global-json-file: ./global.json - + - name: Bootstrap shell: pwsh run: |- @@ -71,6 +71,30 @@ runs: run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue shell: pwsh + - name: Setup Culture + shell: pwsh + run: | + $culture = Get-Culture + Write-Verbose -Verbose "Current culture is $($culture.Name)" + if ($culture.Name -ne 'en-US') { + Write-Verbose -Verbose "Setting culture to en-US" + sudo update-locale LANG=en_US.UTF-8 + "LANG=en_US.UTF-8" >> $GITHUB_ENV + "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV + } + + - name: Capture Culture + shell: pwsh + run: | + $culture = Get-Culture + Write-Verbose -Verbose "Current culture is $($culture.Name)" + if ($culture.Name -ne 'en-US') { + Write-Verbose -Verbose "Setting culture to en-US" + sudo update-locale LANG=en_US.UTF-8 + "LANG=en_US.UTF-8" >> $GITHUB_ENV + "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV + } + - name: Test if: success() run: |- From f9fba9b519ee7de003e649f339960b73e364eb67 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 13:48:50 -0700 Subject: [PATCH 18/24] Remove culture setting logic for non-en-US locales in Nix action --- .github/actions/test/nix/action.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/actions/test/nix/action.yml b/.github/actions/test/nix/action.yml index 512d1d82dfe..069bf96ff3f 100644 --- a/.github/actions/test/nix/action.yml +++ b/.github/actions/test/nix/action.yml @@ -88,12 +88,6 @@ runs: run: | $culture = Get-Culture Write-Verbose -Verbose "Current culture is $($culture.Name)" - if ($culture.Name -ne 'en-US') { - Write-Verbose -Verbose "Setting culture to en-US" - sudo update-locale LANG=en_US.UTF-8 - "LANG=en_US.UTF-8" >> $GITHUB_ENV - "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV - } - name: Test if: success() From 45323517a8240ffca9f0f352eef02fb84c98e03c Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 16:00:03 -0700 Subject: [PATCH 19/24] Add support for Ubuntu 22.04 and 24.04 in environment detection; enhance logging for locale settings --- build.psm1 | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/build.psm1 b/build.psm1 index 0ace5e522ed..76abfb02940 100644 --- a/build.psm1 +++ b/build.psm1 @@ -179,6 +179,8 @@ function Get-EnvironmentInformation $environment += @{'IsUbuntu16' = $environment.IsUbuntu -and $LinuxInfo.VERSION_ID -match '16.04'} $environment += @{'IsUbuntu18' = $environment.IsUbuntu -and $LinuxInfo.VERSION_ID -match '18.04'} $environment += @{'IsUbuntu20' = $environment.IsUbuntu -and $LinuxInfo.VERSION_ID -match '20.04'} + $environment += @{'IsUbuntu22' = $environment.IsUbuntu -and $LinuxInfo.VERSION_ID -match '22.04'} + $environment += @{'IsUbuntu24' = $environment.IsUbuntu -and $LinuxInfo.VERSION_ID -match '24.04'} $environment += @{'IsCentOS' = $LinuxInfo.ID -match 'centos' -and $LinuxInfo.VERSION_ID -match '7'} $environment += @{'IsFedora' = $LinuxInfo.ID -match 'fedora' -and $LinuxInfo.VERSION_ID -ge 24} $environment += @{'IsOpenSUSE' = $LinuxInfo.ID -match 'opensuse'} @@ -2705,6 +2707,59 @@ function script:Write-Log #reset colors for older package to at return to default after error message on a compilation error [console]::ResetColor() } + +function script:Write-LogGroup { + param + ( + [Parameter(Position = 0, Mandatory)] + [ValidateNotNullOrEmpty()] + [string[]] $Message, + [Parameter(Mandatory)] + [string] $Title + ) + + + Write-LogGroupStart -Title $Title + + foreach ($line in $Message) { + Write-Log -Message $line + } + + Write-LogGroupEnd -Title $Title +} + +$script:logGroupColor = [System.ConsoleColor]::Cyan + +function script:Write-LogGroupStart { + param + ( + [Parameter(Mandatory)] + [string] $Title + ) + + if ($env:GITHUB_WORKFLOW) { + Write-Host "::group::${Title}" + } + else { + Write-Host -ForegroundColor $script:logGroupColor "=== BEGIN: $Title ===" + } +} + +function script:Write-LogGroupEnd { + param + ( + [Parameter(Mandatory)] + [string] $Title + ) + + if ($env:GITHUB_WORKFLOW) { + Write-Host "::endgroup::" + } + else { + Write-Host -ForegroundColor $script:logGroupColor "==== END: $Title ====" + } +} + function script:precheck([string]$command, [string]$missedMessage) { $c = Get-Command $command -ErrorAction Ignore if (-not $c) { @@ -3623,22 +3678,50 @@ function Set-PipelineNugetAuthentication { function Set-CorrectLocale { + Write-LogGroupStart -Title "Set-CorrectLocale" + if (-not $IsLinux) { + Write-LogGroupEnd -Title "Set-CorrectLocale" return } $environment = Get-EnvironmentInformation - if ($environment.IsUbuntu -and $environment.IsUbuntu20) - { + if ($environment.IsUbuntu16 -or $environment.IsUbuntu18) { + Write-Verbose -Message "Don't set locale before Ubuntu 20" -Verbose + Write-LogGroupEnd -Title "Set-CorrectLocale" + Write-Locale + return + } + + if ($environment.IsUbuntu) { + Write-Log -Message "Setting locale to en_US.UTF-8" $env:LC_ALL = 'en_US.UTF-8' $env:LANG = 'en_US.UTF-8' sudo locale-gen $env:LANG - sudo update-locale + if ($environment.IsUbuntu20) { + Write-Log -Message "Updating locale for Ubuntu 20" + sudo update-locale + } else { + Write-Log -Message "Updating locale for Ubuntu 22 and newer" + sudo update-locale LANG=$env:LANG LC_ALL=$env:LC_ALL + } + } + + Write-LogGroupEnd -Title "Set-CorrectLocale" + Write-Locale + +} + +function Write-Locale { + if (-not $IsLinux -and -not $IsMacOS) { + Write-Verbose -Message "only supported on Linux and macOS" -Verbose + return } # Output the locale to log it - locale + $localOutput = & locale + Write-LogGroup -Title "Capture Locale" -Message $localOutput } function Install-AzCopy { From baa19ef3611f3696539731628fecbb07aa10b40c Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 16:23:14 -0700 Subject: [PATCH 20/24] Enhance logging in Nix action by adding log group starts and ends for environment capture, artifacts directory, bootstrap, and extracted build ZIP steps --- .github/actions/test/nix/action.yml | 41 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/actions/test/nix/action.yml b/.github/actions/test/nix/action.yml index 069bf96ff3f..fb495cf2eb1 100644 --- a/.github/actions/test/nix/action.yml +++ b/.github/actions/test/nix/action.yml @@ -20,15 +20,25 @@ runs: steps: - name: Capture Environment if: success() || failure() - run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose' + run: |- + ./Import-Module ./build.psm1 + Write-LogGroupStart -Title 'Environment' + Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose + Write-LogGroupEnd -Title 'Environment' shell: pwsh + - name: Download Build Artifacts uses: actions/download-artifact@v4 with: path: "${{ github.workspace }}" + - name: Capture Artifacts Directory continue-on-error: true - run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse + run: |- + ./Import-Module ./build.psm1 + Write-LogGroupStart -Title 'Artifacts Directory' + Get-ChildItem "${{ github.workspace }}/build/*" -Recurse + Write-LogGroupEnd -Title 'Artifacts Directory' shell: pwsh - uses: actions/setup-dotnet@v4 @@ -38,8 +48,11 @@ runs: - name: Bootstrap shell: pwsh run: |- + ./Import-Module ./build.psm1 + Write-LogGroupStart -Title 'Bootstrap' Import-Module ./tools/ci.psm1 Invoke-CIInstall -SkipUser + Write-LogGroupEnd -Title 'Bootstrap' - name: Extract Files uses: actions/github-script@v7.0.0 @@ -68,26 +81,12 @@ runs: - name: Capture Extracted Build ZIP continue-on-error: true - run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue - shell: pwsh - - - name: Setup Culture - shell: pwsh - run: | - $culture = Get-Culture - Write-Verbose -Verbose "Current culture is $($culture.Name)" - if ($culture.Name -ne 'en-US') { - Write-Verbose -Verbose "Setting culture to en-US" - sudo update-locale LANG=en_US.UTF-8 - "LANG=en_US.UTF-8" >> $GITHUB_ENV - "LC_ALL=en_US.UTF-8" >> $GITHUB_ENV - } - - - name: Capture Culture + run: |- + ./Import-Module ./build.psm1 + Write-LogGroupStart -Title 'Extracted Build ZIP' + Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue + Write-LogGroupEnd -Title 'Extracted Build ZIP' shell: pwsh - run: | - $culture = Get-Culture - Write-Verbose -Verbose "Current culture is $($culture.Name)" - name: Test if: success() From dc2c09f3639a4dcc780a5073985c277bc8525657 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 16:24:30 -0700 Subject: [PATCH 21/24] Add support for 'github-mirror' branch in CI workflows for macOS and Windows --- .github/workflows/macos-ci.yml | 2 ++ .github/workflows/windows-ci.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 7d082326610..a285689b5da 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -7,6 +7,7 @@ on: branches: - master - release/** + - github-mirror paths: - "**" - "!.github/ISSUE_TEMPLATE/**" @@ -17,6 +18,7 @@ on: branches: - master - release/** + - github-mirror # Path filters for PRs need to go into the changes job concurrency: diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 059381a1d0e..f5e144f61df 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -5,6 +5,7 @@ on: branches: - master - release/** + - github-mirror paths: - "**" - "!.vsts-ci/misc-analysis.yml" @@ -16,6 +17,8 @@ on: branches: - master - release/** + - github-mirror + # Path filters for PRs need to go into the changes job concurrency: From 427217b63163c128d4ef72367e8d485757597426 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 16:37:17 -0700 Subject: [PATCH 22/24] Add 'contents' permission to CI workflows for macOS and Windows --- .github/workflows/macos-ci.yml | 3 +++ .github/workflows/windows-ci.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index a285689b5da..18a684de2d9 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -36,6 +36,7 @@ env: __SuppressAnsiEscapeSequences: 1 nugetMultiFeedWarnLevel: none system_debug: 'false' + jobs: changes: name: Change Detection @@ -44,6 +45,8 @@ jobs: # Required permissions permissions: pull-requests: read + contents: read + # Set job outputs to values from filter step outputs: source: ${{ steps.filter.outputs.source }} diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index f5e144f61df..3aaa19fcdf6 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -46,6 +46,8 @@ jobs: # Required permissions permissions: pull-requests: read + contents: read + # Set job outputs to values from filter step outputs: source: ${{ steps.filter.outputs.source }} From c1cbe969ac886303243fc43479070377c0714aa3 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 16:55:26 -0700 Subject: [PATCH 23/24] Refactor module import statements in Nix action to remove unnecessary path prefix --- .github/actions/test/nix/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/test/nix/action.yml b/.github/actions/test/nix/action.yml index fb495cf2eb1..cf586f894a0 100644 --- a/.github/actions/test/nix/action.yml +++ b/.github/actions/test/nix/action.yml @@ -21,7 +21,7 @@ runs: - name: Capture Environment if: success() || failure() run: |- - ./Import-Module ./build.psm1 + Import-Module ./build.psm1 Write-LogGroupStart -Title 'Environment' Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose Write-LogGroupEnd -Title 'Environment' @@ -35,7 +35,7 @@ runs: - name: Capture Artifacts Directory continue-on-error: true run: |- - ./Import-Module ./build.psm1 + Import-Module ./build.psm1 Write-LogGroupStart -Title 'Artifacts Directory' Get-ChildItem "${{ github.workspace }}/build/*" -Recurse Write-LogGroupEnd -Title 'Artifacts Directory' @@ -48,7 +48,7 @@ runs: - name: Bootstrap shell: pwsh run: |- - ./Import-Module ./build.psm1 + Import-Module ./build.psm1 Write-LogGroupStart -Title 'Bootstrap' Import-Module ./tools/ci.psm1 Invoke-CIInstall -SkipUser @@ -82,7 +82,7 @@ runs: - name: Capture Extracted Build ZIP continue-on-error: true run: |- - ./Import-Module ./build.psm1 + Import-Module ./build.psm1 Write-LogGroupStart -Title 'Extracted Build ZIP' Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue Write-LogGroupEnd -Title 'Extracted Build ZIP' From 9d938b6c63ac86e4d27812fa46c9fb19947dc41a Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 2 Apr 2025 17:55:30 -0700 Subject: [PATCH 24/24] Add validation for GITHUB_STEP_SUMMARY in process-pester-results action --- .github/actions/test/process-pester-results/action.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/actions/test/process-pester-results/action.yml b/.github/actions/test/process-pester-results/action.yml index b1f5d228699..e1072ec08ca 100644 --- a/.github/actions/test/process-pester-results/action.yml +++ b/.github/actions/test/process-pester-results/action.yml @@ -20,6 +20,11 @@ runs: steps: - name: Log Summary run: | + if (-not $env:GITHUB_STEP_SUMMARY) { + Write-Error "GITHUB_STEP_SUMMARY is not set. Ensure this workflow is running in a GitHub Actions environment." + exit 1 + } + $testCaseCount = 0 $testErrorCount = 0 $testFailureCount = 0 @@ -41,7 +46,10 @@ runs: - Total Failures: $testFailureCount - Total Disabled: $testDisabledCount - "@ >> $GITHUB_STEP_SUMMARY + "@ | Out-File -FilePath $ENV:GITHUB_STEP_SUMMARY -Append + + Write-Host "Summary written to $ENV:GITHUB_STEP_SUMMARY" + Get-Content $ENV:GITHUB_STEP_SUMMARY shell: pwsh - name: Upload testResults artifact