Add RISC-V build CI

This commit is contained in:
Zejun Zhao 2025-04-06 21:26:16 +08:00 committed by Tate, Hongliang Tian
parent 3aa1079ca6
commit 1c881d30f6
7 changed files with 48 additions and 11 deletions

View File

@ -30,6 +30,9 @@ inputs:
required: false
# Test Parameters
arch:
description: 'Architecture (x86_64/riscv64)'
required: false
extra_blocklists:
description: 'Extra blocklists directories'
required: false
@ -59,16 +62,16 @@ runs:
if: ${{ inputs.auto_test == 'general' }}
shell: bash
run: |
if [[ "${{ matrix.id }}" == "lint" ]]; then
make check
elif [[ "${{ matrix.id }}" == "compile" ]]; then
make build FEATURES=all
elif [[ "${{ matrix.id }}" == "usermode_test" ]]; then
make test
elif [[ "${{ matrix.id }}" == "ktest" ]]; then
make ktest NETDEV=tap
fi
CMD=""
[[ "${{ matrix.id }}" == "lint" ]] && CMD+="make check"
[[ "${{ matrix.id }}" == "compile" ]] && CMD+="make build FEATURES=all"
[[ "${{ matrix.id }}" == "usermode_test" ]] && CMD+="make test"
[[ "${{ matrix.id }}" == "ktest" ]] && CMD+="make ktest NETDEV=tap"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
echo "Executing: $CMD"
eval $CMD
- name: Run integration test
if: ${{ !(inputs.auto_test == 'general' || inputs.auto_test == 'osdk') }}
shell: bash
@ -80,6 +83,7 @@ runs:
[[ -n "${{ inputs.smp }}" ]] && CMD+=" SMP=${{ inputs.smp }}"
[[ -n "${{ inputs.netdev }}" ]] && CMD+=" NETDEV=${{ inputs.netdev }}"
[[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}"
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
[[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}"
[[ -n "${{ inputs.syscall_test_dir }}" ]] && CMD+=" SYSCALL_TEST_DIR=${{ inputs.syscall_test_dir }}"
[[ -n "${{ inputs.boot_protocol }}" ]] && CMD+=" BOOT_PROTOCOL=${{ inputs.boot_protocol }}"

27
.github/workflows/test_riscv.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: "Test riscv64 "
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
basic-test:
runs-on: ubuntu-latest
container:
image: asterinas/asterinas:0.14.1-20250326
options: --device=/dev/kvm --privileged
strategy:
matrix:
id: ['lint', 'compile']
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Run basic tests
uses: ./.github/actions/test
with:
auto_test: 'general'
runs_on: 'ubuntu-latest'
arch: 'riscv64'

View File

@ -289,6 +289,7 @@ format:
@$(MAKE) --no-print-directory -C test format
.PHONY: check
# FIXME: Make `make check` arch-aware.
check: initramfs $(CARGO_OSDK)
@./tools/format_all.sh --check # Check Rust format issues
@# Check if STD_CRATES and NOSTD_CRATES combined is the same as all workspace members

View File

@ -2,6 +2,7 @@
<img src="docs/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
A secure, fast, and general-purpose OS kernel written in Rust and compatible with Linux<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>

View File

@ -2,6 +2,7 @@
<img src="docs/src/images/logo_cn.svg" alt="asterinas-logo" width="620"><br>
一个安全、快速、通用的操作系统内核使用Rust编写并与Linux兼容<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>

View File

@ -2,6 +2,7 @@
<img src="docs/src/images/logo_en.svg" alt="asterinas-logo" width="620"><br>
安全で高速、汎用的なOSカーネル。Rustで書かれ、Linuxと互換性があります<br/>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86.yml/badge.svg?event=push" alt="Test x86-64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_riscv.yml/badge.svg?event=push" alt="Test riscv64" style="max-width: 100%;"></a>
<a href="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml"><img src="https://github.com/asterinas/asterinas/actions/workflows/test_x86_tdx.yml/badge.svg" alt="Test Intel TDX" style="max-width: 100%;"></a>
<a href="https://asterinas.github.io/benchmark/x86-64/"><img src="https://github.com/asterinas/asterinas/actions/workflows/benchmark_x86.yml/badge.svg" alt="Benchmark x86-64" style="max-width: 100%;"></a>
<br/>

View File

@ -34,7 +34,6 @@ cpio-decoder = { path = "libs/cpio-decoder" }
intrusive-collections = "0.9.5"
paste = "1.0"
time = { version = "0.3", default-features = false, features = ["alloc"] }
tdx-guest = { version = "0.2.1", optional = true }
# parse elf file
xmas-elf = "0.8.0"
@ -62,6 +61,9 @@ cfg-if = "1.0"
# TODO: fork this crate to rewrite all the (unnecessary) unsafe usage
fixed = "1.28.0"
[target.x86_64-unknown-none.dependencies]
tdx-guest = { version = "0.2.1", optional = true }
[target.riscv64gc-unknown-none-elf.dependencies]
riscv = { version = "0.11.1", features = ["s-mode"] }