Skip to content

Commit be24c3c

Browse files
committed
add setup and CI fix
1 parent d76644f commit be24c3c

File tree

4 files changed

+373
-66
lines changed

4 files changed

+373
-66
lines changed

.github/workflows/ci.yml

Lines changed: 191 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
# Use the latest stable Zig version
14-
ZIG_VERSION: 0.14.1
14+
ZIG_VERSION: 0.15.1
1515

1616
jobs:
1717
lint:
@@ -21,7 +21,7 @@ jobs:
2121
- name: Checkout code
2222
uses: actions/checkout@v4
2323
with:
24-
submodules: recursive
24+
submodules: true # Only fetch configured submodules (vendor/solidity)
2525

2626
- name: Setup Zig
2727
uses: goto-bus-stop/setup-zig@v2
@@ -71,6 +71,41 @@ jobs:
7171
restore-keys: |
7272
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
7373
74+
- name: Clone LLVM/MLIR for build
75+
shell: bash
76+
run: |
77+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
78+
if [ ! -d "vendor/llvm-project" ]; then
79+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
80+
echo "✅ LLVM/MLIR cloned"
81+
else
82+
echo "✅ LLVM/MLIR already present"
83+
fi
84+
85+
- name: Cache MLIR build
86+
uses: actions/cache@v4
87+
with:
88+
path: vendor/mlir/
89+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
90+
restore-keys: |
91+
${{ runner.os }}-mlir-build-
92+
93+
- name: Build MLIR libraries if needed
94+
shell: bash
95+
run: |
96+
# Check if MLIR is already built (any .a file in vendor/mlir/lib indicates it's built)
97+
if [ -d "vendor/mlir/lib" ] && [ "$(ls -A vendor/mlir/lib/*.a 2>/dev/null | wc -l)" -gt 0 ]; then
98+
echo "✅ MLIR libraries already built and cached"
99+
else
100+
echo "🔨 Building MLIR libraries (this takes ~20 minutes, only on first run)..."
101+
echo "Building via zig build (which triggers CMake for MLIR)..."
102+
# The zig build process will automatically build MLIR if needed
103+
zig build 2>&1 | head -100 || {
104+
echo "⚠️ Initial build triggered MLIR compilation"
105+
}
106+
echo "✅ MLIR libraries built"
107+
fi
108+
74109
- name: Check formatting
75110
run: |
76111
echo "🔍 Checking code formatting..."
@@ -96,13 +131,13 @@ jobs:
96131
fail-fast: false
97132
matrix:
98133
os: [ubuntu-latest, macos-latest] # windows-latest commented out until Boost issues resolved
99-
zig-version: [0.14.1]
134+
zig-version: [0.15.1]
100135

101136
steps:
102137
- name: Checkout code
103138
uses: actions/checkout@v4
104139
with:
105-
submodules: recursive
140+
submodules: true # Only fetch configured submodules (vendor/solidity)
106141

