Skip to content

Commit c17d290

Browse files
authoredOct 4, 2020
Merge pull request #16 from Rust-for-Linux/github-ci
Add CI
2 parents 58ffd76 + 453d1ac commit c17d290

File tree

7 files changed

+2834
-0
lines changed

7 files changed

+2834
-0
lines changed
 

‎.github/workflows/ci.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on: [pull_request, push]
2+
3+
jobs:
4+
ci:
5+
runs-on: ubuntu-20.04
6+
timeout-minutes: 15
7+
8+
strategy:
9+
matrix:
10+
mode: [debug, release]
11+
module: [builtin, loadable]
12+
13+
steps:
14+
# Setup
15+
- uses: actions/checkout@v2
16+
- run: sudo apt install libelf-dev qemu-system-x86 busybox-static
17+
- run: rustup default nightly-2020-08-27
18+
- run: rustup component add rust-src
19+
20+
# Build
21+
- run: cp .github/workflows/kernel-${{ matrix.mode }}.config .config
22+
- if: matrix.module == 'loadable'
23+
run: sed -i -E 's/^(CONFIG_RUST_EXAMPLE=)(y)$/\1m/g' .config
24+
- run: make CC=clang-10 LLVM_CONFIG_PATH=llvm-config-10 -j3
25+
26+
# Run
27+
- if: matrix.module == 'builtin'
28+
run: sed -i '/rust_example/d' .github/workflows/qemu-initramfs.desc
29+
- run: usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img
30+
- run: qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd qemu-initramfs.img -cpu Cascadelake-Server -smp 2 -append "console=ttyS0 ${{ matrix.module == 'builtin' && 'rust_example.my_i32=123321' || '' }}" -nographic -no-reboot | tee qemu-stdout.log
31+
32+
# Check
33+
- run: grep -F 'Rust Example (init)' qemu-stdout.log
34+
- run: "grep 'my_i32: \\+123321' qemu-stdout.log"
35+
- if: matrix.module == 'loadable'
36+
run: grep -F 'Rust Example (exit)' qemu-stdout.log

‎.github/workflows/kernel-debug.config

+1,426
Large diffs are not rendered by default.

‎.github/workflows/kernel-release.config

+1,351
Large diffs are not rendered by default.

‎.github/workflows/qemu-init.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
if [ -f rust_example.ko ]; then
4+
busybox insmod rust_example.ko my_i32=123321
5+
busybox rmmod rust_example.ko
6+
fi
7+
8+
busybox reboot -f

‎.github/workflows/qemu-initramfs.desc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dir /bin 0755 0 0
2+
dir /sys 0755 0 0
3+
dir /dev 0755 0 0
4+
file /bin/busybox /bin/busybox 0755 0 0
5+
slink /bin/sh /bin/busybox 0755 0 0
6+
file /init .github/workflows/qemu-init.sh 0755 0 0
7+
file /rust_example.ko drivers/char/rust_example/rust_example.ko 0755 0 0

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ modules.order
9595
!.gitignore
9696
!.mailmap
9797

98+
# XXX: Only for GitHub CI -- do not commit into mainline
99+
!.github
100+
98101
#
99102
# Generated include files
100103
#

‎rust/kernel/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pub mod file_operations;
1818
pub mod prelude;
1919
pub mod printk;
2020
pub mod random;
21+
22+
#[cfg(CONFIG_SYSCTL)]
2123
pub mod sysctl;
24+
2225
mod types;
2326
pub mod user_ptr;
2427

0 commit comments

Comments
 (0)
Please sign in to comment.