Skip to content

Commit 844f014

Browse files
TravisEz13pwshBot
authored andcommitted
Cherry-pick PR PowerShell#25275 with conflicts for manual resolution
1 parent 5f38064 commit 844f014

File tree

7 files changed

+262
-86
lines changed

7 files changed

+262
-86
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Path Filters
2+
description: 'Path Filters'
3+
inputs:
4+
GITHUB_TOKEN:
5+
description: 'GitHub token'
6+
required: true
7+
outputs:
8+
source:
9+
description: 'Source code changes (composite of all changes)'
10+
value: ${{ steps.filter.outputs.source }}
11+
githubChanged:
12+
description: 'GitHub workflow changes'
13+
value: ${{ steps.filter.outputs.githubChanged }}
14+
toolsChanged:
15+
description: 'Tools changes'
16+
value: ${{ steps.filter.outputs.toolsChanged }}
17+
propsChanged:
18+
description: 'Props changes'
19+
value: ${{ steps.filter.outputs.propsChanged }}
20+
testsChanged:
21+
description: 'Tests changes'
22+
value: ${{ steps.filter.outputs.testsChanged }}
23+
mainSourceChanged:
24+
description: 'Main source code changes (any changes in src/)'
25+
value: ${{ steps.filter.outputs.mainSourceChanged }}
26+
buildModuleChanged:
27+
description: 'Build module changes'
28+
value: ${{ steps.filter.outputs.buildModuleChanged }}
29+
runs:
30+
using: composite
31+
steps:
32+
- name: Check if GitHubWorkflowChanges is present
33+
id: filter
34+
uses: actions/[email protected]
35+
with:
36+
github-token: ${{ inputs.GITHUB_TOKEN }}
37+
script: |
38+
// Fetch the list of files changed in the PR
39+
let files = [];
40+
let page = 1;
41+
let fetchedFiles;
42+
do {
43+
fetchedFiles = await github.rest.pulls.listFiles({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
pull_number: context.issue.number,
47+
per_page: 100,
48+
page: page++
49+
});
50+
files = files.concat(fetchedFiles.data);
51+
} while (fetchedFiles.data.length > 0);
52+
53+
const actionsChanged = files.some(file => file.filename.startsWith('.github/actions'));
54+
const workflowsChanged = files.some(file => file.filename.startsWith('.github/workflows'));
55+
const githubChanged = actionsChanged || workflowsChanged;
56+
57+
const toolsCiPsm1Changed = files.some(file => file.filename.startsWith('tools/ci.psm1'));
58+
const toolsBuildCommonChanged = files.some(file => file.filename.startsWith('tools/buildCommon/'));
59+
const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged;
60+
61+
const propsChanged = files.some(file => file.filename.endsWith('.props'));
62+
63+
const testsChanged = files.some(file => file.filename.startsWith('test/powershell/') || file.filename.startsWith('test/tools/') || file.filename.startsWith('test/xUnit/'));
64+
65+
const mainSourceChanged = files.some(file => file.filename.startsWith('src/'));
66+
67+
const buildModuleChanged = files.some(file => file.filename.startsWith('build.psm1'));
68+
69+
const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged;
70+
71+
core.setOutput('toolsChanged', toolsChanged);
72+
core.setOutput('githubChanged', githubChanged);
73+
core.setOutput('propsChanged', propsChanged);
74+
core.setOutput('testsChanged', testsChanged);
75+
core.setOutput('mainSourceChanged', mainSourceChanged);
76+
core.setOutput('buildModuleChanged', buildModuleChanged);
77+
core.setOutput('source', source);
78+
79+
- name: Capture outputs
80+
run: |
81+
Write-Verbose -Verbose "source: ${{ steps.filter.outputs.source }}"
82+
Write-Verbose -Verbose "github: ${{ steps.filter.outputs.githubChanged }}"
83+
Write-Verbose -Verbose "tools: ${{ steps.filter.outputs.toolsChanged }}"
84+
Write-Verbose -Verbose "props: ${{ steps.filter.outputs.propsChanged }}"
85+
Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}"
86+
Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}"
87+
Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}"
88+
shell: pwsh

.github/actions/test/nix/action.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,39 @@ runs:
2020
steps:
2121
- name: Capture Environment
2222
if: success() || failure()
23-
run: 'Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose'
23+
run: |-
24+
Import-Module ./build.psm1
25+
Write-LogGroupStart -Title 'Environment'
26+
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
27+
Write-LogGroupEnd -Title 'Environment'
2428
shell: pwsh
29+
2530
- name: Download Build Artifacts
2631
uses: actions/download-artifact@v4
2732
with:
2833
path: "${{ github.workspace }}"
34+
2935
- name: Capture Artifacts Directory
3036
continue-on-error: true
31-
run: Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
37+
run: |-
38+
Import-Module ./build.psm1
39+
Write-LogGroupStart -Title 'Artifacts Directory'
40+
Get-ChildItem "${{ github.workspace }}/build/*" -Recurse
41+
Write-LogGroupEnd -Title 'Artifacts Directory'
3242
shell: pwsh
33-
43+
3444
- uses: actions/setup-dotnet@v4
3545
with:
3646
global-json-file: ./global.json
37-
47+
3848
- name: Bootstrap
3949
shell: pwsh
4050
run: |-
51+
Import-Module ./build.psm1
52+
Write-LogGroupStart -Title 'Bootstrap'
4153
Import-Module ./tools/ci.psm1
4254
Invoke-CIInstall -SkipUser
55+
Write-LogGroupEnd -Title 'Bootstrap'
4356
4457
- name: Extract Files
4558
uses: actions/[email protected]
@@ -68,7 +81,11 @@ runs:
6881

