-
Notifications
You must be signed in to change notification settings - Fork 2
375 lines (316 loc) · 12.7 KB
/
ci.yml
File metadata and controls
375 lines (316 loc) · 12.7 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
name: CI
on:
push:
branches:
- '**'
pull_request_target:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
force:
description: 'Force full build (ignore hash)'
required: false
default: false
type: boolean
permissions:
contents: read
actions: read
checks: write
pull-requests: write
jobs:
build-and-test:
name: Build and test
runs-on: windows-latest
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request_target'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
Write-Host "Detected module: $moduleName"
- name: Download previous content hash
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc
continue-on-error: true
with:
name: content-hash
path: .build/
workflow: ci.yml
branch: ${{ github.event_name == 'pull_request_target' && github.base_ref || github.ref_name }}
if_no_artifact_found: ignore
- name: Clear hash if force build requested
if: github.event.inputs.force == 'true'
shell: pwsh
run: |
$hashFile = '.build/content-hash.txt'
if (Test-Path $hashFile) {
Remove-Item $hashFile -Force
Write-Host 'Force build requested - cleared previous hash'
}
- name: Cache PowerShell modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: |
~/Documents/PowerShell/Modules
~/Documents/WindowsPowerShell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('install_modules.ps1') }}
- name: Install NuGet provider
shell: pwsh
run: ./install_nuget.ps1
- name: Install PowerShell modules
shell: pwsh
run: ./install_modules.ps1
- name: Build and test
shell: powershell
run: ./build.ps1 -Analyze -Build -Test -Artifact -Package
- name: Upload content hash
if: success()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: content-hash
path: .build/content-hash.txt
retention-days: 90
overwrite: true
- name: Upload module artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
retention-days: 7
test-windows-x64:
name: Test on Windows x64
runs-on: windows-latest
needs: build-and-test
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request_target'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
- name: Download module artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
- name: Cache PowerShell modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: |
~/Documents/PowerShell/Modules
~/Documents/WindowsPowerShell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('install_modules.ps1') }}
- name: Install NuGet provider
shell: pwsh
run: ./install_nuget.ps1
- name: Install PowerShell modules
shell: pwsh
run: ./install_modules.ps1
- name: Run tests on Windows PowerShell 5.1
shell: powershell
run: ./build.ps1 -Test -Artifact
- name: Run tests on PowerShell Core
shell: pwsh
run: ./build.ps1 -Test -Artifact
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: test-results-windows-x64
path: test-results-windows-x64-*.xml
retention-days: 90
if-no-files-found: warn
test-linux-x64:
name: Test on Linux x64
runs-on: ubuntu-latest
needs: build-and-test
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request_target'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
- name: Download module artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
- name: Cache PowerShell modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.local/share/powershell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('install_modules.ps1') }}
- name: Install PowerShell modules
shell: pwsh
run: ./install_modules.ps1
- name: Run tests
shell: pwsh
run: ./build.ps1 -Test -Artifact
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: test-results-linux-x64
path: test-results-linux-x64.xml
retention-days: 90
if-no-files-found: warn
test-macos-x64:
name: Test on macOS x64 (Intel)
runs-on: macos-15-intel
needs: build-and-test
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request_target'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
- name: Download module artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
- name: Cache PowerShell modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.local/share/powershell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('install_modules.ps1') }}
- name: Install PowerShell modules
shell: pwsh
run: ./install_modules.ps1
- name: Run tests
shell: pwsh
run: ./build.ps1 -Test -Artifact
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: test-results-macos-x64
path: test-results-macos-x64.xml
retention-days: 90
if-no-files-found: warn
test-macos-arm64:
name: Test on macOS Apple Silicon
runs-on: macos-latest
needs: build-and-test
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request_target'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
- name: Download module artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
- name: Cache PowerShell modules
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.local/share/powershell/Modules
key: ${{ runner.os }}-psmodules-${{ hashFiles('install_modules.ps1') }}
- name: Install PowerShell modules
shell: pwsh
run: ./install_modules.ps1
- name: Run tests
shell: pwsh
run: ./build.ps1 -Test -Artifact
- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: test-results-macos-arm64
path: test-results-macos-arm64.xml
retention-days: 90
if-no-files-found: warn
publish-results:
name: Publish test results
runs-on: ubuntu-latest
needs: [test-windows-x64, test-linux-x64, test-macos-x64, test-macos-arm64]
if: always()
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Download all test results
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
pattern: test-results-*
path: test-results/
- name: Publish test results
uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226
if: always()
with:
name: Test Results (All Platforms)
path: test-results/**/*.xml
reporter: java-junit
- name: Summary
run: |
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Tests completed on all platforms:" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Windows x64 (PowerShell 5.1 + Core)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Linux x64" >> $GITHUB_STEP_SUMMARY
echo "- ✅ macOS x64 (Intel)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ macOS arm64 (Apple Silicon)" >> $GITHUB_STEP_SUMMARY
create-release-package:
name: Create release package
runs-on: ubuntu-latest
needs: [test-windows-x64, test-linux-x64, test-macos-x64, test-macos-arm64]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Get module name
id: module
shell: pwsh
run: |
$manifest = Get-ChildItem -Path src -Filter '*.psd1' -Recurse | Select-Object -First 1
$moduleName = [System.IO.Path]::GetFileNameWithoutExtension($manifest.Name)
echo "name=$moduleName" >> $env:GITHUB_OUTPUT
- name: Download module artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: ${{ steps.module.outputs.name }}-Module
path: Artifacts/
- name: Get module version
id: version
shell: pwsh
run: |
$moduleName = '${{ steps.module.outputs.name }}'
$manifest = Import-PowerShellDataFile -Path "Artifacts/$moduleName.psd1"
$version = $manifest.ModuleVersion
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "Module version: $version"
- name: Create ZIP package
run: |
cd Artifacts
zip -r ../${{ steps.module.outputs.name }}-${{ steps.version.outputs.version }}.zip .
cd ..
- name: Upload release package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ steps.module.outputs.name }}-Release-Package
path: ${{ steps.module.outputs.name }}-${{ steps.version.outputs.version }}.zip
retention-days: 90