Skip to content

Utilize GitHub Actions for building and running via QEMU #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

G36maid
Copy link

@G36maid G36maid commented Jul 4, 2025

This PR introduces a GitHub Actions CI workflow that:

  • Builds the Linmo kernel using the GNU RISC-V toolchain
  • Runs selected apps (hello, cpubench, etc.) via QEMU
  • Extracts and comments test results back to PRs
  • Moves toolchain setup, build logic, and test execution to .ci/ scripts
  • Enhances maintainability and readability of the CI workflow

Features:

  • Supports running multiple apps at once via run-qemu-tests.sh

Limitations:

  • Current test apps are not suitable for general regression testing
    → Need a more standardized test app in future

Fix #2

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase the latest main branch.

@jserv
Copy link
Contributor

jserv commented Jul 4, 2025

There should be only a commit, discarding unrelated ones.

@G36maid
Copy link
Author

G36maid commented Jul 4, 2025

Rebase the latest main branch.

Already.

There should be only a commit, discarding unrelated ones.

Sure.

@jserv

This comment was marked as resolved.

@G36maid

This comment was marked as resolved.

jserv

This comment was marked as duplicate.

@G36maid G36maid requested a review from jserv July 5, 2025 03:37
@G36maid G36maid force-pushed the ci branch 2 times, most recently from 761c4b2 to bdf027c Compare July 5, 2025 03:56
#!/bin/bash
set -e

URL="https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.06.13/riscv32-elf-ubuntu-22.04-gcc-nightly-2025.06.13-nightly.tar.xz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I know the reason why you download ubuntu-22.04 toolchain ?
Since your runner is ubuntu-24.04.

Copy link
Author

@G36maid G36maid Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the same problem while working on LLVM support, so I temporarily included the updated setup-toolchain.sh with LLVM support in this PR.

Please have a look.

@G36maid G36maid force-pushed the ci branch 2 times, most recently from 3839694 to cc104df Compare July 5, 2025 12:02
@G36maid G36maid requested a review from Damien-Chen July 5, 2025 12:28
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carefully read https://cbea.ms/git-commit/ and strictly apply its rules when writing full sentences in commit messages.

Comment on lines 24 to 36
- name: Verify toolchain installation
run: |
riscv32-unknown-elf-gcc --version
qemu-system-riscv32 --version
env:
CROSS_COMPILE: riscv32-unknown-elf-

- name: Build Kernel
run: |
make clean
make
env:
CROSS_COMPILE: riscv32-unknown-elf-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a matrix strategy for both GNU and LLVM toolchains.

Copy link
Author

@G36maid G36maid Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm almost already done, but some build tests failed on LLVM, so I'm trying to find out if it's the makefile/toolchain problem or the kernel itself.

Copy link
Author

@G36maid G36maid Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is the latest run: https://github.com/G36maid/linmo/actions/runs/16087958296
you can see

   CC	build/kernel/pipe.o
kernel/pipe.c:37:20: error: unused function 'pipe_get_byte' [-Werror,-Wunused-function]
   37 | static inline char pipe_get_byte(pipe_t *p)
      |                    ^~~~~~~~~~~~~
kernel/pipe.c:45:20: error: unused function 'pipe_put_byte' [-Werror,-Wunused-function]
   45 | static inline void pipe_put_byte(pipe_t *p, char c)
      |                    ^~~~~~~~~~~~~
2 errors generated.
make: *** [Makefile:53: build/kernel/pipe.o] Error 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send pull request(s) regarding LLVM compilation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #14

@G36maid G36maid mentioned this pull request Jul 7, 2025
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always rebase properly.

@G36maid
Copy link
Author

G36maid commented Jul 7, 2025

Always rebase properly.

I'll make sure to rebase properly before merging. For now, I prefer to keep the commits.
Once everything is finalized, I'll squash or clean them up as needed.

@G36maid G36maid force-pushed the ci branch 2 times, most recently from f29486c to e792176 Compare July 7, 2025 06:56
This commit introduces initial support for compiling the RISC-V target
using the LLVM toolchain.

Add CI workflow to build and test with QEMU

