-
Notifications
You must be signed in to change notification settings - Fork 0
1450 lines (1248 loc) · 53.8 KB
/
build.yml
File metadata and controls
1450 lines (1248 loc) · 53.8 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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# =============================================================================
# ARO Programming Language - Multi-Platform Build Pipeline
# =============================================================================
# Builds and tests ARO on Linux, macOS, and Windows using Swift 6.2
# =============================================================================
name: Build
permissions:
contents: read
on:
push:
branches:
- main
- 'release/**'
tags:
- '*' # Accept all tag formats (v1.0.0, 0.1.0-alpha.1, etc.)
pull_request:
branches:
- main
- 'release/**'
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
env:
SWIFT_VERSION: '6.2.1'
jobs:
# ===========================================================================
# Run Tests (Gate for all builds)
# ===========================================================================
test:
name: Test
runs-on: ubuntu-latest
container:
image: swift:6.2-jammy
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Swift packages
uses: actions/cache@v5
with:
path: .build
key: linux-swift-${{ env.SWIFT_VERSION }}-test-${{ hashFiles('Package.resolved') }}
- name: Install LLVM 20 and dependencies
run: |
apt-get update -qq
apt-get install -y -qq wget gnupg software-properties-common libgit2-dev
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" > /etc/apt/sources.list.d/llvm.list
apt-get update -qq
apt-get install -y -qq llvm-20-dev libzstd-dev
cat > /usr/lib/pkgconfig/llvm.pc << 'PKGCONFIG'
prefix=/usr/lib/llvm-20
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: LLVM
Description: Low-level Virtual Machine compiler framework
Version: 20.1
Libs: -L${libdir} -lLLVM-20
Cflags: -I${includedir}
PKGCONFIG
- name: Run tests
run: swift test --parallel
# ===========================================================================
# Linux Build & Test
# ===========================================================================
linux:
needs: test
name: Linux
runs-on: ubuntu-latest
container:
image: swift:6.2-jammy
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Cache Swift packages
uses: actions/cache@v5
with:
path: .build
key: linux-swift-${{ env.SWIFT_VERSION }}-v3-${{ hashFiles('Package.resolved') }}
- name: Install LLVM 20 and dependencies
run: |
apt-get update -qq
apt-get install -y -qq wget gnupg software-properties-common libgit2-dev
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" > /etc/apt/sources.list.d/llvm.list
apt-get update -qq
apt-get install -y -qq llvm-20-dev libzstd-dev
cat > /usr/lib/pkgconfig/llvm.pc << 'PKGCONFIG'
prefix=/usr/lib/llvm-20
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: LLVM
Description: Low-level Virtual Machine compiler framework
Version: 20.1
Libs: -L${libdir} -lLLVM-20
Cflags: -I${includedir}
PKGCONFIG
- name: Build
run: swift build -c debug
- name: Run tests
run: swift test --parallel
- name: Generate version file
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > Sources/AROVersion/Version.swift << 'EOF'
// ============================================================
// Version.swift
// ARO Version Information
// ============================================================
// This file is auto-generated during build
import Foundation
public enum AROVersion {
/// Version from git tag (embedded at build time)
public static let version: String = "VERSION_PLACEHOLDER"
/// Short commit hash (embedded at build time)
public static let commit: String = "COMMIT_PLACEHOLDER"
/// Build date in ISO 8601 format (embedded at build time)
public static let buildDate: String = "BUILD_DATE_PLACEHOLDER"
/// Whether this is a release build
public static let isRelease: Bool = {
!version.contains("-dirty") && !version.hasPrefix("unknown") && !version.hasPrefix("dev")
}()
/// Full version string with commit and build date
public static var fullVersion: String {
"\(version) (\(commit)) built on \(buildDate)"
}
/// Short version string (just the version)
public static var shortVersion: String {
version
}
}
EOF
# Replace placeholders with actual values (Linux uses sed without -i '')
sed -i "s|VERSION_PLACEHOLDER|$VERSION|g" Sources/AROVersion/Version.swift
sed -i "s|COMMIT_PLACEHOLDER|$COMMIT|g" Sources/AROVersion/Version.swift
sed -i "s|BUILD_DATE_PLACEHOLDER|$BUILD_DATE|g" Sources/AROVersion/Version.swift
echo "Generated version file with:"
echo " Version: $VERSION"
echo " Commit: $COMMIT"
echo " Build Date: $BUILD_DATE"
- name: Build release
run: |
swift build -c release --static-swift-stdlib
swift build -c release --product ARORuntime
- name: Verify CLI
run: |
.build/release/aro --help
.build/release/aro check ./Examples/HelloWorldAPI
.build/release/aro check ./Examples/UserService
- name: Prepare artifact directory
run: |
mkdir -p aro-dist
cp .build/release/aro aro-dist/
cp .build/x86_64-unknown-linux-gnu/release/libARORuntime.a aro-dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aro-linux-amd64
path: aro-dist/
retention-days: 30
# ===========================================================================
# macOS Build & Test
# ===========================================================================
macos:
needs: test
name: macOS
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Swift
uses: swift-actions/setup-swift@364295d9c23900ce04d4e5cc708387921b4e50f9 # v3
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Verify Swift version
run: |
swift --version
- name: Cache Swift packages
uses: actions/cache@v5
with:
path: .build
key: macos-swift-${{ env.SWIFT_VERSION }}-v1-${{ hashFiles('Package.resolved') }}
- name: Install LLVM 20 and dependencies
run: |
brew install llvm@20 libgit2
# Detect LLVM path (ARM64 vs Intel)
if [ -d "/opt/homebrew/opt/llvm@20" ]; then
LLVM_PREFIX="/opt/homebrew/opt/llvm@20"
# Ensure the default 'llvm' symlink points to llvm@20 for Linker.swift
sudo rm -f /opt/homebrew/opt/llvm 2>/dev/null || true
sudo ln -sf /opt/homebrew/opt/llvm@20 /opt/homebrew/opt/llvm
else
LLVM_PREFIX="/usr/local/opt/llvm@20"
sudo rm -f /usr/local/opt/llvm 2>/dev/null || true
sudo ln -sf /usr/local/opt/llvm@20 /usr/local/opt/llvm
fi
echo "LLVM_PATH=$LLVM_PREFIX" >> $GITHUB_ENV
echo "$LLVM_PREFIX/bin" >> $GITHUB_PATH
# Set include paths for Swifty-LLVM C shims
echo "C_INCLUDE_PATH=$LLVM_PREFIX/include" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=$LLVM_PREFIX/include" >> $GITHUB_ENV
echo "LIBRARY_PATH=$LLVM_PREFIX/lib" >> $GITHUB_ENV
# Set runtime library path
echo "DYLD_LIBRARY_PATH=$LLVM_PREFIX/lib" >> $GITHUB_ENV
echo "DYLD_FALLBACK_LIBRARY_PATH=$LLVM_PREFIX/lib" >> $GITHUB_ENV
# Create pkg-config file for Swifty-LLVM
mkdir -p $HOME/.pkgconfig
cat > $HOME/.pkgconfig/llvm.pc << PKGCONFIG
prefix=$LLVM_PREFIX
exec_prefix=\${prefix}
libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: LLVM
Description: Low-level Virtual Machine compiler framework
Version: 20.1
Libs: -L\${libdir} -lLLVM
Cflags: -I\${includedir}
PKGCONFIG
echo "PKG_CONFIG_PATH=$HOME/.pkgconfig" >> $GITHUB_ENV
- name: Build
run: swift build -c debug
- name: Run tests
run: swift test --parallel
- name: Generate version file
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > Sources/AROVersion/Version.swift << 'EOF'
// ============================================================
// Version.swift
// ARO Version Information
// ============================================================
// This file is auto-generated during build
import Foundation
public enum AROVersion {
/// Version from git tag (embedded at build time)
public static let version: String = "VERSION_PLACEHOLDER"
/// Short commit hash (embedded at build time)
public static let commit: String = "COMMIT_PLACEHOLDER"
/// Build date in ISO 8601 format (embedded at build time)
public static let buildDate: String = "BUILD_DATE_PLACEHOLDER"
/// Whether this is a release build
public static let isRelease: Bool = {
!version.contains("-dirty") && !version.hasPrefix("unknown") && !version.hasPrefix("dev")
}()
/// Full version string with commit and build date
public static var fullVersion: String {
"\(version) (\(commit)) built on \(buildDate)"
}
/// Short version string (just the version)
public static var shortVersion: String {
version
}
}
EOF
# Replace placeholders with actual values
sed -i '' "s|VERSION_PLACEHOLDER|$VERSION|g" Sources/AROVersion/Version.swift
sed -i '' "s|COMMIT_PLACEHOLDER|$COMMIT|g" Sources/AROVersion/Version.swift
sed -i '' "s|BUILD_DATE_PLACEHOLDER|$BUILD_DATE|g" Sources/AROVersion/Version.swift
echo "Generated version file with:"
echo " Version: $VERSION"
echo " Commit: $COMMIT"
echo " Build Date: $BUILD_DATE"
- name: Build release
run: |
swift build -c release
swift build -c release --product ARORuntime
- name: Verify CLI
run: |
.build/release/aro --help
.build/release/aro check ./Examples/HelloWorldAPI
.build/release/aro check ./Examples/UserService
# ========================================================================
# Code Signing and Notarization (only for tagged releases)
# ========================================================================
- name: Import Code Signing Certificate
if: github.ref_type == 'tag'
env:
APPLE_CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
# Create temporary keychain
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
# Decode certificate
echo "$APPLE_CERTIFICATE_BASE64" | base64 --decode > certificate.p12
# Create keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# Import certificate
security import certificate.p12 \
-P "$APPLE_CERTIFICATE_PASSWORD" \
-A \
-t cert \
-f pkcs12 \
-k $KEYCHAIN_PATH
# Set keychain search list
security list-keychain -d user -s $KEYCHAIN_PATH
# Allow codesign to access keychain
security set-key-partition-list \
-S apple-tool:,apple: \
-s \
-k "$KEYCHAIN_PASSWORD" \
$KEYCHAIN_PATH
# Clean up certificate file
rm certificate.p12
- name: Sign Binary
if: github.ref_type == 'tag'
run: |
# Create entitlements that allow loading third-party libraries
# (e.g. Homebrew's llvm@20). Without this, the hardened runtime
# rejects dylibs signed by a different Team ID.
cat > /tmp/aro-entitlements.plist << 'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
PLIST
# Sign the binary with entitlements
codesign --sign "Developer ID Application" \
--timestamp \
--options runtime \
--entitlements /tmp/aro-entitlements.plist \
--verbose \
.build/release/aro
# Verify signature (codesign only - spctl requires notarization)
codesign --verify --verbose .build/release/aro
- name: Create ZIP for Notarization
if: github.ref_type == 'tag'
run: |
# Notarization requires .zip, .dmg, or .pkg
cd .build/release
zip -r aro.zip aro
cd ../..
- name: Notarize Binary
if: github.ref_type == 'tag'
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
# Submit for notarization
xcrun notarytool submit .build/release/aro.zip \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--wait
# Unzip to get the notarized binary
cd .build/release
unzip -o aro.zip
cd ../..
# Try to staple the notarization ticket
# Note: Stapling may not work for standalone executables distributed as tarballs.
# The binary is still notarized - macOS will verify online when users run it.
echo "Attempting to staple notarization ticket..."
if xcrun stapler staple .build/release/aro 2>&1; then
echo "Stapling successful!"
xcrun stapler validate .build/release/aro
else
echo "Stapling not supported for this binary format (this is normal for CLI tools)."
echo "Binary is still notarized - macOS will verify online."
fi
# Verify the binary signature is valid
codesign --verify --verbose .build/release/aro
echo "Binary is signed and notarized successfully!"
- name: Clean Up Keychain
if: always() && github.ref_type == 'tag'
run: |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
if [ -f "$KEYCHAIN_PATH" ]; then
security delete-keychain $KEYCHAIN_PATH
fi
# ========================================================================
# Upload Artifact
# ========================================================================
- name: Prepare artifact directory
run: |
mkdir -p aro-dist
cp .build/release/aro aro-dist/
cp .build/arm64-apple-macosx/release/libARORuntime.a aro-dist/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aro-macos-arm64
path: aro-dist/
retention-days: 30
# ===========================================================================
# Windows Build & Test (temporarily disabled)
# ===========================================================================
windows:
if: false
needs: test
name: Windows
permissions:
contents: read
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Swift
uses: compnerd/gha-setup-swift@c8363f1001fbb4b12d127c432f9eaadec5f56e8c # main
with:
swift-version: swift-6.2.1-release
swift-build: 6.2.1-RELEASE
- name: Build
run: swift build -c debug
- name: Run tests
run: swift test --parallel
- name: Generate version file
shell: bash
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
cat > Sources/AROVersion/Version.swift << 'EOF'
// ============================================================
// Version.swift
// ARO Version Information
// ============================================================
// This file is auto-generated during build
import Foundation
public enum AROVersion {
/// Version from git tag (embedded at build time)
public static let version: String = "VERSION_PLACEHOLDER"
/// Short commit hash (embedded at build time)
public static let commit: String = "COMMIT_PLACEHOLDER"
/// Build date in ISO 8601 format (embedded at build time)
public static let buildDate: String = "BUILD_DATE_PLACEHOLDER"
/// Whether this is a release build
public static let isRelease: Bool = {
!version.contains("-dirty") && !version.hasPrefix("unknown") && !version.hasPrefix("dev")
}()
/// Full version string with commit and build date
public static var fullVersion: String {
"\(version) (\(commit)) built on \(buildDate)"
}
/// Short version string (just the version)
public static var shortVersion: String {
version
}
}
EOF
# Replace placeholders (Windows bash shell)
sed -i "s|VERSION_PLACEHOLDER|$VERSION|g" Sources/AROVersion/Version.swift
sed -i "s|COMMIT_PLACEHOLDER|$COMMIT|g" Sources/AROVersion/Version.swift
sed -i "s|BUILD_DATE_PLACEHOLDER|$BUILD_DATE|g" Sources/AROVersion/Version.swift
echo "Generated version file with:"
echo " Version: $VERSION"
echo " Commit: $COMMIT"
echo " Build Date: $BUILD_DATE"
- name: Build release
run: |
swift build -c release
swift build -c release --product ARORuntime
- name: Verify CLI
run: |
.build\release\aro.exe --help
- name: Find runtime library
shell: bash
run: |
echo "Looking for runtime library..."
echo "=== Searching for ARORuntime library files ==="
find .build -name "*ARORuntime*.a" -o -name "*ARORuntime*.lib" 2>/dev/null || true
echo "=== Searching for all .a and .lib files ==="
find .build \( -name "*.a" -o -name "*.lib" \) -type f 2>/dev/null | head -30 || true
echo "=== Contents of .build/release/ ==="
ls -la .build/release/ 2>/dev/null || true
echo "=== Contents of .build/x86_64-unknown-windows-msvc/release/ ==="
ls -la .build/x86_64-unknown-windows-msvc/release/ 2>/dev/null || true
- name: Prepare artifact directory
shell: bash
run: |
mkdir -p aro-dist
cp .build/release/aro.exe aro-dist/
# Search for runtime library in multiple locations
# Swift on Windows may place it in different locations
# Library names on Windows: libARORuntime.a (Swift default) or ARORuntime.lib (MSVC style)
RUNTIME_FOUND=0
# Standard locations with explicit library names
for path in \
".build/release/libARORuntime.a" \
".build/x86_64-unknown-windows-msvc/release/libARORuntime.a" \
".build/release/ARORuntime.lib" \
".build/x86_64-unknown-windows-msvc/release/ARORuntime.lib" \
".build/release/ARORuntime.a" \
".build/x86_64-unknown-windows-msvc/release/ARORuntime.a"; do
if [ -f "$path" ]; then
echo "Found runtime library at: $path"
cp "$path" aro-dist/libARORuntime.a
RUNTIME_FOUND=1
break
fi
done
# If not found in standard locations, search for library files only
# Be specific: only .a or .lib files with ARORuntime in the name
if [ "$RUNTIME_FOUND" = "0" ]; then
echo "Searching for runtime library..."
# Search for .a files first (more common for Swift)
FOUND_LIB=$(find .build -name "*ARORuntime*.a" -type f 2>/dev/null | head -1)
if [ -z "$FOUND_LIB" ]; then
# Try .lib files (MSVC style)
FOUND_LIB=$(find .build -name "*ARORuntime*.lib" -type f 2>/dev/null | head -1)
fi
if [ -n "$FOUND_LIB" ]; then
echo "Found runtime library at: $FOUND_LIB"
# Verify it looks like a valid library (has some minimum size)
LIB_SIZE=$(stat -c%s "$FOUND_LIB" 2>/dev/null || stat -f%z "$FOUND_LIB" 2>/dev/null || echo "0")
echo "Library size: $LIB_SIZE bytes"
if [ "$LIB_SIZE" -gt 1000 ]; then
cp "$FOUND_LIB" aro-dist/libARORuntime.a
RUNTIME_FOUND=1
else
echo "WARNING: Found file is too small to be a valid library"
fi
fi
fi
if [ "$RUNTIME_FOUND" = "0" ]; then
echo "ERROR: Runtime library not found!"
echo "Native compilation tests will fail without libARORuntime.a"
echo ""
echo "=== All .a and .lib files in .build ==="
find .build \( -name "*.a" -o -name "*.lib" \) -type f 2>/dev/null || true
exit 1
fi
echo "=== Artifact contents ==="
ls -la aro-dist/
# Verify the library file
echo "=== Library file info ==="
file aro-dist/libARORuntime.a 2>/dev/null || true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: aro-windows-amd64
path: aro-dist/
retention-days: 30
# ===========================================================================
# Integration Tests - Linux
# ===========================================================================
integration-tests-linux:
needs: [linux]
name: Integration Tests - Linux
runs-on: ubuntu-latest
container:
image: swift:6.2-jammy
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install LLVM 20 and dependencies
run: |
# Running inside container as root (no sudo needed)
apt-get update -qq
apt-get install -y -qq wget gnupg software-properties-common libgit2-dev
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" > /etc/apt/sources.list.d/llvm.list
apt-get update -qq
apt-get install -y -qq llvm-20-dev libzstd-dev libxml2-dev
ln -sf /usr/bin/llc-20 /usr/bin/llc
# Create pkg-config file for LLVM
mkdir -p /usr/lib/pkgconfig
cat > /usr/lib/pkgconfig/llvm.pc << 'PKGCONFIG'
prefix=/usr/lib/llvm-20
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: LLVM
Description: Low-level Virtual Machine compiler framework
Version: 20.1
Libs: -L${libdir} -lLLVM-20
Cflags: -I${includedir}
PKGCONFIG
- name: Install dependencies and Perl modules
run: |
export DEBIAN_FRONTEND=noninteractive
# Install runtime libraries for plugin tests (SQLiteExample, ZipService)
# and Perl modules from apt (faster and more reliable)
apt-get install -y -qq \
libsqlite3-dev \
zlib1g-dev \
git \
libipc-run-perl \
libyaml-libyaml-perl \
libhttp-tiny-perl \
cpanminus || true
# Install remaining modules via cpan
cpanm -q --notest Net::EmptyPort Term::ANSIColor 2>/dev/null || true
- name: Download ARO artifact
uses: actions/download-artifact@v4
with:
name: aro-linux-amd64
path: ./aro-bin
- name: Prepare ARO binary
run: |
chmod +x ./aro-bin/aro
echo "ARO_BIN=$GITHUB_WORKSPACE/aro-bin/aro" >> $GITHUB_ENV
# Copy libARORuntime.a to system location for native compilation tests
mkdir -p /usr/local/lib
cp ./aro-bin/libARORuntime.a /usr/local/lib/libARORuntime.a
./aro-bin/aro --version
# Verify Swift version
echo "Swift binary: $(which swift)"
swift --version
- name: Install Rust for plugin compilation
run: |
apt-get install -y -qq curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
export PATH="$HOME/.cargo/bin:$PATH"
# Create symlink so ARO runtime can find cargo at known paths
ln -sf "$HOME/.cargo/bin/cargo" /usr/local/bin/cargo
ln -sf "$HOME/.cargo/bin/rustc" /usr/local/bin/rustc
rustc --version
cargo --version
- name: Clean plugin build directories
run: |
# Remove any cached plugin builds from previous runs with different Swift versions
find Examples -name ".build" -type d -exec rm -rf {} + 2>/dev/null || true
echo "Plugin build directories cleaned"
- name: Run integration tests
run: |
export PATH="$HOME/.cargo/bin:$PATH"
chmod +x test-examples.pl
perl test-examples.pl --verbose
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-failures-Linux
path: |
Examples/**/expected.*
Examples/**/testrun.*
retention-days: 7
# ===========================================================================
# REPL Integration Tests - Linux
# ===========================================================================
integration-tests-repl:
needs: [linux]
name: REPL Tests - Linux
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update -qq
export DEBIAN_FRONTEND=noninteractive
apt-get install -y -qq wget gnupg software-properties-common perl libgit2-dev libcurl4
# Add LLVM APT repository for LLVM 20 (required for aro binary which links against libLLVM-20)
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" > /etc/apt/sources.list.d/llvm.list
apt-get update -qq
apt-get install -y -qq libllvm20
# Install Perl modules for REPL tests
apt-get install -y -qq cpanminus
cpanm -q --notest Term::ANSIColor 2>/dev/null || true
- name: Download ARO artifact
uses: actions/download-artifact@v4
with:
name: aro-linux-amd64
path: ./aro-bin
- name: Prepare ARO binary
run: |
chmod +x ./aro-bin/aro
echo "ARO_BIN=$GITHUB_WORKSPACE/aro-bin/aro" >> $GITHUB_ENV
./aro-bin/aro --version
- name: Run REPL tests
run: |
export LD_LIBRARY_PATH="/usr/lib/llvm-20/lib:$LD_LIBRARY_PATH"
chmod +x test_repl.pl
perl test_repl.pl
# ===========================================================================
# REPL Integration Tests - macOS
# ===========================================================================
integration-tests-repl-macos:
needs: [macos]
name: REPL Tests - macOS
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@364295d9c23900ce04d4e5cc708387921b4e50f9 # v3
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Install LLVM 20 and dependencies
run: |
brew install llvm@20 libgit2
if [ -d "/opt/homebrew/opt/llvm@20" ]; then
LLVM_PREFIX="/opt/homebrew/opt/llvm@20"
else
LLVM_PREFIX="/usr/local/opt/llvm@20"
fi
echo "DYLD_LIBRARY_PATH=$LLVM_PREFIX/lib" >> $GITHUB_ENV
- name: Download ARO artifact
uses: actions/download-artifact@v4
with:
name: aro-macos-arm64
path: ./aro-bin
- name: Prepare ARO binary
run: |
chmod +x ./aro-bin/aro
echo "ARO_BIN=$GITHUB_WORKSPACE/aro-bin/aro" >> $GITHUB_ENV
./aro-bin/aro --version
- name: Run REPL tests
run: |
chmod +x test_repl.pl
perl test_repl.pl
# ===========================================================================
# Integration Tests - macOS
# ===========================================================================
integration-tests-macos:
needs: [macos]
name: Integration Tests - macOS
runs-on: macos-15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Swift
uses: swift-actions/setup-swift@364295d9c23900ce04d4e5cc708387921b4e50f9 # v3
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Verify Swift version and set library path
run: |
swift --version
# Get the runtime library path from swift itself
# The runtimeLibraryPaths array contains the actual path to Swift libraries
SWIFT_LIB=$(swift -print-target-info 2>/dev/null | python3 -c "
import sys, json
info = json.load(sys.stdin)
paths = info.get('paths', {}).get('runtimeLibraryPaths', [])
# Use the first path that exists and contains the toolchain
for p in paths:
if 'xctoolchain' in p or 'swift' in p.lower():
print(p)
break
")
echo "Swift lib path from target-info: $SWIFT_LIB"
if [ -n "$SWIFT_LIB" ] && [ -d "$SWIFT_LIB" ]; then
echo "SWIFT_LIB_PATH=$SWIFT_LIB" >> $GITHUB_ENV
echo "Found Swift lib path: $SWIFT_LIB"
ls -la "$SWIFT_LIB" | head -5
else
echo "ERROR: Could not find Swift library path!"
echo "Target info output:"
swift -print-target-info
exit 1
fi
# Set SWIFTC for plugin compilation to use the same Swift version
# This ensures plugins are compiled with the same ABI as the runtime
SWIFTC_PATH=$(which swiftc)
echo "SWIFTC=$SWIFTC_PATH" >> $GITHUB_ENV
echo "Swift compiler for plugins: $SWIFTC_PATH"
- name: Install LLVM 20 and dependencies
run: |
brew install llvm@20 libgit2
# Detect LLVM path (ARM64 vs Intel)
if [ -d "/opt/homebrew/opt/llvm@20" ]; then
LLVM_PREFIX="/opt/homebrew/opt/llvm@20"
# Ensure the default 'llvm' symlink points to llvm@20 for Linker.swift
sudo rm -f /opt/homebrew/opt/llvm 2>/dev/null || true
sudo ln -sf /opt/homebrew/opt/llvm@20 /opt/homebrew/opt/llvm
else
LLVM_PREFIX="/usr/local/opt/llvm@20"
sudo rm -f /usr/local/opt/llvm 2>/dev/null || true
sudo ln -sf /usr/local/opt/llvm@20 /usr/local/opt/llvm
fi
echo "LLVM_PATH=$LLVM_PREFIX" >> $GITHUB_ENV
echo "$LLVM_PREFIX/bin" >> $GITHUB_PATH
# Set runtime library path for LLVM and Swift (SWIFT_LIB_PATH set in previous step)
# This ensures plugins loaded at runtime use the correct Swift runtime
echo "DYLD_LIBRARY_PATH=$SWIFT_LIB_PATH:$LLVM_PREFIX/lib" >> $GITHUB_ENV
echo "DYLD_FALLBACK_LIBRARY_PATH=$SWIFT_LIB_PATH:$LLVM_PREFIX/lib" >> $GITHUB_ENV
- name: Install Perl modules
run: |
cpan -T IPC::Run YAML::XS HTTP::Tiny Net::EmptyPort Term::ANSIColor Time::HiRes 2>&1 || true
- name: Install Rust for plugin compilation
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
source "$HOME/.cargo/env"
rustc --version
cargo --version
- name: Verify LLVM setup
run: |
echo "=== Checking LLVM symlink ==="
ls -la /opt/homebrew/opt/llvm || echo "No /opt/homebrew/opt/llvm"
ls -la /opt/homebrew/opt/llvm/bin/llc || echo "No llc at symlink path"
echo "=== Checking llc in PATH ==="
which llc || echo "llc not in PATH"
llc --version | head -3 || echo "llc --version failed"
echo "=== Checking LLVM_PATH ==="
echo "LLVM_PATH=$LLVM_PATH"
echo "=== Environment ==="
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH"
- name: Download ARO artifact
uses: actions/download-artifact@v4
with:
name: aro-macos-arm64
path: ./aro-bin
- name: Prepare ARO binary
run: |
chmod +x ./aro-bin/aro
echo "ARO_BIN=$GITHUB_WORKSPACE/aro-bin/aro" >> $GITHUB_ENV
# Copy libARORuntime.a to system location for native compilation tests
sudo mkdir -p /usr/local/lib
sudo cp ./aro-bin/libARORuntime.a /usr/local/lib/libARORuntime.a
./aro-bin/aro --version
- name: Test binary compilation
run: |
echo "=== Swift version ==="
swift --version
echo "=== Swift library path ==="
echo "SWIFT_LIB_PATH=$SWIFT_LIB_PATH"
if [ -n "$SWIFT_LIB_PATH" ]; then
ls -la "$SWIFT_LIB_PATH" | head -20
fi
echo "=== Git version and config ==="
git --version
git config --list 2>/dev/null || true
echo "=== Testing aro build ==="
./aro-bin/aro build Examples/HelloWorld --verbose 2>&1 || echo "Build failed with exit code $?"
echo "=== Checking for binary ==="
ls -la Examples/HelloWorld/HelloWorld 2>/dev/null || echo "Binary not found"
ls -la Examples/HelloWorld/.build/ 2>/dev/null || echo "No .build directory"
- name: Run integration tests
run: |
chmod +x test-examples.pl
# Run tests with timeout to prevent hanging
perl test-examples.pl --verbose 2>&1 || {
echo "=== Integration tests failed ==="
echo "=== Checking testrun.log files for errors ==="
find Examples -name "testrun.log" -exec echo "--- {} ---" \; -exec cat {} \; 2>/dev/null | head -500
exit 1
}
- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-failures-macOS
path: |
Examples/**/expected.*
Examples/**/testrun.*
retention-days: 7
# ===========================================================================
# Integration Tests - Windows (temporarily disabled)