Skip to content

Commit

Permalink
Added github CI test
Browse files Browse the repository at this point in the history
  • Loading branch information
elliott10 committed Apr 19, 2024
1 parent eb81359 commit cc0cdf5
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/actions/setup-musl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Download musl toolchain

inputs:
arch:
description: 'Architecture'
required: true
type: string

runs:
using: "composite"
steps:
- name: Cache musl
id: cache-musl
uses: actions/cache/restore@v3
with:
path: ${{ inputs.arch }}-linux-musl-cross
key: ${{ inputs.arch }}-linux-musl-cross
- name: Download musl toolchain
if: steps.cache-musl.outputs.cache-hit != 'true'
shell: bash
run: |
MUSL_PATH=${{ inputs.arch }}-linux-musl-cross
wget https://musl.cc/${MUSL_PATH}.tgz
tar -xf ${MUSL_PATH}.tgz
- uses: actions/cache/save@v3
if: steps.cache-musl.outputs.cache-hit != 'true'
with:
path: ${{ inputs.arch }}-linux-musl-cross
key: ${{ inputs.arch }}-linux-musl-cross

- name: Add to PATH environment variable
shell: bash
run: |
echo "$PWD/${{ inputs.arch }}-linux-musl-cross/bin" >> $GITHUB_PATH
- name: Verify installation
shell: bash
run: |
${{ inputs.arch }}-linux-musl-gcc --version
46 changes: 46 additions & 0 deletions .github/workflows/actions/setup-qemu/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Download and build QEMU

inputs:
qemu-version:
description: 'QEMU version'
required: true
type: string

runs:
using: "composite"
steps:
- name: Cache QEMU
id: cache-qemu
uses: actions/cache/restore@v3
with:
path: qemu_build
key: qemu-${{ inputs.qemu-version }}-slirp-1
- name: Download and build QEMU
if: steps.cache-qemu.outputs.cache-hit != 'true'
env:
QEMU_PATH: qemu-${{ inputs.qemu-version }}
PREFIX: ${{ github.workspace }}/qemu_build
shell: bash
run: |
sudo apt-get update && sudo apt-get install -y ninja-build libslirp-dev
wget https://download.qemu.org/$QEMU_PATH.tar.xz && tar -xJf $QEMU_PATH.tar.xz
cd $QEMU_PATH \
&& ./configure --prefix=$PREFIX --target-list=x86_64-softmmu,riscv64-softmmu,aarch64-softmmu --enable-slirp \
&& make -j > /dev/null 2>&1 \
&& make install
- uses: actions/cache/save@v3
if: steps.cache-qemu.outputs.cache-hit != 'true'
with:
path: qemu_build
key: qemu-${{ inputs.qemu-version }}-slirp-1

- name: Install QEMU
shell: bash
run: |
echo "$PWD/qemu_build/bin" >> $GITHUB_PATH
- name: Verify installation
shell: bash
run: |
qemu-system-x86_64 --version
qemu-system-aarch64 --version
qemu-system-riscv64 --version
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build CI

on: [push, pull_request]

jobs:

build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [riscv64]
rust-toolchain: [nightly]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true

- uses: ./.github/workflows/actions/setup-musl
with:
arch: ${{ matrix.arch }}
- name: Build ${{ github.repository }}
run: |
rustup target add riscv64gc-unknown-none-elf
cargo build -vv --target riscv64gc-unknown-none-elf
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test CI

on: [push, pull_request]

env:
qemu-version: 8.2.0
rust-toolchain: nightly-2024-01-31

jobs:

examples-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [riscv64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
- uses: ./.github/workflows/actions/setup-musl
with:
arch: ${{ matrix.arch }}
- name: Run examples
run: |
cd examples
make run

0 comments on commit cc0cdf5

Please sign in to comment.