-
Notifications
You must be signed in to change notification settings - Fork 10
594 lines (497 loc) · 20.5 KB
/
ci.yml
File metadata and controls
594 lines (497 loc) · 20.5 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
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
env:
MODULE_NAME: Convert
CARGO_TERM_COLOR: always
jobs:
rust-analyze:
name: Rust code analysis
runs-on: ubuntu-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: 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: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
with:
toolchain: stable
cache: true
components: clippy, rustfmt
- name: Update Rust toolchain
run: rustup update stable
- name: Cache cargo binaries
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bins-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bins-
- name: Run Rust analysis
shell: pwsh
run: ./build.ps1 -Rust -Analyze -Security -CI
- 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
build-windows:
name: Build Windows targets (MSVC)
runs-on: windows-latest
needs: rust-analyze
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: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
with:
toolchain: stable
cache: true
target: |
x86_64-pc-windows-msvc
aarch64-pc-windows-msvc
- name: Update Rust toolchain
run: rustup update stable
- name: Cache cargo binaries
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bins-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bins-
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run Rust tests
shell: pwsh
run: ./build.ps1 -Rust -Test
- name: Build Windows targets
shell: pwsh
run: ./build.ps1 -Rust -Build -Targets @('x86_64-pc-windows-msvc', 'aarch64-pc-windows-msvc')
- name: Upload Windows binaries
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: rust-libs-windows
path: |
lib/target/x86_64-pc-windows-msvc/release/convert_core.dll
lib/target/aarch64-pc-windows-msvc/release/convert_core.dll
retention-days: 1
build-linux:
name: Build Linux targets
runs-on: ubuntu-latest
needs: rust-analyze
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: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
with:
toolchain: stable
cache: true
target: |
x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
armv7-unknown-linux-gnueabihf
- name: Update Rust toolchain
run: rustup update stable
- name: Cache cargo binaries
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bins-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bins-
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run Rust tests
shell: pwsh
run: ./build.ps1 -Rust -Test
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
libc6-dev-arm64-cross \
libc6-dev-armhf-cross
- name: Configure cross-compilation linkers
run: |
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
- name: Build Linux targets
shell: pwsh
run: |
./build.ps1 -Rust -Build -Targets @(
'x86_64-unknown-linux-gnu',
'aarch64-unknown-linux-gnu',
'armv7-unknown-linux-gnueabihf'
)
- name: Upload Linux binaries
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: rust-libs-linux
path: |
lib/target/x86_64-unknown-linux-gnu/release/libconvert_core.so
lib/target/aarch64-unknown-linux-gnu/release/libconvert_core.so
lib/target/armv7-unknown-linux-gnueabihf/release/libconvert_core.so
retention-days: 1
build-macos:
name: Build macOS targets
runs-on: macos-latest
needs: rust-analyze
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: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
with:
toolchain: stable
cache: true
target: |
x86_64-apple-darwin
aarch64-apple-darwin
- name: Update Rust toolchain
run: rustup update stable
- name: Cache cargo binaries
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bins-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bins-
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Run Rust tests
shell: pwsh
run: ./build.ps1 -Rust -Test
- name: Build macOS targets
shell: pwsh
run: ./build.ps1 -Rust -Build -Targets @('x86_64-apple-darwin','aarch64-apple-darwin')
- name: Upload macOS binaries
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: rust-libs-macos
path: |
lib/target/x86_64-apple-darwin/release/libconvert_core.dylib
lib/target/aarch64-apple-darwin/release/libconvert_core.dylib
retention-days: 1
assemble-artifact:
name: Assemble universal module artifact
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-macos]
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: Download Windows binaries
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: rust-libs-windows
path: lib/target/
- name: Download Linux binaries
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: rust-libs-linux
path: lib/target/
- name: Download macOS binaries
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: rust-libs-macos
path: lib/target/
- name: Copy binaries to module structure
run: |
mkdir -p src/Convert/Private/bin/{x64,arm64,arm}
cp lib/target/x86_64-pc-windows-msvc/release/convert_core.dll src/Convert/Private/bin/x64/
cp lib/target/aarch64-pc-windows-msvc/release/convert_core.dll src/Convert/Private/bin/arm64/
cp lib/target/x86_64-unknown-linux-gnu/release/libconvert_core.so src/Convert/Private/bin/x64/
cp lib/target/aarch64-unknown-linux-gnu/release/libconvert_core.so src/Convert/Private/bin/arm64/
cp lib/target/armv7-unknown-linux-gnueabihf/release/libconvert_core.so src/Convert/Private/bin/arm/
cp lib/target/x86_64-apple-darwin/release/libconvert_core.dylib src/Convert/Private/bin/x64/
cp lib/target/aarch64-apple-darwin/release/libconvert_core.dylib src/Convert/Private/bin/arm64/
- name: Verify src/Convert/Private/bin before build
run: |
echo "=== src/Convert/Private/bin Structure ==="
find src/Convert/Private/bin -type f -exec ls -lh {} \; 2>/dev/null || echo "No bin directory found"
- name: Build PowerShell module
shell: pwsh
run: ./build.ps1 -PowerShell -Build
- name: Verify artifact structure
run: |
echo "=== Artifact Structure ==="
find Artifacts -type f
echo ""
echo "=== Binary Sizes ==="
find Artifacts/bin -type f -exec ls -lh {} \;
- name: Upload universal module artifact (if built)
id: upload-new
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Convert-Module-Universal
path: Artifacts/
retention-days: 7
- name: Download previous module artifact (if not rebuilt)
if: steps.upload-new.outputs.artifact-id == ''
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11
with:
name: Convert-Module-Universal
path: Artifacts/
workflow: ci.yml
branch: ${{ github.ref_name }}
search_artifacts: true
if_no_artifact_found: warn
- name: Re-upload module artifact (if not rebuilt)
if: steps.upload-new.outputs.artifact-id == ''
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Convert-Module-Universal
path: Artifacts/
retention-days: 7
if-no-files-found: warn
test-windows-x64:
name: Test on Windows x64
runs-on: windows-latest
needs: assemble-artifact
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: Download universal artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: Convert-Module-Universal
path: Artifacts/
- name: Verify artifact structure
shell: pwsh
run: |
Write-Host "=== Module Files ===" -ForegroundColor Cyan
Get-ChildItem -Path Artifacts/ -Recurse -File -ErrorAction SilentlyContinue | Select-Object -Property FullName | Sort-Object -Property FullName
- 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 -PowerShell -Test -Artifact
- name: Run tests on PowerShell Core
shell: pwsh
run: ./build.ps1 -PowerShell -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: assemble-artifact
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: Download universal artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: Convert-Module-Universal
path: Artifacts/
- name: Verify artifact structure
shell: pwsh
run: |
Write-Host "=== Module Files ===" -ForegroundColor Cyan
Get-ChildItem -Path Artifacts/ -Recurse -File -ErrorAction SilentlyContinue | Select-Object -Property FullName | Sort-Object -Property FullName
- 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 -PowerShell -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: assemble-artifact
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: Download universal artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: Convert-Module-Universal
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 -PowerShell -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: assemble-artifact
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: Download universal artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: Convert-Module-Universal
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 -PowerShell -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: Download universal artifact
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
with:
name: Convert-Module-Universal
path: Artifacts/
- name: Get module version
id: version
shell: pwsh
run: |
$manifest = Import-PowerShellDataFile -Path Artifacts/Convert.psd1
$version = $manifest.ModuleVersion
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "Module version: $version"
- name: Create ZIP package
run: |
cd Artifacts
zip -r ../Convert-${{ steps.version.outputs.version }}-Universal.zip .
cd ..
- name: Upload release package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Convert-Release-Package
path: Convert-${{ steps.version.outputs.version }}-Universal.zip
retention-days: 90