.github/workflows/ci.yaml #909
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
pull_request: {} | |
schedule: | |
- cron: '30 11,23 * * *' | |
# push: | |
jobs: | |
ci: | |
runs-on: [self-hosted] | |
timeout-minutes: 20 | |
strategy: | |
matrix: | |
arch: [arm64] # arm, , ppc64le, riscv64, x86_64 | |
toolchain: [clang, llvm] # gcc | |
config: [release] # debug | |
rustc: [1.54.0] | |
output: [src] # [src, build] | |
install: [rustup] # [rustup, standalone] | |
sysroot: [common] # [common, custom] | |
exclude: | |
# arm 32-bit gcc not yet supported | |
- arch: arm | |
toolchain: gcc | |
# Exclude `LLVM=1` where not supported. | |
- arch: ppc64le | |
toolchain: llvm | |
- arch: riscv64 | |
toolchain: llvm | |
# A few independent combinations to avoid exploding the matrix: | |
# - The other option for `output`. | |
# - Different releases for `rustc`. | |
# - The other three (`install`, `sysroot`) combinations | |
# (they are interrelated, so the cross-product needs to be tested) | |
# include: | |
# - arch: arm64 | |
# toolchain: gcc | |
# config: debug | |
# rustc: 1.54.0 | |
# output: build | |
# install: rustup | |
# sysroot: custom | |
# - arch: ppc64le | |
# toolchain: clang | |
# config: release | |
# rustc: 1.54.0 | |
# output: build | |
# install: standalone | |
# sysroot: common | |
# - arch: x86_64 | |
# toolchain: llvm | |
# config: debug | |
# rustc: 1.54.0 | |
# output: build | |
# install: standalone | |
# sysroot: custom | |
steps: | |
# Setup: checkout | |
- uses: actions/checkout@v2 | |
# Setup: Store matrix name | |
- run: echo 'MATRIX_NAME=${{ matrix.arch }}-${{ matrix.toolchain }}-${{ matrix.config }}' >> $GITHUB_ENV | |
# Setup: Github cache | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.ccache | |
key: ${{ env.MATRIX_NAME }}-ccache-${{ github.run_id }} | |
restore-keys: | | |
${{ env.MATRIX_NAME }}-ccache- | |
# Setup: variables | |
- if: matrix.arch == 'x86_64' | |
run: | | |
echo 'IMAGE_PATH=arch/x86/boot/bzImage' >> $GITHUB_ENV | |
echo 'QEMU_ARCH=x86_64' >> $GITHUB_ENV | |
echo 'QEMU_MACHINE=pc' >> $GITHUB_ENV | |
echo 'QEMU_CPU=Cascadelake-Server' >> $GITHUB_ENV | |
echo 'QEMU_APPEND=console=ttyS0' >> $GITHUB_ENV | |
- if: matrix.arch == 'arm64' | |
run: | | |
echo 'MAKE_ARCH=ARCH=arm64' >> $GITHUB_ENV | |
echo 'MAKE_CROSS_COMPILE=CROSS_COMPILE=aarch64-linux-gnu-' >> $GITHUB_ENV | |
echo 'IMAGE_PATH=arch/arm64/boot/Image.gz' >> $GITHUB_ENV | |
echo 'QEMU_ARCH=aarch64' >> $GITHUB_ENV | |
echo 'QEMU_MACHINE=virt' >> $GITHUB_ENV | |
echo 'QEMU_CPU=cortex-a72' >> $GITHUB_ENV | |
- if: matrix.arch == 'ppc64le' | |
run: | | |
echo 'MAKE_ARCH=ARCH=powerpc' >> $GITHUB_ENV | |
echo 'MAKE_CROSS_COMPILE=CROSS_COMPILE=powerpc64le-linux-gnu-' >> $GITHUB_ENV | |
echo 'IMAGE_PATH=vmlinux' >> $GITHUB_ENV | |
echo 'QEMU_ARCH=ppc64' >> $GITHUB_ENV | |
echo 'QEMU_MACHINE=pseries' >> $GITHUB_ENV | |
echo 'QEMU_CPU=POWER9' >> $GITHUB_ENV | |
- if: matrix.arch == 'arm' | |
run: | | |
echo 'MAKE_ARCH=ARCH=arm' >> $GITHUB_ENV | |
echo 'MAKE_CROSS_COMPILE=CROSS_COMPILE=arm-linux-gnueabi-' >> $GITHUB_ENV | |
echo 'IMAGE_PATH=arch/arm/boot/zImage' >> $GITHUB_ENV | |
echo 'QEMU_ARCH=arm' >> $GITHUB_ENV | |
echo 'QEMU_MACHINE=virt' >> $GITHUB_ENV | |
echo 'QEMU_CPU=cortex-a7' >> $GITHUB_ENV | |
- if: matrix.arch == 'riscv64' | |
run: | | |
echo 'MAKE_ARCH=ARCH=riscv' >> $GITHUB_ENV | |
echo 'MAKE_CROSS_COMPILE=CROSS_COMPILE=riscv64-linux-gnu-' >> $GITHUB_ENV | |
echo 'IMAGE_PATH=arch/riscv/boot/Image' >> $GITHUB_ENV | |
echo 'QEMU_ARCH=riscv64' >> $GITHUB_ENV | |
echo 'QEMU_MACHINE=virt' >> $GITHUB_ENV | |
echo 'QEMU_CPU=rv64' >> $GITHUB_ENV | |
echo 'QEMU_ARGS=-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf' >> $GITHUB_ENV | |
- if: matrix.toolchain == 'clang' | |
run: echo 'MAKE_TOOLCHAIN=CC=clang-13' >> $GITHUB_ENV | |
- if: matrix.toolchain == 'llvm' | |
run: echo 'MAKE_TOOLCHAIN=LLVM=1' >> $GITHUB_ENV | |
- if: matrix.output == 'build' | |
run: | | |
echo 'MAKE_OUTPUT=O=build' >> $GITHUB_ENV | |
echo 'BUILD_DIR=build/' >> $GITHUB_ENV | |
- if: matrix.sysroot == 'custom' | |
run: | | |
echo 'RUSTC_SYSROOT=--sysroot=$HOME/sysroot' >> $GITHUB_ENV | |
echo "MAKE_SYSROOT=KRUSTFLAGS=--sysroot=$HOME/sysroot" >> $GITHUB_ENV | |
# Setup: custom pre-built binaries folder | |
- run: | | |
mkdir bin | |
echo $(pwd)/bin >> $GITHUB_PATH | |
# Setup: LLVM | |
# - run: curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | |
# Retry to be resilient to intermittent network issues | |
# - run: | | |
# add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' || | |
# add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' || | |
# add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' | |
# - run: apt-get update -y | |
# - run: apt-get install -y llvm-12 clang-12 lld-12 | |
- run: echo $(llvm-config-13 --bindir) >> $GITHUB_PATH | |
# Setup: GCC | |
- if: matrix.arch == 'arm' | |
run: apt-get install -y gcc-arm-linux-gnueabi lzop | |
# - if: matrix.arch == 'arm64' | |
# run: apt-get install -y gcc-aarch64-linux-gnu | |
- if: matrix.arch == 'ppc64le' | |
run: apt-get install -y gcc-powerpc64le-linux-gnu | |
- if: matrix.arch == 'riscv64' | |
run: apt-get install -y gcc-riscv64-linux-gnu | |
# Setup OpenSBI | |
- if: matrix.arch == 'riscv64' | |
run: apt-get install -y opensbi | |
# Setup: libelf | |
# - run: apt-get install -y libelf-dev | |
# Setup: QEMU | |
- if: matrix.arch == 'x86_64' | |
run: apt-get install -y qemu-system-x86 | |
# - if: matrix.arch == 'arm' || matrix.arch == 'arm64' | |
# run: apt-get install -y qemu-system-arm | |
- if: matrix.arch == 'ppc64le' | |
run: apt-get install -y qemu-system-ppc | |
- if: matrix.arch == 'riscv64' | |
run: | | |
curl -o bin/qemu-system-riscv64 https://raw.githubusercontent.com/Rust-for-Linux/ci-bin/master/qemu-6.0.0/bin/qemu-system-riscv64 | |
chmod u+x bin/qemu-system-riscv64 | |
# Setup: rustc | |
- if: matrix.install == 'rustup' | |
run: | | |
rustup default ${{ matrix.rustc }} | |
rustup component add rustfmt | |
- if: matrix.install == 'standalone' | |
run: | | |
curl https://static.rust-lang.org/dist/rust-${{ matrix.rustc }}-x86_64-unknown-linux-gnu.tar.gz | tar xz | |
rust-${{ matrix.rustc }}-x86_64-unknown-linux-gnu/install.sh --without=rust-docs --prefix=$HOME/rustc | |
echo $HOME/rustc/bin >> $GITHUB_PATH | |
# Setup: rustc native libs | |
- if: matrix.sysroot == 'custom' | |
run: | | |
mkdir $(rustc ${{ env.RUSTC_SYSROOT }} --print sysroot) | |
ln -s $(rustc --print sysroot)/lib $(rustc ${{ env.RUSTC_SYSROOT }} --print sysroot)/lib | |
# Setup: rustc source | |
- if: matrix.install == 'rustup' && matrix.sysroot == 'common' | |
run: rustup component add rust-src | |
- if: matrix.install != 'rustup' || matrix.sysroot != 'common' | |
run: | | |
git clone -n https://github.com/rust-lang/rust $(rustc ${{ env.RUSTC_SYSROOT }} --print sysroot)/lib/rustlib/src/rust | |
cd $(rustc ${{ env.RUSTC_SYSROOT }} --print sysroot)/lib/rustlib/src/rust | |
git checkout $(rustc -vV | grep -F 'commit-hash' | awk '{print $2}') | |
git submodule update --init library | |
# Setup: clippy | |
- run: rustup component add clippy | |
# Setup: bindgen | |
# - run: | | |
# curl -o bin/bindgen https://raw.githubusercontent.com/Rust-for-Linux/ci-bin/master/bindgen-0.56.0/bin/bindgen | |
# chmod u+x bin/bindgen | |
# Setup: ccache | |
- run: | | |
# apt-get install ccache | |
echo '/usr/lib/ccache:$PATH' >> $GITHUB_PATH | |
echo 'CCACHE_COMPRESS=true' >> $GITHUB_ENV | |
# Setup: Check existing ccache | |
- run: ccache -s | |
# Setup: busybox | |
# - run: git clone --depth 1 -b 1_30_1 https://github.com/mirror/busybox | |
- run: cp -r /busybox ./ | |
- run: mv .github/workflows/busybox.config busybox/.config | |
- run: cd busybox && make ${{ env.MAKE_CROSS_COMPILE }} -j3 | |
# Setup: module parameters test | |
- run: | | |
cp samples/rust/rust_module_parameters.rs samples/rust/rust_module_parameters_builtin_default.rs | |
cp samples/rust/rust_module_parameters.rs samples/rust/rust_module_parameters_builtin_custom.rs | |
cp samples/rust/rust_module_parameters.rs samples/rust/rust_module_parameters_loadable_default.rs | |
cp samples/rust/rust_module_parameters.rs samples/rust/rust_module_parameters_loadable_custom.rs | |
sed -i 's:rust_module_parameters:rust_module_parameters_builtin_default:g' samples/rust/rust_module_parameters_builtin_default.rs | |
sed -i 's:rust_module_parameters:rust_module_parameters_builtin_custom:g' samples/rust/rust_module_parameters_builtin_custom.rs | |
sed -i 's:rust_module_parameters:rust_module_parameters_loadable_default:g' samples/rust/rust_module_parameters_loadable_default.rs | |
sed -i 's:rust_module_parameters:rust_module_parameters_loadable_custom:g' samples/rust/rust_module_parameters_loadable_custom.rs | |
echo 'obj-y += rust_module_parameters_builtin_default.o' >> samples/rust/Makefile | |
echo 'obj-y += rust_module_parameters_builtin_custom.o' >> samples/rust/Makefile | |
echo 'obj-m += rust_module_parameters_loadable_default.o' >> samples/rust/Makefile | |
echo 'obj-m += rust_module_parameters_loadable_custom.o' >> samples/rust/Makefile | |
# Pre-check | |
- run: make LLVM=1 rustfmtcheck | |
# Build | |
- run: mv .github/workflows/kernel-${{ matrix.arch }}-${{ matrix.config }}.config .config | |
- if: matrix.output == 'build' | |
run: | | |
mkdir ${{ env.BUILD_DIR }} | |
mv .config ${{ env.BUILD_DIR }}.config | |
sed -i 's:samples/rust/:${{ env.BUILD_DIR }}samples/rust/:' .github/workflows/qemu-initramfs.desc | |
- run: make ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_SYSROOT }} -j30 | |
# Run | |
- run: ${{ env.BUILD_DIR }}usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img | |
- run: | | |
qemu-system-${{ env.QEMU_ARCH }} \ | |
${{ env.QEMU_ARGS }} \ | |
-kernel ${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} \ | |
-initrd qemu-initramfs.img \ | |
-M ${{ env.QEMU_MACHINE }} \ | |
-cpu ${{ env.QEMU_CPU }} \ | |
-smp 1 \ | |
-nographic \ | |
-vga none \ | |
-no-reboot \ | |
-append '${{ env.QEMU_APPEND }} \ | |
rust_module_parameters_builtin_custom.my_bool=n \ | |
rust_module_parameters_builtin_custom.my_i32=345543 \ | |
rust_module_parameters_builtin_custom.my_str=🦀mod \ | |
rust_module_parameters_builtin_custom.my_usize=84 \ | |
rust_module_parameters_builtin_custom.my_array=1,2,3 \ | |
' \ | |
| sed s:$'\r'$:: \ | |
| tee qemu-stdout.log | |
# The kernel should not be generating any warnings | |
- run: | | |
! grep -v 'at mm/debug_vm_pgtable.c:' qemu-stdout.log | grep '] WARNING:' | |
# Check | |
- run: | | |
grep '] rust_minimal: Rust minimal sample (init)$' qemu-stdout.log | |
grep '] rust_minimal: Am I built-in? false$' qemu-stdout.log | |
grep '] rust_minimal: My message is on the heap!$' qemu-stdout.log | |
grep '] rust_minimal: Rust minimal sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_print: Rust printing macros sample (init)$' qemu-stdout.log | |
grep '] rust_print: Emergency message (level 0) without args$' qemu-stdout.log | |
grep '] rust_print: Alert message (level 1) without args$' qemu-stdout.log | |
grep '] rust_print: Critical message (level 2) without args$' qemu-stdout.log | |
grep '] rust_print: Error message (level 3) without args$' qemu-stdout.log | |
grep '] rust_print: Warning message (level 4) without args$' qemu-stdout.log | |
grep '] rust_print: Notice message (level 5) without args$' qemu-stdout.log | |
grep '] rust_print: Info message (level 6) without args$' qemu-stdout.log | |
grep '] rust_print: A line that is continued without args$' qemu-stdout.log | |
grep '] rust_print: Emergency message (level 0) with args$' qemu-stdout.log | |
grep '] rust_print: Alert message (level 1) with args$' qemu-stdout.log | |
grep '] rust_print: Critical message (level 2) with args$' qemu-stdout.log | |
grep '] rust_print: Error message (level 3) with args$' qemu-stdout.log | |
grep '] rust_print: Warning message (level 4) with args$' qemu-stdout.log | |
grep '] rust_print: Notice message (level 5) with args$' qemu-stdout.log | |
grep '] rust_print: Info message (level 6) with args$' qemu-stdout.log | |
grep '] rust_print: A line that is continued with args$' qemu-stdout.log | |
grep '] rust_print: Rust printing macros sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_module_parameters_builtin_default: Rust module parameters sample (init)' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_default: my_bool: true$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_default: my_i32: 42$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_default: my_str: default str val$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_default: my_usize: 42$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_default: my_array: \[0, 1]$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: Rust module parameters sample (init)$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: my_bool: false$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: my_i32: 345543$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: my_str: 🦀mod$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: my_usize: 84$' qemu-stdout.log | |
grep '] rust_module_parameters_builtin_custom: my_array: \[1, 2, 3]$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: Rust module parameters sample (init)$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: my_bool: true$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: my_i32: 42$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: my_str: default str val$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: my_usize: 42$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: my_array: \[0, 1]$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_default: Rust module parameters sample (exit)$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: Rust module parameters sample (init)$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: my_bool: false$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: my_i32: 345543$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: my_str: 🦀mod$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: my_usize: 84$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: my_array: \[1, 2, 3]$' qemu-stdout.log | |
grep '] rust_module_parameters_loadable_custom: Rust module parameters sample (exit)$' qemu-stdout.log | |
grep '] rust_module_parameters: Rust module parameters sample (init)$' qemu-stdout.log | |
grep '] rust_module_parameters: my_bool: true$' qemu-stdout.log | |
grep '] rust_module_parameters: my_i32: 42$' qemu-stdout.log | |
grep '] rust_module_parameters: my_str: default str val$' qemu-stdout.log | |
grep '] rust_module_parameters: my_usize: 42$' qemu-stdout.log | |
grep '] rust_module_parameters: my_array: \[0, 1]$' qemu-stdout.log | |
grep '] rust_module_parameters: Rust module parameters sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_sync: Rust synchronisation primitives sample (init)$' qemu-stdout.log | |
grep '] rust_sync: Value: 10$' qemu-stdout.log | |
grep '] rust_sync: Rust synchronisation primitives sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_chrdev: Rust character device sample (init)$' qemu-stdout.log | |
grep '] rust_chrdev: Rust character device sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_miscdev: Rust miscellaneous device sample (init)$' qemu-stdout.log | |
grep '] rust_miscdev: Rust miscellaneous device sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_stack_probing: Rust stack probing sample (init)$' qemu-stdout.log | |
grep '] rust_stack_probing: Large array has length: 514$' qemu-stdout.log | |
grep '] rust_stack_probing: Rust stack probing sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_semaphore: Rust semaphore sample (init)$' qemu-stdout.log | |
grep '] rust_semaphore: Rust semaphore sample (exit)$' qemu-stdout.log | |
- run: | | |
grep '] rust_semaphore_c: Rust semaphore sample (in C, for comparison) (init)$' qemu-stdout.log | |
grep '] rust_semaphore_c: Rust semaphore sample (in C, for comparison) (exit)$' qemu-stdout.log | |
# Report | |
- run: | | |
ls -l \ | |
${{ env.BUILD_DIR }}samples/rust/*.o \ | |
${{ env.BUILD_DIR }}samples/rust/*.ko \ | |
${{ env.BUILD_DIR }}drivers/android/rust_binder.o \ | |
${{ env.BUILD_DIR }}rust/*.o \ | |
${{ env.BUILD_DIR }}vmlinux \ | |
${{ env.BUILD_DIR }}${{ env.IMAGE_PATH }} | |
size \ | |
${{ env.BUILD_DIR }}samples/rust/*.o \ | |
${{ env.BUILD_DIR }}samples/rust/*.ko \ | |
${{ env.BUILD_DIR }}drivers/android/rust_binder.o \ | |
${{ env.BUILD_DIR }}rust/*.o \ | |
${{ env.BUILD_DIR }}vmlinux | |
# # Clippy | |
# - run: make ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_SYSROOT }} -j3 CLIPPY=1 | |
# # Docs | |
# - run: make ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_SYSROOT }} -j3 rustdoc | |
# # Tests | |
# - run: make ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_SYSROOT }} -j3 rusttest | |
# # Formatting | |
# - run: make ${{ env.MAKE_ARCH }} ${{ env.MAKE_CROSS_COMPILE }} ${{ env.MAKE_TOOLCHAIN }} ${{ env.MAKE_OUTPUT }} ${{ env.MAKE_SYSROOT }} -j3 rustfmtcheck | |
# View changes to ccache | |
- run: ccache -s | |
concurrency: | |
group: ${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true |