forked from inferno-os/inferno-os
-
Notifications
You must be signed in to change notification settings - Fork 1
382 lines (327 loc) · 12.9 KB
/
ci.yml
File metadata and controls
382 lines (327 loc) · 12.9 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
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ─────────────────────────────────────────────
# Linux AMD64: Full bootstrap build from source
# ─────────────────────────────────────────────
linux-amd64:
name: Linux AMD64 Build & Test
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
env:
ROOT: ${{ github.workspace }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Stamp build version
run: |
BUILD_DATE=$(date +%Y%m%d)
SHORT_SHA=${GITHUB_SHA::8}
sed -i "s|InferNode 0.1|InferNode 0.1 build ${BUILD_DATE}-${SHORT_SHA}|" include/version.h
echo "Version: $(cat include/version.h)"
- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Bootstrap build (mk, libraries, limbo, emulator)
run: |
chmod +x build-linux-amd64.sh
./build-linux-amd64.sh
- name: Verify emulator binary
run: |
test -x emu/Linux/o.emu || { echo "Emulator not built"; exit 1; }
file emu/Linux/o.emu
test -x Linux/amd64/bin/limbo || { echo "Limbo compiler not built"; exit 1; }
- name: Compile test suite
run: |
LIMBO="$ROOT/Linux/amd64/bin/limbo"
# Build the testing module first
mkdir -p dis/tests dis/lib
# Build testing library
COMPILE_FAILURES=0
if [ -d tests/testing ]; then
cd tests/testing
for f in *.b; do
if [ -f "$f" ]; then
if ! "$LIMBO" -I "$ROOT/module" -o "$ROOT/dis/lib/${f%.b}.dis" "$f" 2>&1; then
echo "ERROR: Failed to compile testing/$f"
COMPILE_FAILURES=$((COMPILE_FAILURES + 1))
fi
fi
done
cd "$ROOT"
fi
# Build test runner and test files into tests/ where the runner expects them
cd tests
for f in *.b; do
name="${f%.b}"
echo "Compiling $f..."
if ! "$LIMBO" -I "$ROOT/module" -o "$ROOT/tests/$name.dis" "$f" 2>&1; then
echo "ERROR: Failed to compile $f"
COMPILE_FAILURES=$((COMPILE_FAILURES + 1))
fi
done
cd "$ROOT"
# Verify runner was compiled
test -f tests/runner.dis || { echo "Test runner not compiled"; exit 1; }
echo "Compiled test .dis files:"
ls tests/*_test.dis 2>/dev/null | wc -l
if [ "$COMPILE_FAILURES" -gt 0 ]; then
echo "ERROR: $COMPILE_FAILURES test file(s) failed to compile"
exit 1
fi
- name: Run test suite
run: |
# Create /tmp inside Inferno root for tmp_writable test
mkdir -p tmp
echo "Running test suite inside Inferno emulator..."
# The emulator doesn't exit cleanly after the test runner finishes
# (kernel threads keep the process alive), so we capture output and
# parse the result instead of relying on exit code.
timeout 60 ./emu/Linux/o.emu -r . /tests/runner.dis -v > test-output.txt 2>&1 || true
cat test-output.txt
# Check test results from output
if grep -q "^PASS$" test-output.txt; then
echo "Tests passed."
elif grep -q "^FAIL$" test-output.txt; then
echo "Tests failed."
exit 1
else
echo "No test result found in output — tests may not have run."
exit 1
fi
- name: Run wallet and secstore integration tests
run: |
echo "Running host-side integration tests..."
# wallet9p basic operations
if [ -f tests/host/wallet9p_test.sh ]; then
echo "--- wallet9p test ---"
chmod +x tests/host/wallet9p_test.sh
ROOT=. bash tests/host/wallet9p_test.sh > wallet9p-test.txt 2>&1 || true
cat wallet9p-test.txt
if grep -q "=== PASS ===" wallet9p-test.txt; then
echo "wallet9p test: PASS"
else
echo "wallet9p test: SKIP (requires full Inferno namespace)"
fi
fi
# wallet persistence (secstore round-trip)
if [ -f tests/host/wallet_persist_test.sh ]; then
echo "--- wallet persistence test ---"
chmod +x tests/host/wallet_persist_test.sh
ROOT=. bash tests/host/wallet_persist_test.sh > wallet-persist-test.txt 2>&1 || true
cat wallet-persist-test.txt
if grep -q "^PASS$" wallet-persist-test.txt; then
echo "wallet persistence test: PASS"
else
echo "wallet persistence test: FAIL (non-fatal in CI)"
fi
fi
- name: Upload Linux build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: success()
with:
name: infernode-linux-amd64
path: |
emu/Linux/o.emu
Linux/amd64/bin/limbo
Linux/amd64/bin/mk
retention-days: 14
# ─────────────────────────────────────────────
# macOS ARM64: Build using shipped toolchain
# ─────────────────────────────────────────────
macos-arm64:
name: macOS ARM64 Build & Test
runs-on: macos-15
timeout-minutes: 30
permissions:
contents: read
env:
ROOT: ${{ github.workspace }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Stamp build version
run: |
BUILD_DATE=$(date +%Y%m%d)
SHORT_SHA=${GITHUB_SHA::8}
sed -i '' "s|InferNode 0.1|InferNode 0.1 build ${BUILD_DATE}-${SHORT_SHA}|" include/version.h
echo "Version: $(cat include/version.h)"
- name: Build mk
run: |
chmod +x makemk.sh
./makemk.sh
test -x MacOSX/arm64/bin/mk || { echo "mk build failed"; exit 1; }
- name: Build system libraries
run: |
export PATH="$ROOT/MacOSX/arm64/bin:/usr/bin:/bin"
for dir in lib9 libbio libmp libsec libmath; do
echo "Building $dir..."
(cd $dir && "$ROOT/MacOSX/arm64/bin/mk" install) || exit 1
done
- name: Build limbo compiler
run: |
export PATH="$ROOT/MacOSX/arm64/bin:/usr/bin:/bin"
(cd limbo && "$ROOT/MacOSX/arm64/bin/mk" install) || exit 1
test -x MacOSX/arm64/bin/limbo || { echo "limbo not found"; exit 1; }
- name: Build libinterp and remaining libraries
run: |
export PATH="$ROOT/MacOSX/arm64/bin:/usr/bin:/bin"
(cd libinterp && "$ROOT/MacOSX/arm64/bin/mk" install) || exit 1
for dir in libkeyring libdraw libmemdraw libmemlayer; do
echo "Building $dir..."
if ! (cd $dir && "$ROOT/MacOSX/arm64/bin/mk" install); then
echo "WARNING: $dir build failed (non-fatal for headless build)"
fi
done
- name: Build headless emulator
run: |
export PATH="$ROOT/MacOSX/arm64/bin:/usr/bin:/bin"
cd emu/MacOSX
OBJTYPE=arm64 SYSTARG=MacOSX SHELL=/bin/sh "$ROOT/MacOSX/arm64/bin/mk" -f mkfile-g
test -f o.emu || { echo "Headless emulator build failed"; exit 1; }
- name: Compile essential dis files
run: |
LIMBO="$ROOT/MacOSX/arm64/bin/limbo"
# Verify limbo works
echo "Using limbo: $LIMBO"
"$LIMBO" -w 2>&1 || true
# emuinit + shell (these must succeed)
echo "Compiling emuinit.b..."
"$LIMBO" -I./module -gw appl/cmd/emuinit.b
cp emuinit.dis dis/
echo "Compiling sh.b..."
(cd appl/cmd/sh && ../../../MacOSX/arm64/bin/limbo -I../../../module -gw sh.b && cp sh.dis ../../../dis/)
# Core commands
for cmd in cat ls pwd echo date; do
echo "Compiling $cmd.b..."
"$LIMBO" -I./module -gw "appl/cmd/$cmd.b" && cp "$cmd.dis" dis/ || echo "WARNING: $cmd.b compilation failed"
done
# Essential libraries
mkdir -p dis/lib
cd appl/lib
for f in bufio.b string.b readdir.b arg.b; do
echo "Compiling lib/$f..."
"../../MacOSX/arm64/bin/limbo" -I../../module -gw "$f" || echo "WARNING: $f compilation failed"
done
cp bufio.dis string.dis readdir.dis arg.dis ../../dis/lib/ 2>/dev/null || true
cd "$ROOT"
# Verify critical .dis files exist (from compilation or git checkout)
echo "Verifying essential .dis files..."
for f in dis/emuinit.dis dis/sh.dis dis/cat.dis dis/ls.dis dis/pwd.dis; do
if [ -f "$f" ]; then
echo " OK: $f ($(wc -c < "$f") bytes)"
else
echo " MISSING: $f"
fi
done
- name: Compile test suite
run: |
LIMBO="$ROOT/MacOSX/arm64/bin/limbo"
mkdir -p dis/lib
# Build testing library
COMPILE_FAILURES=0
if [ -d tests/testing ]; then
cd tests/testing
for f in *.b; do
if [ -f "$f" ]; then
if ! "$LIMBO" -I "$ROOT/module" -o "$ROOT/dis/lib/${f%.b}.dis" "$f" 2>&1; then
echo "ERROR: Failed to compile testing/$f"
COMPILE_FAILURES=$((COMPILE_FAILURES + 1))
fi
fi
done
cd "$ROOT"
fi
# Build test runner and test files into tests/ where the runner expects them
cd tests
for f in *.b; do
name="${f%.b}"
echo "Compiling $f..."
if ! "$LIMBO" -I "$ROOT/module" -o "$ROOT/tests/$name.dis" "$f" 2>&1; then
echo "ERROR: Failed to compile $f"
COMPILE_FAILURES=$((COMPILE_FAILURES + 1))
fi
done
cd "$ROOT"
test -f tests/runner.dis || { echo "Test runner not compiled"; exit 1; }
echo "Compiled test .dis files:"
ls tests/*_test.dis 2>/dev/null | wc -l
if [ "$COMPILE_FAILURES" -gt 0 ]; then
echo "ERROR: $COMPILE_FAILURES test file(s) failed to compile"
exit 1
fi
- name: Run test suite
run: |
# Create /tmp inside Inferno root for tmp_writable test
mkdir -p tmp
echo "Running test suite inside Inferno emulator..."
# The emulator doesn't exit cleanly after the test runner finishes
# (kernel threads keep the process alive), so we capture output and
# parse the result instead of relying on exit code.
# macOS doesn't have timeout; use background process with kill
./emu/MacOSX/o.emu -r . /tests/runner.dis -v > test-output.txt 2>&1 &
EMU_PID=$!
( sleep 60; kill $EMU_PID 2>/dev/null ) &
WATCHDOG=$!
wait $EMU_PID 2>/dev/null || true
kill $WATCHDOG 2>/dev/null || true
cat test-output.txt
# Check test results from output
if grep -q "^PASS$" test-output.txt; then
echo "Tests passed."
elif grep -q "^FAIL$" test-output.txt; then
echo "Tests failed."
exit 1
else
echo "No test result found in output — tests may not have run."
exit 1
fi
- name: Run port verification
run: |
chmod +x verify-port.sh
./verify-port.sh
- name: Run wallet and secstore integration tests
run: |
echo "Running host-side integration tests..."
# wallet9p basic operations
if [ -f tests/host/wallet9p_test.sh ]; then
echo "--- wallet9p test ---"
chmod +x tests/host/wallet9p_test.sh
ROOT=. bash tests/host/wallet9p_test.sh > wallet9p-test.txt 2>&1 || true
cat wallet9p-test.txt
if grep -q "=== PASS ===" wallet9p-test.txt; then
echo "wallet9p test: PASS"
else
echo "wallet9p test: SKIP (requires full Inferno namespace)"
fi
fi
# wallet persistence (secstore round-trip)
if [ -f tests/host/wallet_persist_test.sh ]; then
echo "--- wallet persistence test ---"
chmod +x tests/host/wallet_persist_test.sh
ROOT=. bash tests/host/wallet_persist_test.sh > wallet-persist-test.txt 2>&1 || true
cat wallet-persist-test.txt
if grep -q "^PASS$" wallet-persist-test.txt; then
echo "wallet persistence test: PASS"
else
echo "wallet persistence test: FAIL (non-fatal in CI)"
fi
fi
- name: Upload macOS build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: success()
with:
name: infernode-macos-arm64
path: |
emu/MacOSX/o.emu
MacOSX/arm64/bin/limbo
MacOSX/arm64/bin/mk
retention-days: 14