Skip to content

Commit cb5ebdd

Browse files
committed
add initial version of CI tests
1 parent 38bc218 commit cb5ebdd

7 files changed

Lines changed: 113 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
workflow_dispatch:
7+
8+
env:
9+
GH_TOKEN: ${{ github.token }}
10+
RUSTDOCFLAGS: -Dwarnings
11+
12+
jobs:
13+
clippy:
14+
name: Clippy
15+
runs-on: ubuntu-26.04
16+
steps:
17+
- uses: actions/checkout@v7
18+
with:
19+
submodules: true
20+
lfs: true
21+
- name: Install Rust toolchain
22+
uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: clippy
25+
- name: Clippy
26+
run: |
27+
cd mkinitrd
28+
cargo clippy
29+
cd ..
30+
ARCH=x86_64 make initrd.img
31+
cd image
32+
cargo clippy --target=x86_64-unknown-none -- -Dwarnings
33+
cd ..
34+
rm initrd.img
35+
ARCH=aarch64 make initrd.img
36+
cd image
37+
cargo clippy --target=aarch64-unknown-none-softfloat -- -Dwarnings
38+
cd ..
39+
rm initrd.img
40+
ARCH=riscv64 make initrd.img
41+
cd image
42+
cargo clippy --target=riscv64gc-unknown-none-elf --no-default-features --features loader,fork,kernel-stack,common-os -- -Dwarnings
43+
44+
format:
45+
name: Format
46+
runs-on: ubuntu-26.04
47+
steps:
48+
- uses: actions/checkout@v7
49+
with:
50+
submodules: true
51+
- name: Install Rust toolchain
52+
uses: dtolnay/rust-toolchain@stable
53+
with:
54+
components: clippy rustfmt
55+
- name: Format
56+
run: |
57+
cd mkinitrd
58+
cargo fmt -- --check
59+
cd ../image
60+
cargo fmt -- --check
61+
62+
run-hermit:
63+
name: Run
64+
runs-on: ubuntu-26.04
65+
strategy:
66+
matrix:
67+
arch: [x86_64, aarch64, riscv64]
68+
profile: [dev, release]
69+
include:
70+
- arch: x86_64
71+
packages: qemu-system-x86-hwe
72+
flags: --accel --sudo
73+
- arch: aarch64
74+
packages: qemu-system-arm-hwe
75+
- arch: riscv64
76+
packages: qemu-system-riscv-hwe
77+
steps:
78+
- uses: actions/checkout@v7
79+
with:
80+
submodules: true
81+
lfs: true
82+
- name: Install Packages
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install --no-install-recommends ipxe-qemu libcap-ng-dev libseccomp-dev ${{ matrix.packages }}
86+
- name: Download loader
87+
working-directory: ./image
88+
run: gh release download --repo hermit-os/loader --pattern 'hermit-loader-${{ matrix.arch }}*'
89+
- name: Install Rust toolchain
90+
uses: dtolnay/rust-toolchain@stable
91+
- name: Run boot-image
92+
run: |
93+
ARCH=${{ matrix.arch }} make run

‎image/.cargo/config.toml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ build-std-features = ["compiler-builtins-mem"]
66
target = "x86_64-unknown-none"
77

88
[target.x86_64-unknown-none]
9-
runner = "qemu-system-x86_64 -display none -serial stdio -kernel hermit-loader-x86_64 -cpu Skylake-Client -device isa-debug-exit,iobase=0xf4,iosize=0x04 -smp 1 -m 2G -netdev user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9 -device virtio-net-pci,netdev=u1,disable-legacy=on -monitor telnet:127.0.0.1:12345,server,nowait -initrd"
9+
runner = "qemu-system-x86_64 -display none -serial stdio -kernel hermit-loader-x86_64-multiboot -cpu Skylake-Client -device isa-debug-exit,iobase=0xf4,iosize=0x04 -smp 1 -m 2G -netdev user,id=u1,hostfwd=tcp::9975-:9975,hostfwd=udp::9975-:9975,net=192.168.76.0/24,dhcpstart=192.168.76.9 -device virtio-net-pci,netdev=u1,disable-legacy=on -monitor telnet:127.0.0.1:12345,server,nowait -initrd"
1010

1111
[target.aarch64-unknown-none-softfloat]
1212
runner = "sh ./qemu-aarch64.sh"
13-
rustflags = ["-Clink-arg=--image-base=0x40400000"]
13+
# Link boot_image as a static PIE so the loader can place it anywhere in RAM.
14+
# The target spec does not enable static PIE, so `-pie` must be passed
15+
# explicitly; `-Crelocation-model=pic` alone still yields an ET_EXEC
16+
# linked at lld's default base (0x200000), which is outside of RAM.
17+
rustflags = [
18+
"-Crelocation-model=pic",
19+
"-Clink-arg=-pie",
20+
"-Clink-arg=--no-dynamic-linker",
21+
"-Clink-arg=-ztext",
22+
]
1423

1524
[target.riscv64gc-unknown-none-elf]
1625
# Uses QEMU's bundled OpenSBI as the default -bios for the virt machine.
17-
runner = "qemu-system-riscv64 -machine virt -cpu rv64 -smp 1 -m 2G -display none -serial stdio -kernel hermit-loader-riscv64 -initrd"
26+
runner = "qemu-system-riscv64 -machine virt -cpu rv64 -smp 1 -m 2G -display none -serial stdio -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.bin -kernel hermit-loader-riscv64-sbi -initrd"
1827
# RAM on the virt machine starts at 0x8000_0000; OpenSBI occupies the
1928
# first 512 KiB and the loader sits at 0x8020_0000. Link the kernel
2029
# image above both (the loader loads ELF segments at their link

‎image/kernel‎

‎image/qemu-aarch64.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# because cargo invokes the runner with the working directory set there.
55
exec qemu-system-aarch64 \
66
-display none -serial stdio \
7-
-kernel hermit-loader-aarch64 \
7+
-kernel hermit-loader-aarch64-elf \
88
-machine virt,gic-version=3 \
99
-cpu max,lpa2=off \
1010
-semihosting \

‎image/rust-toolchain.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[toolchain]
22
channel = "nightly-2026-09-01"
33
components = [
4+
"clippy",
45
"llvm-tools",
56
"rust-src",
7+
"rustfmt",
68
]

‎image/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub extern "C" fn main(_argc: i32, _argv: *const *const u8, _env: *const *const
410410

411411
info!("Start user-level process to initialize the HermitOS");
412412

413-
let app = c"/bin/fork".to_owned();
413+
let app = c"/bin/pipe".to_owned();
414414
let spawn_args = Box::new(SpawnArgs {
415415
args: vec![app.clone()],
416416
envs: Vec::new(),

‎mkinitrd/src/list.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub fn list(path: &Path) -> io::Result<()> {
2323

2424
println!(
2525
"Found file {:?} ({} bytes, compressed {} bytes)",
26-
ramdisk_file.path, decompressed_size, ramdisk_file.bin.len()
26+
ramdisk_file.path,
27+
decompressed_size,
28+
ramdisk_file.bin.len()
2729
);
2830
}
2931

0 commit comments

Comments
 (0)