107142
- name: Setup Zig
108143
uses: goto-bus-stop/setup-zig@v2
@@ -153,68 +188,54 @@ jobs:
153188
restore-keys: |
154189
${{ runner.os }}-zig-${{ matrix.zig-version }}-
155190
156-
- name: Build project
157-
shell: bash
158-
run: |
159-
echo "🔨 Building Ora compiler..."
160-
zig build
161-
echo "✅ Build successful"
162-
163-
- name: Run comprehensive tests
164-
shell: bash
165-
run: |
166-
echo "🧪 Running comprehensive test suite..."
167-
zig build test || echo "⚠️ Some tests failed"
168-
echo "✅ Comprehensive test suite completed"
169-
170-
- name: Run AST tests
191+
- name: Clone LLVM/MLIR for build
171192
shell: bash
172193
run: |
173-
echo "🧪 Running AST visitor tests..."
174-
zig build test-ast || echo "⚠️ AST tests failed"
175-
echo "✅ AST tests completed"
176-
177-
- name: Run lexer tests
178-
shell: bash
179-
run: |
180-
echo "🧪 Running lexer tests..."
181-
zig build test-lexer || echo "⚠️ Lexer tests failed"
182-
echo "✅ Lexer tests completed"
183-
184-
- name: Run expression parser tests
185-
shell: bash
186-
run: |
187-
echo "🧪 Running expression parser tests..."
188-
zig build test-expression-parser || echo "⚠️ Expression parser tests failed"
189-
echo "✅ Expression parser tests completed"
194+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
195+
if [ ! -d "vendor/llvm-project" ]; then
196+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
197+
echo "✅ LLVM/MLIR cloned"
198+
else
199+
echo "✅ LLVM/MLIR already present"
200+
fi
190201
191-
- name: Run test framework tests
192-
shell: bash
193-
run: |
194-
echo "🧪 Running test framework tests..."
195-
zig build test-framework || echo "⚠️ Test framework tests failed"
196-
echo "✅ Test framework tests completed"
202+
- name: Cache MLIR build
203+
uses: actions/cache@v4
204+
with:
205+
path: vendor/mlir/
206+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
207+
restore-keys: |
208+
${{ runner.os }}-mlir-build-
197209
198-
- name: Run example tests
210+
- name: Build MLIR libraries if needed
199211
shell: bash
200212
run: |
201-
echo "🧪 Running example tests..."
202-
zig build test-examples || echo "⚠️ Example tests failed (some expected due to compiler bugs)"
203-
echo "✅ Example tests completed"
213+
# Check if MLIR is already built (any .a file in vendor/mlir/lib indicates it's built)
214+
if [ -d "vendor/mlir/lib" ] && [ "$(ls -A vendor/mlir/lib/*.a 2>/dev/null | wc -l)" -gt 0 ]; then
215+
echo "✅ MLIR libraries already built and cached"
216+
else
217+
echo "🔨 Building MLIR libraries (this takes ~20 minutes, only on first run)..."
218+
echo "Building via zig build (which triggers CMake for MLIR)..."
219+
# The zig build process will automatically build MLIR if needed
220+
zig build 2>&1 | head -100 || {
221+
echo "⚠️ Initial build triggered MLIR compilation"
222+
}
223+
echo "✅ MLIR libraries built"
224+
fi
204225
205-
- name: Test individual components
226+
- name: Build project
206227
shell: bash
207228
run: |
208-
echo "🔧 Testing individual components..."
209-
zig build-lib src/lexer.zig && echo "✅ Lexer compiles"
210-
zig build-lib src/parser.zig && echo "✅ Parser compiles"
211-
zig build-lib src/semantics.zig && echo "✅ Semantics compiles"
212-
zig build-lib src/typer.zig && echo "✅ Typer compiles"
229+
echo "🔨 Building Ora compiler..."
230+
zig build
231+
echo "✅ Build successful"
213232
214-
- name: Clean up build artifacts
233+
- name: Run unit tests
215234
shell: bash
216235
run: |
217-
rm -f lib*.a lib*.a.o
236+
echo "🧪 Running unit test suite..."
237+
zig build test
238+
echo "✅ Unit tests completed"
218239
219240
examples:
220241
name: Build Examples
@@ -225,7 +246,7 @@ jobs:
225246
- name: Checkout code
226247
uses: actions/checkout@v4
227248
with:
228-
submodules: recursive
249+
submodules: true # Only fetch configured submodules (vendor/solidity)
229250

230251
- name: Setup Zig
231252
uses: goto-bus-stop/setup-zig@v2
@@ -272,11 +293,47 @@ jobs:
272293
restore-keys: |
273294
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
274295
275-
- name: Build and test examples
296+
- name: Clone LLVM/MLIR for build
297+
shell: bash
298+
run: |
299+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
300+
if [ ! -d "vendor/llvm-project" ]; then
301+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
302+
echo "✅ LLVM/MLIR cloned"
303+
else
304+
echo "✅ LLVM/MLIR already present"
305+
fi
306+
307+
- name: Cache MLIR build
308+
uses: actions/cache@v4
309+
with:
310+
path: vendor/mlir/
311+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
312+
restore-keys: |
313+
${{ runner.os }}-mlir-build-
314+
315+
- name: Build compiler (includes MLIR build if needed)
316+
shell: bash
317+
run: |
318+
echo "🔨 Building Ora compiler..."
319+
zig build
320+
echo "✅ Build successful"
321+
322+
- name: Compile ora-examples
276323
shell: bash
277324
run: |
278-
echo "🧪 Running unified test suite..."
279-
./scripts/test-all.sh -q all
325+
echo "🧪 Testing example compilation..."
326+
if [ -d "ora-example" ]; then
327+
for file in ora-example/**/*.ora; do
328+
if [ -f "$file" ]; then
329+
echo "Compiling $file..."
330+
./zig-out/bin/ora compile "$file" || echo "⚠️ Failed to compile $file"
331+
fi
332+
done
333+
else
334+
echo "⚠️ ora-example directory not found, skipping"
335+
fi
336+
echo "✅ Example compilation test completed"
280337
281338
comprehensive-tests:
282339
name: Comprehensive Feature Tests
@@ -291,7 +348,7 @@ jobs:
291348
- name: Checkout code
292349
uses: actions/checkout@v4
293350
with:
294-
submodules: recursive
351+
submodules: true # Only fetch configured submodules (vendor/solidity)
295352

