-
Notifications
You must be signed in to change notification settings - Fork 152
699 lines (641 loc) · 27.9 KB
/
Copy pathmain.yml
File metadata and controls
699 lines (641 loc) · 27.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
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
name: CI
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
detect-code-related-file-changes:
runs-on: ubuntu-24.04
outputs:
has_code_related_changes: ${{ steps.set_has_code_related_changes.outputs.has_code_related_changes }}
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Test changed files
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: |
.ci/**
build/**
mk/**
src/**
tests/**
tools/**
.clang-format
Dockerfile
Makefile
- name: Set has_code_related_changes
id: set_has_code_related_changes
run: |
if [[ ${{ steps.changed-files.outputs.any_changed }} == true ]]; then
echo "has_code_related_changes=true" >> $GITHUB_OUTPUT
else
echo "has_code_related_changes=false" >> $GITHUB_OUTPUT
fi
host-x64:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
submodules: 'true'
- name: Read LLVM Version
id: llvm-version
run: echo "version=$(cat .ci/llvm-version)" >> $GITHUB_OUTPUT
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v5
with:
path: /usr/lib/llvm-${{ steps.llvm-version.outputs.version }}
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ steps.llvm-version.outputs.version }}
- name: Cache RISC-V Toolchain
id: cache-toolchain
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/toolchain
key: ${{ runner.os }}-${{ runner.arch }}-riscv-toolchain-${{ hashFiles('.ci/riscv-toolchain-install.sh') }}
- name: Install dependencies
run: |
set +e # Disable errexit
# Configure apt to tolerate mirror sync failures
sudo tee /etc/apt/apt.conf.d/99-ci-reliability > /dev/null << 'EOF'
APT::Update::Error-Mode "any";
Acquire::IndexTargets::deb::DEP-11::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons-hidpi::DefaultEnabled "false";
Acquire::Retries "3";
Acquire::Check-Valid-Until "false";
EOF
# Update with error tolerance
sudo apt-get update -q=2 2>&1
UPDATE_EXIT=$?
if [ $UPDATE_EXIT -ne 0 ]; then
echo "WARNING: apt update exited with code $UPDATE_EXIT, continuing..."
fi
sudo apt-get install -q=2 curl libsdl2-dev libsdl2-mixer-dev device-tree-compiler expect bc p7zip-full
set -e # Re-enable errexit
shell: bash
- name: Install RISC-V Toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
.ci/riscv-toolchain-install.sh
- name: Setup RISC-V Toolchain PATH
run: echo "${{ github.workspace }}/toolchain/bin" >> $GITHUB_PATH
- name: Install LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
.ci/fetch.sh -q -o llvm.sh https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh ${{ steps.llvm-version.outputs.version }}
- name: Setup LLVM PATH
run: echo "/usr/lib/llvm-${{ steps.llvm-version.outputs.version }}/bin" >> $GITHUB_PATH
- name: Install compiler
id: install_cc
uses: rlalik/setup-cpp-compiler@master
with:
compiler: ${{ matrix.compiler }}
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.51
actions-cache-folder: 'emsdk-cache'
- name: Set parallel jobs variable
run: |
echo "PARALLEL=-j$(nproc)" >> "$GITHUB_ENV"
echo "BOOT_LINUX_TEST=TMP_FILE=\$(mktemp "$RUNNER_TEMP/tmpfile.XXXXXX"); \
sudo env TMP_FILE=\${TMP_FILE} .ci/boot-linux-prepare.sh setup; \
. \${TMP_FILE}; \
.ci/boot-linux.sh; \
EXIT_CODE=\$?; \
sudo env TMP_FILE=\${TMP_FILE} BLK_DEV_EXT4=\${BLK_DEV_EXT4} \
BLK_DEV_SIMPLEFS=\${BLK_DEV_SIMPLEFS} .ci/boot-linux-prepare.sh cleanup; \
exit \${EXIT_CODE};" >> "$GITHUB_ENV"
- name: Cache build artifacts
uses: actions/cache@v5
with:
path: build/
key: rv32emu-artifacts-${{ runner.os }}-${{ hashFiles('mk/artifact.mk', 'mk/external.mk') }}
restore-keys: |
rv32emu-artifacts-${{ runner.os }}-
- name: Fetch artifacts
env:
CC: ${{ steps.install_cc.outputs.cc }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .ci/common.sh
fetch_artifact ELF
fetch_artifact Linux-Image ENABLE_SYSTEM=1
rm -f build/.config # Clean config after ENABLE_SYSTEM=1 to prevent contamination
fetch_artifact sail ENABLE_ARCH_TEST=1
# get from rv32emu-prebuilt
.ci/fetch.sh -o build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
unzip -o -d build/ build/shareware_doom_iwad.zip
# emcc builds run on x64 only - WebAssembly output is platform-independent
# This validates Emscripten compatibility without redundant builds on macOS
- name: default build using emcc
if: success()
run: |
make distclean
make CC=emcc ENABLE_JIT=0 $PARALLEL
- name: default build for system emulation using emcc
if: success()
run: |
make distclean
make CC=emcc ENABLE_SYSTEM=1 ENABLE_JIT=0 $PARALLEL
make distclean ENABLE_SYSTEM=1
- name: Build with various optimization levels
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
set -euo pipefail
# Test boundary cases: -O0 (unoptimized), -O2 (standard), -Ofast (aggressive)
for opt_level in -O0 -O2 -Ofast; do
echo "Building with OPT_LEVEL=$opt_level"
if ! (make distclean && make OPT_LEVEL=$opt_level $PARALLEL); then
echo "ERROR: Build failed with OPT_LEVEL=$opt_level"
exit 1
fi
done
- name: Build system emulation with various optimization levels
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
set -euo pipefail
# Test boundary cases: -O0 (unoptimized), -O2 (standard), -Ofast (aggressive)
for opt_level in -O0 -O2 -Ofast; do
echo "Building system emulation with OPT_LEVEL=$opt_level"
if ! (make distclean && make OPT_LEVEL=$opt_level ENABLE_SYSTEM=1 $PARALLEL); then
echo "ERROR: System emulation build failed with OPT_LEVEL=$opt_level"
exit 1
fi
done
- name: check + tests
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean
make check $PARALLEL
make tests $PARALLEL
make misalign $PARALLEL
make tool $PARALLEL
- name: core extension disable tests (interpreter + JIT)
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
set -euo pipefail
# Core extensions + bit manipulation + CSR/fence + performance features
# Tests both interpreter and JIT modes (12 × 2 = 24 builds)
# Consolidated from 25 separate builds (13 interpreter + 12 JIT)
for ext in ENABLE_EXT_M ENABLE_EXT_A ENABLE_EXT_F ENABLE_EXT_C \
ENABLE_Zba ENABLE_Zbb ENABLE_Zbc ENABLE_Zbs \
ENABLE_Zicsr ENABLE_Zifencei \
ENABLE_MOP_FUSION ENABLE_BLOCK_CHAINING; do
echo "Testing ${ext}=0 (interpreter)"
if ! (make distclean && make ${ext}=0 check $PARALLEL); then
echo "ERROR: Interpreter test failed with ${ext}=0"
exit 1
fi
echo "Testing ${ext}=0 (JIT)"
if ! (make ENABLE_JIT=1 clean && make ${ext}=0 ENABLE_JIT=1 check $PARALLEL); then
echo "ERROR: JIT test failed with ${ext}=0"
exit 1
fi
done
- name: SDL disable test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
# SDL is graphics subsystem, interpreter-only test sufficient
make distclean && make ENABLE_SDL=0 check $PARALLEL
- name: misalignment test in block emulation
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make -C tests/system/alignment/
make distclean && make ENABLE_ELF_LOADER=1 ENABLE_EXT_C=0 ENABLE_SYSTEM=1 misalign-in-blk-emu $PARALLEL
- name: MMU test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make -C tests/system/mmu/
make distclean && make ENABLE_ELF_LOADER=1 ENABLE_SYSTEM=1 mmu-test $PARALLEL
- name: gdbstub test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make ENABLE_GDBSTUB=1 gdbstub-test $PARALLEL
- name: JIT base test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
# Base JIT test (extension disable tests handled in consolidated step above)
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 check $PARALLEL
- name: undefined behavior test
if: success() || failure()
run: |
# Clear cached config from previous steps to avoid ENABLE_SYSTEM=1 contamination
rm -f build/.config
make distclean && make ENABLE_UBSAN=1 check $PARALLEL
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 ENABLE_UBSAN=1 check $PARALLEL
- name: boot Linux kernel test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make INITRD_SIZE=32 ENABLE_SYSTEM=1 $PARALLEL && make ENABLE_SYSTEM=1 artifact $PARALLEL
bash -c "${BOOT_LINUX_TEST}"
make ENABLE_SYSTEM=1 clean
- name: boot Linux kernel test (JIT)
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make INITRD_SIZE=32 ENABLE_SYSTEM=1 ENABLE_JIT=1 ENABLE_MOP_FUSION=0 $PARALLEL && make ENABLE_SYSTEM=1 artifact $PARALLEL
bash -c "${BOOT_LINUX_TEST}"
make ENABLE_SYSTEM=1 ENABLE_JIT=1 ENABLE_MOP_FUSION=0 clean
- name: Architecture test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .ci/common.sh
export LATEST_RELEASE=$(download_with_headers "https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases" \
"Authorization: Bearer ${GH_TOKEN}" \
| grep '"tag_name"' \
| grep "sail" \
| head -n 1 \
| sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
.ci/riscv-tests.sh
# Native AArch64 on GitHub ARM runners - fast, no QEMU overhead
host-arm64:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 30
runs-on: ubuntu-24.04-arm
steps:
- name: checkout code
uses: actions/checkout@v6
with:
submodules: 'true'
- name: Set LLVM version
run: echo "LLVM_VERSION=$(cat .ci/llvm-version)" >> $GITHUB_ENV
- name: Install dependencies
run: |
# Configure apt to tolerate ARM mirror sync failures
sudo tee /etc/apt/apt.conf.d/99-ci-reliability > /dev/null << 'EOF'
APT::Update::Error-Mode "any";
Acquire::IndexTargets::deb::DEP-11::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons-hidpi::DefaultEnabled "false";
Acquire::Retries "3";
Acquire::Check-Valid-Until "false";
EOF
# Update with error tolerance
sudo apt-get update -q=2 || {
echo "WARNING: apt update failed, continuing with cached indexes..."
}
# Install packages with retry for critical ones
sudo apt-get install -q=2 -y make curl wget libsdl2-dev libsdl2-mixer-dev \
lsb-release software-properties-common gnupg bc || {
echo "WARNING: Some packages failed, retrying critical ones..."
sudo apt-get install -q=2 -y --no-download make curl wget || true
}
- name: Install LLVM
run: |
.ci/fetch.sh -q -o llvm.sh https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh $LLVM_VERSION
- name: Setup LLVM PATH
run: echo "/usr/lib/llvm-${LLVM_VERSION}/bin" >> $GITHUB_PATH
- name: Set parallel jobs variable
run: echo "PARALLEL=-j$(nproc)" >> "$GITHUB_ENV"
- name: Fetch artifacts
env:
CC: clang-${{ env.LLVM_VERSION }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .ci/common.sh
LATEST_RELEASE=$(download_with_headers "https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases" \
"Authorization: Bearer ${GH_TOKEN}" \
| grep '"tag_name"' \
| grep "ELF" \
| head -n 1 \
| sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
if [ -z "$LATEST_RELEASE" ]; then
echo "Error: Failed to fetch LATEST_RELEASE from GitHub API"
exit 1
fi
make LATEST_RELEASE=$LATEST_RELEASE artifact
# FIXME: gcc build fails on AArch64/Linux hosts
- name: check + tests
env:
CC: clang-${{ env.LLVM_VERSION }}
run: |
make $PARALLEL
make check $PARALLEL
- name: JIT tests
env:
CC: clang-${{ env.LLVM_VERSION }}
run: |
set -euo pipefail
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 check $PARALLEL
for ext in ENABLE_EXT_A ENABLE_EXT_F ENABLE_EXT_C; do
echo "JIT test with ${ext}=0"
make ENABLE_JIT=1 clean && make ${ext}=0 ENABLE_JIT=1 check $PARALLEL
done
macOS-arm64:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
compiler: [gcc-15, clang]
runs-on: macos-latest # M1 chip
steps:
- uses: actions/checkout@v6
with:
submodules: 'true'
- name: Read LLVM Version
id: llvm-version
run: echo "version=$(cat .ci/llvm-version)" >> $GITHUB_OUTPUT
- name: Cache RISC-V Toolchain
id: cache-toolchain
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/toolchain
key: ${{ runner.os }}-${{ runner.arch }}-riscv-toolchain-${{ hashFiles('.ci/riscv-toolchain-install.sh') }}
- name: Cache Homebrew packages
id: cache-brew
uses: actions/cache@v5
with:
path: |
/opt/homebrew/Cellar/llvm@${{ steps.llvm-version.outputs.version }}
/opt/homebrew/Cellar/sdl2
/opt/homebrew/Cellar/dtc
key: ${{ runner.os }}-${{ runner.arch }}-brew-llvm${{ steps.llvm-version.outputs.version }}-${{ hashFiles('.github/workflows/main.yml') }}
- name: Install dependencies
run: |
brew install make dtc expect sdl2 bc e2fsprogs p7zip llvm@${{ steps.llvm-version.outputs.version }} dcfldd
brew install sdl2_mixer || echo "Warning: sdl2_mixer installation failed, continuing without SDL_MIXER support"
# Ensure symlinks exist after cache restore (cached Cellar may lack /opt/homebrew/bin links)
brew link dtc --overwrite 2>/dev/null || true
command -v dtc || { echo "ERROR: dtc not found in PATH after install"; exit 1; }
- name: Install RISC-V Toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
.ci/riscv-toolchain-install.sh
- name: Setup toolchain paths
run: |
echo "${{ github.workspace }}/toolchain/bin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@${{ steps.llvm-version.outputs.version }})/bin" >> $GITHUB_PATH
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install compiler
id: install_cc
uses: rlalik/setup-cpp-compiler@master
with:
compiler: ${{ matrix.compiler }}
# NOTE: emsdk removed - emcc builds run on host-x64 only (WebAssembly is platform-independent)
- name: Set parallel jobs variable
run: |
echo "PARALLEL=-j$(sysctl -n hw.logicalcpu)" >> "$GITHUB_ENV"
echo "BOOT_LINUX_TEST=TMP_FILE=\$(mktemp "$RUNNER_TEMP/tmpfile.XXXXXX"); \
sudo env TMP_FILE=\${TMP_FILE} .ci/boot-linux-prepare.sh setup; \
. \${TMP_FILE}; \
.ci/boot-linux.sh; \
EXIT_CODE=\$?; \
sudo env TMP_FILE=\${TMP_FILE} BLK_DEV_EXT4=\${BLK_DEV_EXT4} .ci/boot-linux-prepare.sh cleanup; \
exit \${EXIT_CODE};" >> "$GITHUB_ENV"
- name: Symlink gcc-15 due to the default /usr/local/bin/gcc links to system's clang
run: |
ln -s /opt/homebrew/opt/gcc/bin/gcc-15 /usr/local/bin/gcc-15
- name: fetch artifact first to reduce HTTP requests
env:
CC: ${{ steps.install_cc.outputs.cc }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .ci/common.sh
fetch_artifact ELF
fetch_artifact Linux-Image ENABLE_SYSTEM=1
rm -f build/.config # Clean config after ENABLE_SYSTEM=1 to prevent contamination
fetch_artifact sail ENABLE_ARCH_TEST=1
# get from rv32emu-prebuilt
.ci/fetch.sh -o build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
unzip -o -d build/ build/shareware_doom_iwad.zip
# NOTE: emcc builds removed - they run on host-x64 only since WebAssembly output is platform-independent
- name: check + tests
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean
make check $PARALLEL
make tests $PARALLEL
make misalign $PARALLEL
make tool $PARALLEL
- name: core extension disable tests (interpreter + JIT)
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
set -euo pipefail
# Core extensions + bit manipulation + CSR/fence + performance features
# Tests both interpreter and JIT modes (12 × 2 = 24 builds)
# Consolidated from 25 separate builds (13 interpreter + 12 JIT)
for ext in ENABLE_EXT_M ENABLE_EXT_A ENABLE_EXT_F ENABLE_EXT_C \
ENABLE_Zba ENABLE_Zbb ENABLE_Zbc ENABLE_Zbs \
ENABLE_Zicsr ENABLE_Zifencei \
ENABLE_MOP_FUSION ENABLE_BLOCK_CHAINING; do
echo "Testing ${ext}=0 (interpreter)"
if ! (make distclean && make ${ext}=0 check $PARALLEL); then
echo "ERROR: Interpreter test failed with ${ext}=0"
exit 1
fi
echo "Testing ${ext}=0 (JIT)"
if ! (make ENABLE_JIT=1 clean && make ${ext}=0 ENABLE_JIT=1 check $PARALLEL); then
echo "ERROR: JIT test failed with ${ext}=0"
exit 1
fi
done
- name: SDL disable test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
# SDL is graphics subsystem, interpreter-only test sufficient
make distclean && make ENABLE_SDL=0 check $PARALLEL
- name: gdbstub test, need RV32 toolchain
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make ENABLE_GDBSTUB=1 gdbstub-test $PARALLEL
- name: JIT base test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
# Base JIT test (extension disable tests handled in consolidated step above)
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 check $PARALLEL
- name: undefined behavior test
if: (success() || failure()) && steps.install_cc.outputs.cc == 'clang' # gcc on macOS/arm64 does not support sanitizers
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
# Clear cached config from previous steps to avoid ENABLE_SYSTEM=1 contamination
rm -f build/.config
make distclean && make ENABLE_UBSAN=1 check $PARALLEL
make ENABLE_JIT=1 clean && make ENABLE_JIT=1 ENABLE_UBSAN=1 check $PARALLEL
- name: boot Linux kernel test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make INITRD_SIZE=32 ENABLE_SYSTEM=1 $PARALLEL && \
make ENABLE_SYSTEM=1 artifact $PARALLEL
bash -c "${BOOT_LINUX_TEST}"
make ENABLE_SYSTEM=1 clean
- name: boot Linux kernel test (JIT)
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean && make INITRD_SIZE=32 ENABLE_SYSTEM=1 ENABLE_JIT=1 ENABLE_MOP_FUSION=0 $PARALLEL && make ENABLE_SYSTEM=1 artifact $PARALLEL
bash -c "${BOOT_LINUX_TEST}"
make ENABLE_SYSTEM=1 ENABLE_JIT=1 ENABLE_MOP_FUSION=0 clean
- name: Architecture test
if: success()
env:
CC: ${{ steps.install_cc.outputs.cc }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
. .ci/common.sh
export LATEST_RELEASE=$(download_with_headers "https://api.github.com/repos/sysprog21/rv32emu-prebuilt/releases" \
"Authorization: Bearer ${GH_TOKEN}" \
| grep '"tag_name"' \
| grep "sail" \
| head -n 1 \
| sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
python3 -m venv venv
. venv/bin/activate
.ci/riscv-tests.sh
coding-style:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 15
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: coding convention
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.gpg >/dev/null
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-20 main" | sudo tee /etc/apt/sources.list.d/llvm-20.list
sudo apt-get update -q=2
sudo apt-get install -q=2 clang-format-20 shfmt python3-pip
pip3 install black==25.1.0
curl -LSfs https://go.mskelton.dev/dtsfmt/install | sh -s -- -y
.ci/check-newline.sh
.ci/check-format.sh
shell: bash
static-analysis:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 45
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
submodules: 'true'
# LLVM static analysis
- name: set up scan-build
run: |
set +e # Disable errexit
# Configure apt to tolerate mirror sync failures
sudo tee /etc/apt/apt.conf.d/99-ci-reliability > /dev/null << 'EOF'
APT::Update::Error-Mode "any";
Acquire::IndexTargets::deb::DEP-11::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons::DefaultEnabled "false";
Acquire::IndexTargets::deb::DEP-11-icons-hidpi::DefaultEnabled "false";
Acquire::Retries "3";
Acquire::Check-Valid-Until "false";
EOF
# Update with error tolerance
sudo apt-get update -q=2 2>&1
UPDATE_EXIT=$?
if [ $UPDATE_EXIT -ne 0 ]; then
echo "WARNING: apt update exited with code $UPDATE_EXIT, continuing..."
fi
sudo apt-get install -q=2 curl libsdl2-dev libsdl2-mixer-dev
LLVM_VERSION=$(cat .ci/llvm-version)
.ci/fetch.sh -q -o llvm.sh https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh $LLVM_VERSION
sudo apt-get install -q=2 clang-${LLVM_VERSION} clang-tools-${LLVM_VERSION}
set -e # Re-enable errexit
shell: bash
- name: run scan-build without JIT
env:
LATEST_RELEASE: dummy
run: |
LLVM_VERSION=$(cat .ci/llvm-version)
make distclean && scan-build-${LLVM_VERSION} -v -o ~/scan-build --status-bugs --use-cc=clang-${LLVM_VERSION} --force-analyze-debug-code --show-description -analyzer-config stable-report-filename=true -enable-checker valist,nullability make ENABLE_EXT_F=0 ENABLE_SDL=0 ENABLE_JIT=0
- name: run scan-build with JIT
env:
LATEST_RELEASE: dummy
run: |
LLVM_VERSION=$(cat .ci/llvm-version)
make ENABLE_JIT=1 distclean && scan-build-${LLVM_VERSION} -v -o ~/scan-build --status-bugs --use-cc=clang-${LLVM_VERSION} --force-analyze-debug-code --show-description -analyzer-config stable-report-filename=true -enable-checker valist,nullability make ENABLE_EXT_F=0 ENABLE_SDL=0 ENABLE_JIT=1
# https://docs.docker.com/build/ci/github-actions/multi-platform/
docker-hub-build-and-publish:
needs: [detect-code-related-file-changes]
if: needs.detect-code-related-file-changes.outputs.has_code_related_changes == 'true'
timeout-minutes: 60
runs-on: ubuntu-24.04
steps:
- name: Check out the repo
uses: actions/checkout@v6
with:
submodules: 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
if: github.event_name == 'push'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Get short commit SHA1
if: github.event_name == 'push'
shell: bash
run: |
echo "short_hash=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build and push
if: github.event_name == 'push'
uses: docker/build-push-action@v6
with:
push: true
context: .
platforms: linux/amd64,linux/arm64/v8
tags: sysprog21/rv32emu:latest, sysprog21/rv32emu:${{ env.short_hash }}