-
Notifications
You must be signed in to change notification settings - Fork 0
715 lines (640 loc) · 23.4 KB
/
ci.yml
File metadata and controls
715 lines (640 loc) · 23.4 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
# Run nightly at 2 AM UTC
- cron: '0 2 * * *'
env:
# Use the latest stable Zig version
ZIG_VERSION: 0.15.1
jobs:
lint:
name: Lint and Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
# Windows)
# # Install basic dependencies
# choco install cmake openssl
# # Install Boost via vcpkg for better CMake integration
# vcpkg install boost-system boost-filesystem boost-program-options --triplet x64-windows
# echo "✅ Windows dependencies installed"
# ;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build MLIR libraries if needed
shell: bash
run: |
# Check if MLIR is already built (any .a file in vendor/mlir/lib indicates it's built)
if [ -d "vendor/mlir/lib" ] && [ "$(ls -A vendor/mlir/lib/*.a 2>/dev/null | wc -l)" -gt 0 ]; then
echo "✅ MLIR libraries already built and cached"
else
echo "🔨 Building MLIR libraries (this takes ~20 minutes, only on first run)..."
echo "Building via zig build (which triggers CMake for MLIR)..."
# The zig build process will automatically build MLIR if needed
zig build 2>&1 | head -100 || {
echo "⚠️ Initial build triggered MLIR compilation"
}
echo "✅ MLIR libraries built"
fi
- name: Check formatting
run: |
echo "🔍 Checking code formatting..."
zig fmt --check src/ || {
echo "❌ Code formatting issues found. Run 'zig fmt src/' to fix."
exit 1
}
echo "✅ Code formatting is correct"
- name: Lint code
run: |
echo "🔍 Running linter..."
find src/ -name "*.zig" -exec zig ast-check {} \; || {
echo "❌ Linting issues found"
exit 1
}
echo "✅ All files pass linting"
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest] # windows-latest commented out until Boost issues resolved
zig-version: [0.15.1]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ matrix.zig-version }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
# Windows)
# # Install basic dependencies
# choco install cmake openssl
# # Install Boost via vcpkg for better CMake integration
# vcpkg install boost-system boost-filesystem boost-program-options --triplet x64-windows
# echo "✅ Windows dependencies installed"
# ;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ matrix.zig-version }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-${{ matrix.zig-version }}-
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build MLIR libraries if needed
shell: bash
run: |
# Check if MLIR is already built (any .a file in vendor/mlir/lib indicates it's built)
if [ -d "vendor/mlir/lib" ] && [ "$(ls -A vendor/mlir/lib/*.a 2>/dev/null | wc -l)" -gt 0 ]; then
echo "✅ MLIR libraries already built and cached"
else
echo "🔨 Building MLIR libraries (this takes ~20 minutes, only on first run)..."
echo "Building via zig build (which triggers CMake for MLIR)..."
# The zig build process will automatically build MLIR if needed
zig build 2>&1 | head -100 || {
echo "⚠️ Initial build triggered MLIR compilation"
}
echo "✅ MLIR libraries built"
fi
- name: Build project
shell: bash
run: |
echo "🔨 Building Ora compiler..."
zig build
echo "✅ Build successful"
- name: Run unit tests
shell: bash
run: |
echo "🧪 Running unit test suite..."
zig build test
echo "✅ Unit tests completed"
examples:
name: Build Examples
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
Windows)
choco install boost-msvc-14.3 cmake openssl
echo "✅ Windows dependencies installed"
;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build compiler (includes MLIR build if needed)
shell: bash
run: |
echo "🔨 Building Ora compiler..."
zig build
echo "✅ Build successful"
- name: Compile ora-examples
shell: bash
run: |
echo "🧪 Testing example compilation..."
if [ -d "ora-example" ]; then
for file in ora-example/**/*.ora; do
if [ -f "$file" ]; then
echo "Compiling $file..."
./zig-out/bin/ora compile "$file" || echo "⚠️ Failed to compile $file"
fi
done
else
echo "⚠️ ora-example directory not found, skipping"
fi
echo "✅ Example compilation test completed"
comprehensive-tests:
name: Comprehensive Feature Tests
runs-on: ${{ matrix.os }}
needs: [lint, test]
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # windows-latest commented out until Boost issues resolved
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
# Windows)
# # Install basic dependencies
# choco install cmake openssl
# # Install Boost via vcpkg for better CMake integration
# vcpkg install boost-system boost-filesystem boost-program-options --triplet x64-windows
# echo "✅ Windows dependencies installed"
# ;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build compiler (includes MLIR)
shell: bash
run: |
echo "🔨 Building Ora compiler..."
zig build
echo "✅ Build successful"
- name: Run end-to-end compilation tests
shell: bash
run: |
echo "🏗️ Running end-to-end compilation tests..."
# Test compilation of sample files
if [ -d "ora-example" ]; then
./zig-out/bin/ora compile ora-example/smoke.ora || echo "⚠️ smoke.ora failed"
./zig-out/bin/ora compile ora-example/basic_storage.ora || echo "⚠️ basic_storage.ora failed"
fi
echo "✅ End-to-end tests completed"
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: struct-test-results-${{ matrix.os }}
path: test-results/
retention-days: 30
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: ora-compiler-${{ runner.os }}
path: |
zig-out/bin/
zig-out/lib/
retention-days: 7
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Run security scan
shell: bash
run: |
echo "🔍 Running basic security scan..."
# Basic security checks - more comprehensive scans in security.yml
- name: Check for security issues
shell: bash
run: |
echo "🔒 Running security checks..."
# Check for common security patterns
echo "🔍 Checking for unsafe patterns..."
if grep -r "unsafe" src/ 2>/dev/null; then
echo "⚠️ Found unsafe code patterns"
else
echo "✅ No unsafe patterns found"
fi
# Check for TODO/FIXME security notes
echo "🔍 Checking for security TODOs..."
if grep -r -i "todo.*security\|fixme.*security" src/ 2>/dev/null; then
echo "⚠️ Found security-related TODOs"
else
echo "✅ No security TODOs found"
fi
echo "✅ Security scan completed"
performance:
name: Performance Benchmarks
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || contains(github.event.pull_request.labels.*.name, 'performance')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
Windows)
choco install boost-msvc-14.3 cmake openssl
echo "✅ Windows dependencies installed"
;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build with optimizations
shell: bash
run: |
echo "🚀 Building optimized version..."
zig build -Doptimize=ReleaseFast
- name: Run performance tests
shell: bash
run: |
echo "⚡ Running performance benchmarks..."
# Time compilation of test files
if [ -f "zig-out/bin/ora" ]; then
echo "📊 Timing compilation performance..."
time ./zig-out/bin/ora --version 2>/dev/null || echo "⚠️ Compiler version check failed"
fi
# Memory usage tests
echo "💾 Checking memory usage..."
/usr/bin/time -v zig build 2>&1 | grep -E "(Maximum resident set size|User time|System time)" || echo "⚠️ Memory profiling failed"
echo "✅ Performance benchmarks completed"
release:
name: Release Check
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [lint, test, examples, comprehensive-tests, security]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true # Only fetch configured submodules (vendor/solidity)
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
shell: bash
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
clang \
libc++-dev \
libc++abi-dev \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
Windows)
choco install boost-msvc-14.3 cmake openssl
echo "✅ Windows dependencies installed"
;;
esac
- name: Clone LLVM/MLIR for build
shell: bash
run: |
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
if [ ! -d "vendor/llvm-project" ]; then
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
echo "✅ LLVM/MLIR cloned"
else
echo "✅ LLVM/MLIR already present"
fi
- name: Cache MLIR build
uses: actions/cache@v4
with:
path: vendor/mlir/
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
restore-keys: |
${{ runner.os }}-mlir-build-
- name: Build release version
shell: bash
run: |
echo "🎯 Building release version..."
zig build -Doptimize=ReleaseFast -Dtarget=x86_64-linux
# macOS Intel build removed; keep Linux and other targets as needed
zig build -Doptimize=ReleaseFast -Dtarget=x86_64-windows
echo "✅ Release builds completed"
- name: Create release summary
shell: bash
run: |
echo "📋 Release Summary:" > release-summary.md
echo "- Commit: ${{ github.sha }}" >> release-summary.md
echo "- Date: $(date)" >> release-summary.md
echo "- Tests: ✅ Passed" >> release-summary.md
echo "- Examples: ✅ Built" >> release-summary.md
echo "- Security: ✅ Scanned" >> release-summary.md
echo "📋 Release summary created"
cat release-summary.md
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: ora-release-${{ github.sha }}
path: |
zig-out/
release-summary.md
retention-days: 30
notification:
name: Notification
runs-on: ubuntu-latest
if: always()
needs: [lint, test, examples, comprehensive-tests, security]
steps:
- name: Notify on success
if: needs.lint.result == 'success' && needs.test.result == 'success' && needs.examples.result == 'success' && needs.comprehensive-tests.result == 'success'
run: |
echo "✅ 🎉 All CI checks passed successfully!"
echo "📊 Results:"
echo " - Lint: ✅"
echo " - Test: ✅"
echo " - Examples: ✅"
echo " - Security: ✅"
- name: Notify on failure
if: needs.lint.result == 'failure' || needs.test.result == 'failure' || needs.examples.result == 'failure'
run: |
echo "❌ Some CI checks failed"
echo "📊 Results:"
echo " - Lint: ${{ needs.lint.result }}"
echo " - Test: ${{ needs.test.result }}"
echo " - Examples: ${{ needs.examples.result }}"
echo " - Security: ${{ needs.security.result }}"