Skip to content

Commit

Permalink
Test ci (#3)
Browse files Browse the repository at this point in the history
* ci: test ubuntu

* CI: Test update ci

* ci: test ci through archlinux docker

* ci: test ci through docker

* ci: fix ci without toolchain

* ci: add gcc package

* ci: fix ci

* export ci

* ci: test ci

* Install qemu

* ci: update example

* Test ci (#1)

* update Makefile for github CI on loongarch64

* update example/Makefile for github ci

* update Makefile for github CI

* update Makefile for github CI

---------

Co-authored-by: chyyuu <yuchen@tsinghua.edu.cn>

* CI: add time out minutes

* ci: test trigger another repo ci

* ci: change personal_token name

* ci: rename yaml file

* ci: config proper config

* ci: add sha

* ci: update template ci

* ci: install openssl

* ci: install pkgconf

* ci: install cargo-generate through pacman

* ci: install git

* ci: install libgit2

* ci: install cargo generate through cargo

* ci: install openssl and pkgconf

* ci: set path

* fix example

---------

Co-authored-by: chyyuu <chyyuu@users.noreply.github.com>
Co-authored-by: chyyuu <yuchen@tsinghua.edu.cn>
  • Loading branch information
3 people authored May 9, 2024
1 parent 22bc95a commit f152260
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 26 deletions.
95 changes: 75 additions & 20 deletions .github/workflows/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,87 @@ on:
push:

jobs:
build-qemu:
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: sudo apt -y install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
gawk build-essential bison flex texinfo gperf libtool patchutils bc \
zlib1g-dev libexpat-dev pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev libslirp-dev \
git tmux python3 python3-pip ninja-build
- name: Get QEMU Source Code
run: wget https://github.com/qemu/qemu/archive/refs/tags/v9.0.0.tar.gz
- name: extract qemu source code
run: tar zxvf v9.0.0.tar.gz
- name: build qemu 9.0
run: mkdir v9.0.0/build && cd v9.0.0/build && ../configure --target-list=riscv64-softmmu,aarch64-softmmu,x86_64-softmmu,loongarch64-softmmu
- name: make qemu 9.0
run: cd v9.0.0/build && make -j8
# build-qemu:
# runs-on: ubuntu-latest
# steps:
# - run: sudo apt update
# - name: Install dependencies
# run: sudo apt -y install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
# build-essential bison flex texinfo gperf libtool patchutils bc \
# libexpat-dev pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev libslirp-dev \
# tmux python3 python3-pip ninja-build
# - name: Get QEMU Source Code
# run: wget https://github.com/qemu/qemu/archive/refs/tags/v9.0.0.tar.gz
# - name: extract qemu source code
# run: tar zxvf v9.0.0.tar.gz
# - name: build qemu 9.0
# run: mkdir v9.0.0/build && cd v9.0.0/build && ../configure --target-list=riscv64-softmmu,aarch64-softmmu,x86_64-softmmu,loongarch64-softmmu
# - name: make qemu 9.0
# run: cd v9.0.0/build && make -j8

test:
runs-on: ubuntu-20.04
needs: build-qemu
runs-on: ubuntu-latest
container:
image: archlinux:base
volumes:
- .:/code
strategy:
fail-fast: false
matrix:
arch: [x86_64, riscv64, aarch64, loongarch64]
include:
- arch: aarch64
packages: qemu-system-aarch64
- arch: riscv64
packages: qemu-system-riscv
- arch: x86_64
packages: qemu-system-x86
- arch: loongarch64
packages: qemu-system-loongarch64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install generaic tools
run: yes | pacman -Syy make cmake rustup gcc
- name: setup rust toolchain
run: rustup default nightly && cargo install cargo-binutils
- name: Test ${{ matrix.arch }}
run: cd example && make ARCH=${{ matrix.arch }} build
run: cd example && PATH=$PATH:~/.cargo/bin make ARCH=${{ matrix.arch }} build
- name: Install Qemu
run: yes | pacman -Syy ${{ matrix.packages }}
- name: Test run
run: cd example && PATH=$PATH:~/.cargo/bin make ARCH=${{ matrix.arch }} run
timeout-minutes: 1

template:
runs-on: ubuntu-latest
container:
image: archlinux:base
volumes:
- .:/code
strategy:
fail-fast: false
matrix:
arch: [x86_64, riscv64, aarch64, loongarch64]
include:
- arch: aarch64
packages: qemu-system-aarch64
- arch: riscv64
packages: qemu-system-riscv
- arch: x86_64
packages: qemu-system-x86
- arch: loongarch64
packages: qemu-system-loongarch64
steps:
- name: Install generaic tools
run: yes | pacman -Syy make cmake rustup gcc git libgit2 libgit2-glib pkgconf openssl
- name: Install Rust toolchain
run: rustup default stable && cargo install cargo-binutils && cargo install cargo-generate
- name: generate by template
run: USER=test cargo generate --git https://github.com/Byte-OS/polyhal-template.git -n test-polyhal
- name: Install Qemu
run: yes | pacman -Syy ${{ matrix.packages }}
- name: test run
run: cd test-polyhal && (PATH=$PATH:~/.cargo/bin timeout 60 make ARCH=${{ matrix.arch }} run > output.log) || echo "qemu exited!"
timeout-minutes: 2
- name: test log
run: grep "\[kernel\] exited successfully" test-polyhal/output.log
24 changes: 24 additions & 0 deletions .github/workflows/test-extranel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: TestExternal

on:
workflow_dispatch:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: convictional/trigger-workflow-and-wait@v1.6.1
with:
owner: yfblock
repo: rcore-tutorial-v3-with-hal-component
github_token: ${{ secrets.PERSONAL_TOKEN }}
github_user: yfblock
workflow_file_name: test-run.yml
ref: ch7
wait_interval: 10
client_payload: '{"commit": "${{ github.sha}}"}'
propagate_failure: true
trigger_workflow: true
wait_workflow: true
21 changes: 15 additions & 6 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# Building
ARCH := riscv64
QEMU_EXEC := timeout 40


ifeq ($(ARCH), x86_64)
TARGET := x86_64-unknown-none
KERNEL_ELF := target/$(TARGET)/release/example
KERNEL_BIN := $(KERNEL_ELF).bin
QEMU_EXEC += qemu-system-x86_64 \
-machine q35 \
-kernel $(KERNEL_ELF) \
-cpu IvyBridge-v2
BUS := pci
else ifeq ($(ARCH), riscv64)
TARGET := riscv64gc-unknown-none-elf
KERNEL_ELF := target/$(TARGET)/release/example
KERNEL_BIN := $(KERNEL_ELF).bin
QEMU_EXEC += qemu-system-$(ARCH) \
-machine virt \
-kernel $(KERNEL_BIN)
else ifeq ($(ARCH), aarch64)
TARGET := aarch64-unknown-none-softfloat
KERNEL_ELF := target/$(TARGET)/release/example
KERNEL_BIN := $(KERNEL_ELF).bin
QEMU_EXEC += qemu-system-$(ARCH) \
-cpu cortex-a72 \
-machine virt \
-kernel $(KERNEL_BIN)
else ifeq ($(ARCH), loongarch64)
TARGET := loongarch64-unknown-none
KERNEL_ELF := target/$(TARGET)/release/example
KERNEL_BIN := $(KERNEL_ELF).bin
QEMU_EXEC += qemu-system-$(ARCH) -kernel $(KERNEL_ELF)
BUILD_ARGS += -Z build-std=core,alloc
BUS := pci
else
$(error "ARCH" must be one of "x86_64", "riscv64", "aarch64" or "loongarch64")
endif

KERNEL_ELF := target/$(TARGET)/release/example
KERNEL_BIN := $(KERNEL_ELF).bin

# Binutils
OBJDUMP := rust-objdump --arch-name=riscv64
OBJCOPY := rust-objcopy --binary-architecture=riscv64
Expand All @@ -54,15 +62,16 @@ clean:

run: run-inner

QEMU_EXEC += -nographic -smp 1
QEMU_EXEC += -nographic -smp 1 >output.log 2>&1

run-inner: build
$(QEMU_EXEC)
$(QEMU_EXEC) || echo "QEMU exited"
grep "\[kernel\] Hello, world!" output.log

test:
make ARCH=aarch64 run
make ARCH=riscv64 run
make ARCH=x86_64 run
# make ARCH=loongarch64 run
make ARCH=loongarch64 run

.PHONY: build env kernel clean run-inner

0 comments on commit f152260

Please sign in to comment.