Introduce GitHub Actions-based CI that builds the kernel using the
GNU RISC-V toolchain and runs selected apps (e.g., cpubench) in QEMU.

Results are extracted and posted to PRs. Toolchain setup, build,
and QEMU test logic are modularized into scripts in .ci/.

Features:
- Support multiple apps per run
- CI comments results on PR automatically
- Timeout prevents hangs

Limitations:
- Currently GNU-only (LLVM WIP)
- cpubench doesn't exit cleanly due to preemptive mode

Fixes: #2
Supersedes: sysprog21#11

Refactor riscv build.mk toolchain selection logic

Add CI workflow for building and testing

Improve CI workflow with QEMU, cpubench, timeout

I notice that the cpu bench will make qemu into Scheduler mode: Preemptive
so the qemu will not stop, add some trick to pass the test(not good)

Refactor CI workflow for improved toolchain usage

Comment out hello build and run step in CI workflow

Update RISC-V toolchain and enable hello build step

Add -bios none to QEMU commands in CI workflow

Remove hello build and run step from CI workflow

Add timeout to QEMU command in CI workflow

Add completion message to cpubench CI step

Allow QEMU step to pass without stopping CI job

ci: refactor QEMU test workflow and extract scripts

The workflow now extracts cpubench results from QEMU output and
automatically comments the result on pull requests.

Improve CI workflow with QEMU, cpubench, timeout

I notice that the cpu bench will make qemu into Scheduler mode: Preemptive
so the qemu will not stop, add some trick to pass the test(not good)

Refactor CI workflow for improved toolchain usage

Comment out hello build and run step in CI workflow

Update RISC-V toolchain and enable hello build step

Add -bios none to QEMU commands in CI workflow

Remove hello build and run step from CI workflow

Add timeout to QEMU command in CI workflow

Add completion message to cpubench CI step

Allow QEMU step to pass without stopping CI job

Fix merge conflict markers in CI workflow file

Use Ubuntu 24.04 in CI workflow

Remove merge conflict markers from error.c

Remove merge conflict markers from error.h

Remove redundant libc.h include from libc.c

Delete libc.c

Add CI scripts and refactor workflow

- Move toolchain setup, build, QEMU run, and result extraction to
dedicated scripts in .ci/ - Update ci.yml to use these scripts for
improved maintainability

Make CI scripts executable

Add flexible test sequencing and CI test suites

  - Replace run-qemu.sh with run-test-sequence.sh for configurable,
  robust test execution (supports timeouts, app lists, output dirs,
  continue-on-failure, and verbosity) - Add run-qemu-tests.sh for simple
  sequential app testing - Add test suite definitions: basic.txt,
  performance.txt, comprehensive.txt - Overhaul extract-result.sh to
  aggregate, summarize, and format results for GitHub Actions and
  artifacts - Update CI workflow to run multiple test suites (basic,
  performance, comprehensive, custom), upload artifacts, and generate a
  consolidated summary - Remove obsolete run-qemu.sh script

Simplify CI test runner and result extraction

Comment PR with benchmark results in CI workflow

Run all basic apps in CI and comment results on PRs

Remove extract-result.sh and update CI to inline test output

Update QEMU tests to run cpubench and test64 only

Inline build steps in CI workflow and remove build.sh

Add LLVM toolchain support to CI and build system

Remove test-summary job from CI workflow

Update toolchain URLs and add CI test summary job

Remove test64 argument from QEMU test script in CI

Refactor toolchain URLs and add LLVM fallback in CI workflow

Set CROSS_COMPILE to riscv32-unknown-elf- in CI setup

Add AR=llvm-ar to LLVM toolchain environment setup

Refactor toolchain URL to use TOOLCHAIN_OS variable

Refactor RISC-V toolchain selection and defaults

Run CI on all branches and pull requests

Add __maybe_unused macro for unused attribute

Use GNU ar instead of llvm-ar for LLVM toolchain

Update toolchain version to verified

Detect Clang toolchain in RISC-V build script
@G36maid
Copy link
Author

G36maid commented Jul 7, 2025

Do these results match what we wanted?
Check this run:

G36maid#6 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable CI via GitHub Actions
3 participants