Skip to content

Commit 4bb09f5

Browse files
authored
Merge pull request greatbridf#44 from greatbridf/pipeline
Pipeline build and test support
2 parents 9e7e047 + 9a207f5 commit 4bb09f5

3 files changed

Lines changed: 88 additions & 1 deletion

File tree

.github/workflows/test-build.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test Build
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- comp-and-judge
7+
pull_request:
8+
branches-ignore:
9+
- comp-and-judge
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-and-run-test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
arch: [riscv64, loongarch64]
19+
include:
20+
- arch: riscv64
21+
target: riscv64gc-unknown-none-elf
22+
- arch: loongarch64
23+
target: loongarch64-unknown-none-softfloat
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup rust nightly
29+
run: rustup component add rust-src llvm-tools
30+
31+
- name: Setup QEMU
32+
run: |
33+
sudo apt-get install -y qemu-system-${{ matrix.arch }} qemu-kvm
34+
35+
- name: Configure
36+
run: ./configure
37+
38+
- name: Run build for ${{ matrix.arch }} targets
39+
run: |
40+
make build ARCH=${{ matrix.arch }} MODE=release
41+
zstd -k build/boot-${{ matrix.arch }}.img
42+
43+
- name: Upload build artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: eonix-kernel-and-image-${{ matrix.arch }}
47+
path: |
48+
build/${{ matrix.target }}/release/eonix_kernel
49+
build/boot-${{ matrix.arch }}.img.zst
50+
51+
- name: Test run for ${{ matrix.arch }}
52+
run: |
53+
echo "Fixing permissions for /dev/kvm..."
54+
sudo adduser $USER kvm
55+
sh script/test.sh
56+
env:
57+
ARCH: ${{ matrix.arch }}
58+
QEMU_ACCEL: ''
59+
timeout-minutes: 2
60+
continue-on-error: true
61+
62+
- name: Upload run log
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: test-${{ matrix.arch }}.log
66+
path: build/test-*.log

Makefile.src

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ KERNEL_SOURCES := $(shell find src macros crates -name '*.rs' -type f)
2121
KERNEL_CARGO_MANIFESTS += $(shell find src macros crates -name Cargo.toml -type f)
2222
KERNEL_DEPS := $(KERNEL_SOURCES) $(KERNEL_CARGO_MANIFESTS)
2323

24-
QEMU_ARGS ?= -no-reboot -no-shutdown
24+
QEMU_ARGS ?= -no-reboot
2525
CARGO_FLAGS := --profile $(PROFILE) --features $(FEATURES)$(if $(SMP),$(COMMA)smp,)
2626

2727
ifeq ($(HOST),darwin)
2828
QEMU_ACCEL ?= -accel tcg
2929
else ifeq ($(HOST),linux)
30+
31+
ifeq ($(shell ls /dev/kvm),/dev/kvm)
3032
QEMU_ACCEL ?= -accel kvm
3133
endif
3234

35+
endif
36+
3337
QEMU_ARGS += $(QEMU_ACCEL)
3438

3539
ifneq ($(DEBUG_TRAPS),)
@@ -122,6 +126,10 @@ run: build build/kernel.sym
122126
srun: build build/kernel.sym
123127
$(QEMU) $(QEMU_ARGS) -display none -S -s -serial mon:stdio
124128

129+
.PHONY: test-run
130+
test-run: build
131+
$(QEMU) $(QEMU_ARGS) -display none -serial stdio
132+
125133
.PHONY: clean
126134
clean:
127135
-rm -rf build

script/test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
SUCCESS_MSG="###$RANDOM :SuCCeSS: $RANDOM###"
4+
5+
if [ "$ARCH" = "" ]; then
6+
echo "Error: ARCH environment variable is not set." >&2
7+
exit 1
8+
fi
9+
10+
printf "ls\necho \"$SUCCESS_MSG\"\npoweroff\n" \
11+
| make test-run ARCH=$ARCH MODE=release QEMU=qemu-system-$ARCH \
12+
| tee build/test-$$.log \
13+
| grep "$SUCCESS_MSG" > /dev/null && echo TEST\ $$\ WITH\ ARCH=$ARCH\ PASSED

0 commit comments

Comments
 (0)