6982
- name: Capture Extracted Build ZIP
7083
continue-on-error: true
71-
run: Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
84+
run: |-
85+
Import-Module ./build.psm1
86+
Write-LogGroupStart -Title 'Extracted Build ZIP'
87+
Get-ChildItem "${{ github.workspace }}/bins/*" -Recurse -ErrorAction SilentlyContinue
88+
Write-LogGroupEnd -Title 'Extracted Build ZIP'
7289
shell: pwsh
7390

7491
- name: Test

.github/actions/test/process-pester-results/action.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,43 @@ inputs:
1818
runs:
1919
using: composite
2020
steps:
21-
- name: Convert JUnit to CTRF
22-
run: |-
21+
- name: Log Summary
22+
run: |
23+
if (-not $env:GITHUB_STEP_SUMMARY) {
24+
Write-Error "GITHUB_STEP_SUMMARY is not set. Ensure this workflow is running in a GitHub Actions environment."
25+
exit 1
26+
}
27+
28+
$testCaseCount = 0
29+
$testErrorCount = 0
30+
$testFailureCount = 0
31+
$testDisabledCount = 0
2332
Get-ChildItem -Path "${{ inputs.testResultsFolder }}/*.xml" -Recurse | ForEach-Object {
24-
npx --yes junit-to-ctrf $_.FullName --output ./${{ inputs.ctrfFolder }}/$($_.BaseName).json --tool Pester
33+
$results = [xml] (get-content $_.FullName)
34+
$testCaseCount += $results.testsuites.tests
35+
$testErrorCount += $results.testsuites.errors
36+
$testFailureCount += $results.testsuites.failures
37+
$testDisabledCount += $results.testsuites.disabled
2538
}
26-
shell: pwsh
2739
28-
# this task only takes / as directory separators
29-
- name: Publish Test Report
30-
uses: ctrf-io/github-test-reporter@v1
31-
with:
32-
report-path: './${{ inputs.ctrfFolder }}/*.json'
33-
exit-on-fail: true
34-
summary-report: true
35-
test-report: false
36-
test-list-report: false
37-
failed-report: false
38-
fail-rate-report: false
39-
flaky-report: false
40-
flaky-rate-report: false
41-
failed-folded-report: true
42-
previous-results-report: false
43-
ai-report: true
44-
skipped-report: false
45-
suite-folded-report: false
46-
suite-list-report: false
47-
pull-request-report: false
48-
commit-report: false
49-
custom-report: false
50-
if: always()
40+
@"
41+
42+
# Summary of ${{ inputs.name }}
43+
44+
- Total Tests: $testCaseCount
45+
- Total Errors: $testErrorCount
46+
- Total Failures: $testFailureCount
47+
- Total Disabled: $testDisabledCount
48+
49+
"@ | Out-File -FilePath $ENV:GITHUB_STEP_SUMMARY -Append
50+
51+
Write-Host "Summary written to $ENV:GITHUB_STEP_SUMMARY"
52+
Get-Content $ENV:GITHUB_STEP_SUMMARY
53+
shell: pwsh
5154

5255
- name: Upload testResults artifact
5356
if: always()
5457
uses: actions/upload-artifact@v4
5558
with:
5659
name: junit-pester-${{ inputs.name }}
5760
path: ${{ runner.workspace }}/testResults
58-
59-
- name: Upload ctrf artifact
60-
if: always()
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: ctrf-pester-${{ inputs.name }}
64-
path: ${{ inputs.ctrfFolder }}

