Skip to content

Utilize GitHub Actions for building and running via QEMU #11

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

Closed
wants to merge 6 commits into from

Conversation

G36maid
Copy link

@G36maid G36maid commented Jul 4, 2025

Fixes #2

This PR introduces a GitHub Actions CI workflow that:

  • Builds the Linmo kernel using the GNU RISC-V toolchain
  • Runs the cpubench application under QEMU
  • Extracts benchmark output (e.g., Result / Elapsed Time)
  • Automatically comments the result on PRs via GitHub Action bot

Sample output from a successful CI run:
Preview: G36maid#1

Notes

  • cpubench enters preemptive mode after benchmark completion, causing it to continue running tasks indefinitely.
    To ensure QEMU terminates in CI, I used a timeout 5s wrapper.
  • Just use this trick to avoid the ci keep running

Ongoing Work

  • I am currently working on a shell script runner that can test multiple applications (e.g., hello, cpubench, etc.) in sequence.
  • I plan to expand the workflow to support the LLVM toolchain via matrix across toolchains and apps.

This is just a prototype implementation.
Feel free to comment, suggest improvements, or advertise what kinds of test is needed.

jserv

This comment was marked as duplicate.

@jserv jserv changed the title Add GitHub Actions CI for building and running cpubench via QEMU Utilize GitHub Actions for building and running via QEMU Jul 4, 2025
G36maid and others added 5 commits July 4, 2025 11:03
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
The error_desc array and the perror pointer are never modified after
initialization. Marking them as const moves the data to the read-only
section, improving safety.

Before:
$ riscv-none-elf-size ./build/kernel/error.o
   text    data     bss     dec     hex filename
    398     172       0     570     23a ./build/kernel/error.o

After:
$ riscv-none-elf-size ./build/kernel/error.o
   text    data     bss     dec     hex filename
    570       0       0     570     23a ./build/kernel/error.o
strlen() returns the length of the input string,
which is always non‑negative.
Switching the return type to size_t is more accurately.
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.

wget 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
tar -xf 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.

Move to dedicated scripts. See https://github.com/sysprog21/rv32emu/tree/master/.ci for reference.

Copy link
Author

Choose a reason for hiding this comment

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

Do you prefer keeping the scripts in a .ci/ directory (as in rv32emu),
or splitting them into a more general scripts/ directory for better reuse —
for example, by developers who want to build and run the kernel locally?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you prefer keeping the scripts in a .ci/ directory (as in rv32emu), or splitting them into a more general scripts/ directory for better reuse — for example, by developers who want to build and run the kernel locally?

All CI-specific scripts should be placed in the .ci directory, as they are not intended for general use.

Copy link
Author

Choose a reason for hiding this comment

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

I got it.

@G36maid G36maid marked this pull request as draft July 4, 2025 03:18
@jserv
Copy link
Contributor

jserv commented Jul 4, 2025

  • I am currently working on a shell script runner that can test multiple applications (e.g., hello, cpubench, etc.) in sequence.

cpubench might not be an ideal target for testing purposes, as it lacks interleaving and concurrent execution.

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.

Remove lib/libc.c and do git rebase.

@jserv
Copy link
Contributor

jserv commented Jul 4, 2025

Next time, don't submit pull request via main (or default branch).
See https://graphite.dev/blog/pull-request-best-practices

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
@G36maid
Copy link
Author

G36maid commented Jul 4, 2025

Next time, don't submit pull request via main (or default branch). See https://graphite.dev/blog/pull-request-best-practices

Got it.

@G36maid
Copy link
Author

G36maid commented Jul 4, 2025

Marking this PR as a draft while I work on extracting the scripts from the workflow.

Will reopen this PR or open a new one once the improvements are complete.

@G36maid
Copy link
Author

G36maid commented Jul 4, 2025

A new PR is open #12

G36maid added a commit to G36maid/linmo that referenced this pull request Jul 5, 2025
Fixes #2
Improves upon PR sysprog21#11

- Build Linmo kernel using RISC-V GNU toolchain
- Run selected apps (e.g., cpubench) inside QEMU
- Auto-extract test output and post results as PR comments
- Move toolchain setup, build, and QEMU run logic to `.ci/` scripts
- Introduce flexible script-based test sequencing and suite support
- Improve CI maintainability and transparency for contributors

Limitations:
- Current tests (like cpubench) are not designed for full regression testing
- Preemptive mode may stop QEMU exit
- Only supports GNU toolchain for now; LLVM support WIP
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 5, 2025
This commit introduces a GitHub Actions workflow to build the Linmo
kernel using the GNU RISC-V toolchain and run selected applications
(e.g., cpubench) using QEMU.

Test output is extracted from QEMU logs and automatically posted
as a comment to pull requests. Toolchain setup, kernel build, and
QEMU test execution have been modularized into reusable scripts
under the `.ci/` directory.

Features:
- CI supports running multiple apps in a single job
- All QEMU runs are time-limited to prevent hangs
- Results are reported directly to GitHub PRs

Limitations:
- Only GNU toolchain is supported (LLVM is a work in progress)
- Some test apps (e.g., cpubench) do not exit cleanly due to
  entering preemptive scheduler mode

Fixes: #2
Supersedes: sysprog21#11
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 5, 2025
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
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 5, 2025
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
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 7, 2025
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
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 7, 2025
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
G36maid added a commit to G36maid/linmo that referenced this pull request Jul 7, 2025
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
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
4 participants