forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
247 lines (237 loc) · 7.56 KB
/
macos-ci.yml
File metadata and controls
247 lines (237 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: macOS-CI
run-name: "${{ github.ref_name }} - ${{ github.run_number }}"
on:
push:
branches:
- master
- release/**
- github-mirror
paths:
- "**"
- "*"
- ".globalconfig"
- "!.github/ISSUE_TEMPLATE/**"
- "!.dependabot/config.yml"
- "!.pipelines/**"
- "!test/perf/**"
pull_request:
branches:
- master
- release/**
- github-mirror
- "*-feature"
# Path filters for PRs need to go into the changes job
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ contains(github.ref, 'merge')}}
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
FORCE_FEATURE: 'False'
FORCE_PACKAGE: 'False'
HOMEBREW_NO_ANALYTICS: 1
NUGET_KEY: none
POWERSHELL_TELEMETRY_OPTOUT: 1
__SuppressAnsiEscapeSequences: 1
nugetMultiFeedWarnLevel: none
system_debug: 'false'
jobs:
changes:
name: Change Detection
runs-on: ubuntu-latest
if: startsWith(github.repository_owner, 'azure') || github.repository_owner == 'PowerShell'
# Required permissions
permissions:
pull-requests: read
contents: read
# Set job outputs to values from filter step
outputs:
source: ${{ steps.filter.outputs.source }}
buildModuleChanged: ${{ steps.filter.outputs.buildModuleChanged }}
steps:
- name: checkout
uses: actions/checkout@v6
- name: Change Detection
id: filter
uses: "./.github/actions/infrastructure/path-filters"
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ci_build:
name: Build PowerShell
runs-on: macos-15-large
needs: changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- name: Build
uses: "./.github/actions/build/ci"
macos_test_unelevated_ci:
name: macos Unelevated CI
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
runs-on: macos-15-large
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- name: macOS Unelevated CI
uses: "./.github/actions/test/nix"
with:
purpose: UnelevatedPesterTests
tagSet: CI
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
macos_test_elevated_ci:
name: macOS Elevated CI
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
runs-on: macos-15-large
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- name: macOS Elevated CI
uses: "./.github/actions/test/nix"
with:
purpose: ElevatedPesterTests
tagSet: CI
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
macos_test_unelevated_others:
name: macOS Unelevated Others
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
runs-on: macos-15-large
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- name: macOS Unelevated Others
uses: "./.github/actions/test/nix"
with:
purpose: UnelevatedPesterTests
tagSet: Others
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
macos_test_elevated_others:
name: macOS Elevated Others
needs:
- ci_build
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
runs-on: macos-15-large
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- name: macOS Elevated Others
uses: "./.github/actions/test/nix"
with:
purpose: ElevatedPesterTests
tagSet: Others
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xunit_tests:
name: xUnit Tests
needs:
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
uses: ./.github/workflows/xunit-tests.yml
with:
runner_os: macos-15-large
test_results_artifact_name: testResults-xunit
PackageMac-macos_packaging:
name: macOS packaging and testing
needs:
- changes
if: ${{ needs.changes.outputs.source == 'true' || needs.changes.outputs.buildModuleChanged == 'true' }}
runs-on:
- macos-15-large
steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1000
- uses: actions/setup-dotnet@v5
with:
global-json-file: ./global.json
- name: Bootstrap packaging
if: success()
run: |-
import-module ./build.psm1
start-psbootstrap -Scenario package
shell: pwsh
- name: Build PowerShell and Create macOS package
if: success()
run: |-
import-module ./build.psm1
import-module ./tools/ci.psm1
import-module ./tools/packaging/packaging.psm1
Switch-PSNugetConfig -Source Public
Sync-PSTags -AddRemoteIfMissing
$releaseTag = Get-ReleaseTag
Start-PSBuild -Configuration Release -PSModuleRestore -ReleaseTag $releaseTag
$macOSRuntime = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'osx-arm64' } else { 'osx-x64' }
Start-PSPackage -Type osxpkg -ReleaseTag $releaseTag -MacOSRuntime $macOSRuntime -SkipReleaseChecks
shell: pwsh
- name: Install Pester
if: success()
run: |-
Import-Module ./tools/ci.psm1
Install-CIPester
shell: pwsh
- name: Test package contents
if: success()
run: |-
$env:PACKAGE_FOLDER = Get-Location
$testResultsPath = Join-Path $env:RUNNER_WORKSPACE "testResults"
if (-not (Test-Path $testResultsPath)) {
New-Item -ItemType Directory -Path $testResultsPath -Force | Out-Null
}
Import-Module Pester
$pesterConfig = New-PesterConfiguration
$pesterConfig.Run.Path = './test/packaging/macos/package-validation.tests.ps1'
$pesterConfig.Run.PassThru = $true
$pesterConfig.Output.Verbosity = 'Detailed'
$pesterConfig.TestResult.Enabled = $true
$pesterConfig.TestResult.OutputFormat = 'NUnitXml'
$pesterConfig.TestResult.OutputPath = Join-Path $testResultsPath "macOSPackage.xml"
$result = Invoke-Pester -Configuration $pesterConfig
if ($result.FailedCount -gt 0) {
throw "Package validation failed with $($result.FailedCount) failed test(s)"
}
shell: pwsh
- name: Publish and Upload Pester Test Results
if: always()
uses: "./.github/actions/test/process-pester-results"
with:
name: "macOSPackage"
testResultsFolder: "${{ runner.workspace }}/testResults"
- name: Upload package artifact
if: always()
uses: actions/upload-artifact@v6
with:
name: macos-package
path: "*.pkg"
ready_to_merge:
name: macos ready to merge
needs:
- xunit_tests
- PackageMac-macos_packaging
- macos_test_elevated_ci
- macos_test_elevated_others
- macos_test_unelevated_ci
- macos_test_unelevated_others
if: always()
uses: PowerShell/compliance/.github/workflows/ready-to-merge.yml@v1.0.0
with:
needs_context: ${{ toJson(needs) }}