.github/workflows/linux-ci.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
branches:
1010
- master
1111
- release/**
12+
- github-mirror
1213
paths:
1314
- "**"
1415
- "!.github/ISSUE_TEMPLATE/**"
@@ -19,6 +20,7 @@ on:
1920
branches:
2021
- master
2122
- release/**
23+
- github-mirror
2224
# Path filters for PRs need to go into the changes job
2325

2426
concurrency:
@@ -43,30 +45,30 @@ jobs:
4345
# Required permissions
4446
permissions:
4547
pull-requests: read
48+
contents: read
49+
4650
# Set job outputs to values from filter step
4751
outputs:
4852
source: ${{ steps.filter.outputs.source }}
4953
steps:
5054
- name: checkout
55+
<<<<<<< HEAD
5156
uses: actions/[email protected]
5257

5358
# For pull requests it's not necessary to checkout the code
5459
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0
5560
id: filter
61+
=======
62+
uses: actions/checkout@v4
63+
>>>>>>> f60193b9d (Make GitHub Workflows work in the internal mirror (#25275))
64+
with:
65+
persist-credentials: false
66+
67+
- name: Change Detection
68+
id: filter
69+
uses: "./.github/actions/infrastructure/path-filters"
5670
with:
57-
list-files: json
58-
filters: .github/action-filters.yml
59-
60-
- name: Capture outputs
61-
run: |
62-
"source: ${{ steps.filter.outputs.source }}"
63-
"github: ${{ steps.filter.outputs.github }}"
64-
"tools: ${{ steps.filter.outputs.tools }}"
65-
"props: ${{ steps.filter.outputs.props }}"
66-
"tests: ${{ steps.filter.outputs.tests }}"
67-
"mainSource: ${{ steps.filter.outputs.mainSource }}"
68-
"buildModule: ${{ steps.filter.outputs.buildModule }}"
69-
shell: pwsh
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7072

7173
ci_build:
7274
name: Build PowerShell

.github/workflows/macos-ci.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
branches:
88
- master
99
- release/**
10+
- github-mirror
1011
paths:
1112
- "**"
1213
- "!.github/ISSUE_TEMPLATE/**"
@@ -17,6 +18,7 @@ on:
1718
branches:
1819
- master
1920
- release/**
21+
- github-mirror
2022
# Path filters for PRs need to go into the changes job
2123

2224
concurrency:
@@ -34,6 +36,7 @@ env:
3436
__SuppressAnsiEscapeSequences: 1
3537
nugetMultiFeedWarnLevel: none
3638
system_debug: 'false'
39+
3740
jobs:
3841
changes:
3942
name: Change Detection
@@ -42,30 +45,20 @@ jobs:
4245
# Required permissions
4346
permissions:
4447
pull-requests: read
48+
contents: read
49+
4550
# Set job outputs to values from filter step
4651
outputs:
4752
source: ${{ steps.filter.outputs.source }}
4853
steps:
4954
- name: checkout
5055
uses: actions/[email protected]
5156

52-
# For pull requests it's not necessary to checkout the code
53-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0
57+
- name: Change Detection
5458
id: filter
59+
uses: "./.github/actions/infrastructure/path-filters"
5560
with:
56-
list-files: json
57-
filters: .github/action-filters.yml
58-
59-
- name: Capture outputs
60-
run: |
61-
"source: ${{ steps.filter.outputs.source }}"
62-
"github: ${{ steps.filter.outputs.github }}"
63-
"tools: ${{ steps.filter.outputs.tools }}"
64-
"props: ${{ steps.filter.outputs.props }}"
65-
"tests: ${{ steps.filter.outputs.tests }}"
66-
"mainSource: ${{ steps.filter.outputs.mainSource }}"
67-
"buildModule: ${{ steps.filter.outputs.buildModule }}"
68-
shell: pwsh
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6962

7063
ci_build:
7164
name: Build PowerShell

.github/workflows/windows-ci.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- master
77
- release/**
8+
- github-mirror
89
paths:
910
- "**"
1011
- "!.vsts-ci/misc-analysis.yml"
@@ -16,6 +17,8 @@ on:
1617
branches:
1718
- master
1819
- release/**
20+
- github-mirror
21+
1922
# Path filters for PRs need to go into the changes job
2023

2124
concurrency:
@@ -43,30 +46,20 @@ jobs:
4346
# Required permissions
4447
permissions:
4548
pull-requests: read
49+
contents: read
50+
4651
# Set job outputs to values from filter step
4752
outputs:
4853
source: ${{ steps.filter.outputs.source }}
4954
steps:
5055
- name: checkout
5156
uses: actions/[email protected]
5257

53-
# For pull requests it's not necessary to checkout the code
54-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.2.0
58+
- name: Change Detection
5559
id: filter
60+
uses: "./.github/actions/infrastructure/path-filters"
5661
with:
57-
list-files: json
58-
filters: .github/action-filters.yml
59-
60-
- name: Capture outputs
61-
run: |
62-
"source: ${{ steps.filter.outputs.source }}"
63-
"github: ${{ steps.filter.outputs.github }}"
64-
"tools: ${{ steps.filter.outputs.tools }}"
65-
"props: ${{ steps.filter.outputs.props }}"
66-
"tests: ${{ steps.filter.outputs.tests }}"
67-
"mainSource: ${{ steps.filter.outputs.mainSource }}"
68-
"buildModule: ${{ steps.filter.outputs.buildModule }}"
69-
shell: pwsh
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7063

7164
ci_build:
7265
name: Build PowerShell

0 commit comments

Comments
 (0)