[CI] Modify CI and add workflow call to implement externel test #1586
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build CI | |
on: | |
push: | |
pull_request: | |
workflow_call: | |
inputs: | |
package: | |
description: 'The package that triggers the workflow' | |
required: true | |
type: string | |
ref: | |
description: 'The branch of the main repository' | |
required: false | |
default: 'main' | |
type: string | |
env: | |
prj-repo: "arceos-org/arceos" | |
jobs: | |
clippy: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
rust-toolchain: [nightly, nightly-2024-05-02] | |
env: | |
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} | |
steps: | |
- uses: actions/checkout@v4 | |
if: inputs.package == '' | |
- uses: actions/checkout@v4 | |
if: inputs.package != '' | |
with: | |
repository: ${{ env.prj-repo }} | |
ref: ${{ inputs.ref }} | |
- name: Patch for the commit to be tested | |
if: inputs.package != '' | |
run: | | |
cargo install dependencies-patch | |
dependencies-patch -c . \ | |
-n ${{ inputs.package }} \ | |
-t git --git-repo ${{ github.repository }} \ | |
--commit ${{ github.sha }} | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.rust-toolchain }} | |
components: rust-src, clippy, rustfmt | |
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat | |
- name: Check rust version | |
run: rustc --version --verbose | |
- name: Clippy for the default target | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make clippy | |
- name: Clippy for x86_64 | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make clippy ARCH=x86_64 | |
- name: Clippy for riscv64 | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make clippy ARCH=riscv64 | |
- name: Clippy for aarch64 | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make clippy ARCH=aarch64 | |
- name: Check code format | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: cargo fmt --all -- --check | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
arch: [x86_64, riscv64, aarch64] | |
rust-toolchain: [nightly, nightly-2024-05-02] | |
env: | |
RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} | |
steps: | |
- uses: actions/checkout@v4 | |
if: inputs.package == '' | |
- uses: actions/checkout@v4 | |
if: inputs.package != '' | |
with: | |
repository: ${{ env.prj-repo }} | |
ref: ${{ inputs.ref }} | |
- name: Patch for the commit to be tested | |
if: inputs.package != '' | |
run: | | |
cargo install dependencies-patch | |
dependencies-patch -c . \ | |
-n ${{ inputs.package }} \ | |
-t git --git-repo ${{ github.repository }} \ | |
--commit ${{ github.sha }} | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.rust-toolchain }} | |
components: rust-src, llvm-tools | |
targets: x86_64-unknown-none, riscv64gc-unknown-none-elf, aarch64-unknown-none, aarch64-unknown-none-softfloat | |
- uses: Swatinem/rust-cache@v2 | |
- run: cargo install cargo-binutils | |
- name: Build helloworld | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/helloworld | |
- name: Build httpclient | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/httpclient | |
- name: Build httpserver | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/httpserver | |
- name: Build shell | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/shell | |
- uses: ./.github/workflows/actions/setup-musl | |
with: | |
arch: ${{ matrix.arch }} | |
- name: Build helloworld-c | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/helloworld-c | |
- name: Build httpclient-c | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/httpclient-c | |
- name: Build httpserver-c | |
continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} | |
run: make ARCH=${{ matrix.arch }} A=examples/httpserver-c | |