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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Linmo CI (GNU Only)

on:
push:
branches: [main, ci]
pull_request:
branches: [main, ci]

jobs:
test:
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential qemu-system-riscv32 wget

- name: Download RISC-V GNU Toolchain
run: |
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
Comment on lines +24 to +25
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.

echo "$PWD/riscv/bin" >> $GITHUB_PATH

- name: Verify toolchain installation
run: |
riscv32-unknown-elf-gcc --version
qemu-system-riscv32 --version
env:
CROSS_COMPILE: riscv32-unknown-elf-

- name: Build Linmo kernel
run: |
make clean
make
env:
CROSS_COMPILE: riscv32-unknown-elf-

- name: Build and run cpubench
run: |
make clean
make cpubench
set +e
timeout 5s qemu-system-riscv32 -nographic -machine virt -bios none -kernel build/image.elf | tee qemu_output.txt
echo "cpubench completed" >> qemu_output.txt
set -e
env:
CROSS_COMPILE: riscv32-unknown-elf-

- name: Extract benchmark result
id: extract
run: |
grep -E "Result:|Elapsed time" qemu_output.txt > result.txt || echo "Result not found" > result.txt
echo "result<<EOF" >> $GITHUB_OUTPUT
cat result.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Comment result to PR
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
✅ **cpubench test result**
```
${{ steps.extract.outputs.result }}
```