296353
- name: Setup Zig
297354
uses: goto-bus-stop/setup-zig@v2
@@ -341,11 +398,42 @@ jobs:
341398
restore-keys: |
342399
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
343400
344-
- name: Run comprehensive tests
401+
- name: Clone LLVM/MLIR for build
345402
shell: bash
346403
run: |
347-
echo "🏗️ Running comprehensive tests..."
348-
./scripts/test-all.sh struct enum core advanced
404+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
405+
if [ ! -d "vendor/llvm-project" ]; then
406+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
407+
echo "✅ LLVM/MLIR cloned"
408+
else
409+
echo "✅ LLVM/MLIR already present"
410+
fi
411+
412+
- name: Cache MLIR build
413+
uses: actions/cache@v4
414+
with:
415+
path: vendor/mlir/
416+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
417+
restore-keys: |
418+
${{ runner.os }}-mlir-build-
419+
420+
- name: Build compiler (includes MLIR)
421+
shell: bash
422+
run: |
423+
echo "🔨 Building Ora compiler..."
424+
zig build
425+
echo "✅ Build successful"
426+
427+
- name: Run end-to-end compilation tests
428+
shell: bash
429+
run: |
430+
echo "🏗️ Running end-to-end compilation tests..."
431+
# Test compilation of sample files
432+
if [ -d "ora-example" ]; then
433+
./zig-out/bin/ora compile ora-example/smoke.ora || echo "⚠️ smoke.ora failed"
434+
./zig-out/bin/ora compile ora-example/basic_storage.ora || echo "⚠️ basic_storage.ora failed"
435+
fi
436+
echo "✅ End-to-end tests completed"
349437
350438
- name: Upload test results
351439
uses: actions/upload-artifact@v4
@@ -373,7 +461,7 @@ jobs:
373461
- name: Checkout code
374462
uses: actions/checkout@v4
375463
with:
376-
submodules: recursive
464+
submodules: true # Only fetch configured submodules (vendor/solidity)
377465

378466
- name: Run security scan
379467
shell: bash
@@ -413,7 +501,7 @@ jobs:
413501
- name: Checkout code
414502
uses: actions/checkout@v4
415503
with:
416-
submodules: recursive
504+
submodules: true # Only fetch configured submodules (vendor/solidity)
417505

418506
- name: Setup Zig
419507
uses: goto-bus-stop/setup-zig@v2
@@ -460,6 +548,25 @@ jobs:
460548
restore-keys: |
461549
${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-
462550
551+
- name: Clone LLVM/MLIR for build
552+
shell: bash
553+
run: |
554+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
555+
if [ ! -d "vendor/llvm-project" ]; then
556+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
557+
echo "✅ LLVM/MLIR cloned"
558+
else
559+
echo "✅ LLVM/MLIR already present"
560+
fi
561+
562+
- name: Cache MLIR build
563+
uses: actions/cache@v4
564+
with:
565+
path: vendor/mlir/
566+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
567+
restore-keys: |
568+
${{ runner.os }}-mlir-build-
569+
463570
- name: Build with optimizations
464571
shell: bash
465572
run: |
@@ -493,7 +600,7 @@ jobs:
493600
- name: Checkout code
494601
uses: actions/checkout@v4
495602
with:
496-
submodules: recursive
603+
submodules: true # Only fetch configured submodules (vendor/solidity)
497604

498605
- name: Setup Zig
499606
uses: goto-bus-stop/setup-zig@v2
@@ -530,6 +637,25 @@ jobs:
530637
;;
531638
esac
532639
640+
- name: Clone LLVM/MLIR for build
641+
shell: bash
642+
run: |
643+
echo "📦 Cloning LLVM/MLIR (shallow clone for faster CI)..."
644+
if [ ! -d "vendor/llvm-project" ]; then
645+
git clone --depth=1 --branch=release/19.x https://github.com/llvm/llvm-project.git vendor/llvm-project
646+
echo "✅ LLVM/MLIR cloned"
647+
else
648+
echo "✅ LLVM/MLIR already present"
649+
fi
650+
651+
- name: Cache MLIR build
652+
uses: actions/cache@v4
653+
with:
654+
path: vendor/mlir/
655+
key: ${{ runner.os }}-mlir-build-${{ hashFiles('vendor/llvm-project/.git/HEAD', 'build.zig') }}
656+
restore-keys: |
657+
${{ runner.os }}-mlir-build-
658+
533659
- name: Build release version
534660
shell: bash
535661
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ vendor/mlir/lib/
1515

1616
vendor/mlir
1717
backup/
18+
vendor/llvm-project/

0 commit comments

Comments
 (0)