From 94bda5a87232c546df722a3e10c8135959cb8f31 Mon Sep 17 00:00:00 2001 From: Youjie Zheng Date: Tue, 14 May 2024 21:20:06 +0800 Subject: [PATCH] chore: update CI script for external test --- .github/workflows/build.yml | 121 +++++++++++++++++++++++++++++++----- .github/workflows/docs.yml | 16 ++--- .github/workflows/test.yml | 60 +++++++++++++++++- 3 files changed, 165 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f17a751..3d19512 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,32 @@ name: Build CI -on: [push, pull_request] - - -env: - rust-toolchain: nightly +on: + push: + pull_request: + workflow_call: + inputs: + TopTestDirectory: + required: true + type: string + jobs: + prepare_for_external_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - id: step1 + if: github.repository != 'Starry-OS/Starry' + # 输出的值可以在后续的job中使用 + run: echo "TopTestDirectory=${{ inputs.TopTestDirectory }}" >> $GITHUB_OUTPUT + - id: step2 + if: github.repository == 'Starry-OS/Starry' + run: echo "ToptTestDirectory=./" >> $GITHUB_OUTPUT + outputs: + TopTestDirectory: ${{ steps.step1.outputs.TopTestDirectory || steps.step2.outputs.TopTestDirectory }} + clippy: + needs: prepare_for_external_test runs-on: ubuntu-latest strategy: fail-fast: false @@ -15,6 +34,7 @@ jobs: rust-toolchain: [nightly, nightly-2024-05-02] env: RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -22,31 +42,30 @@ jobs: 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: Setup C++ environment - run: sudo apt-get update && sudo apt-get install -y build-essential - - uses: ./.github/workflows/actions/setup-musl - with: - arch: x86_64 - - uses: ./.github/workflows/actions/setup-musl - with: - arch: riscv64 - - uses: ./.github/workflows/actions/setup-musl - with: - arch: aarch64 + - name: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} - name: Check rust version + working-directory: ${{ env.WORKING_DIRECTORY }} run: rustc --version --verbose - name: Clippy for the default target + working-directory: ${{ env.WORKING_DIRECTORY }} run: make clippy - name: Clippy for x86_64 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make clippy ARCH=x86_64 - name: Clippy for riscv64 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make clippy ARCH=riscv64 - name: Clippy for aarch64 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make clippy ARCH=aarch64 - name: Check code format + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo fmt --all -- --check build-apps-for-unikernel: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -56,6 +75,7 @@ jobs: rust-toolchain: [nightly, nightly-2024-05-02] env: RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -65,56 +85,85 @@ jobs: 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: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: | + git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} + mkdir .github/workflows/actions + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl - name: Build helloworld + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/helloworld - name: Build memtest + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/memtest - name: Build exception + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/exception - name: Build display + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/display - name: Build task/yield + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/task/yield - name: Build task/parallel + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/task/parallel - name: Build task/sleep + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/task/sleep - name: Build task/priority + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/task/priority - name: Build task/tls + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/task/tls - name: Build fs/shell + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/fs/shell - name: Build net/echoserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/net/echoserver - name: Build net/httpclient + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/net/httpclient - name: Build net/httpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/net/httpserver - name: Build net/udpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/net/udpserver - uses: ./.github/workflows/actions/setup-musl with: arch: ${{ matrix.arch }} - name: Build c/helloworld + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/helloworld - name: Build c/memtest + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/memtest - name: Build c/sqlite3 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/sqlite3 - name: Build c/httpclient + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/httpclient - name: Build c/httpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/httpserver - name: Build c/udpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/udpserver - name: Build c/iperf + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/iperf - name: Build c/redis + working-directory: ${{ env.WORKING_DIRECTORY }} run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4 build-apps-for-other-platforms: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -123,6 +172,7 @@ jobs: rust-toolchain: [nightly, nightly-2024-05-02] env: RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -132,28 +182,42 @@ jobs: 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: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: | + git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} + mkdir .github/workflows/actions + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl - uses: ./.github/workflows/actions/setup-musl with: arch: x86_64 - - name: Build helloworld for x86_64-pc-oslab + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=x86_64-pc-oslab A=apps/helloworld - name: Build net/httpserver for x86_64-pc-oslab + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=x86_64-pc-oslab A=apps/net/httpserver FEATURES=driver-ixgbe - name: Build c/iperf for x86_64-pc-oslab + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=x86_64-pc-oslab A=apps/c/iperf FEATURES=driver-ixgbe,driver-ramdisk - name: Build c/redis for x86_64-pc-oslab + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4 - name: Build helloworld for aarch64-raspi4 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=aarch64-raspi4 A=apps/helloworld - name: Build fs/shell for aarch64-raspi4 + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci - name: Build helloworld for aarch64-bsta1000b + working-directory: ${{ env.WORKING_DIRECTORY }} run: make PLATFORM=aarch64-bsta1000b A=apps/helloworld build-apps-for-std: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -163,39 +227,57 @@ jobs: rust-toolchain: [nightly, nightly-2024-05-02] env: RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust-toolchain }} + - name: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} - name: Build helloworld + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-helloworld - name: Build memtest + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-memtest - name: Build exception + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-exception - name: Build task/yield + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-yield - name: Build task/parallel + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-parallel - name: Build task/sleep + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-sleep - name: Build task/priority + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-priority - name: Build task/tls + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-tls - name: Build fs/shell + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-shell - name: Build net/echoserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-echoserver - name: Build net/httpclient + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-httpclient - name: Build net/httpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-httpserver - name: Build net/udpserver + working-directory: ${{ env.WORKING_DIRECTORY }} run: cargo build -p arceos-udpserver build-apps-for-monolithic: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -205,6 +287,7 @@ jobs: rust-toolchain: [nightly, nightly-2024-05-02] env: RUSTUP_TOOLCHAIN: ${{ matrix.rust-toolchain }} + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -214,7 +297,11 @@ jobs: 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: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} - name: Bulld monolithic-userboot + working-directory: ${{ env.WORKING_DIRECTORY }} run: | sh ./build_img.sh -m ${{ matrix.arch }} make ARCH=${{ matrix.arch }} A=apps/monolithic_userboot diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5b774ef..fdd060d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Build & Deploy docs on: [push, pull_request] env: - rust-toolchain: nightly-2024-05-02 + rust-toolchain: nightly jobs: doc: @@ -15,19 +15,11 @@ jobs: env: default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }} steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 with: + profile: minimal toolchain: ${{ env.rust-toolchain }} - - uses: ./.github/workflows/actions/setup-musl - with: - arch: x86_64 - - uses: ./.github/workflows/actions/setup-musl - with: - arch: riscv64 - - uses: ./.github/workflows/actions/setup-musl - with: - arch: aarch64 - name: Build docs continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }} run: make doc_check_missing diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64e6488..de9f693 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,20 +1,44 @@ name: Test CI -on: [push, pull_request] - - +on: + push: + pull_request: + workflow_call: + inputs: + TopTestDirectory: + required: true + type: string + env: qemu-version: 8.2.0 rust-toolchain: nightly-2024-05-02 jobs: + prepare_for_external_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - id: step1 + if: github.repository != 'Starry-OS/Starry' + # 输出的值可以在后续的job中使用 + run: echo "TopTestDirectory=${{ inputs.TopTestDirectory }}" >> $GITHUB_OUTPUT + - id: step2 + if: github.repository == 'Starry-OS/Starry' + run: echo "ToptTestDirectory=./" >> $GITHUB_OUTPUT + outputs: + TopTestDirectory: ${{ steps.step1.outputs.TopTestDirectory || steps.step2.outputs.TopTestDirectory }} + + app-test-for-unikernel: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] arch: [x86_64, riscv64, aarch64] + env: + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -23,6 +47,13 @@ jobs: components: rust-src - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils + - name: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: | + git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} + mkdir .github/workflows/actions + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu - uses: ./.github/workflows/actions/setup-qemu with: qemu-version: ${{ env.qemu-version }} @@ -30,17 +61,21 @@ jobs: with: arch: ${{ matrix.arch }} - name: Run app tests + working-directory: ${{ env.WORKING_DIRECTORY }} run: | make disk_img make test ARCH=${{ matrix.arch }} app-test-for-monolithic: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] arch: [x86_64, riscv64, aarch64] + env: + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -49,6 +84,13 @@ jobs: components: rust-src - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils + - name: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: | + git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} + mkdir .github/workflows/actions + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu - uses: ./.github/workflows/actions/setup-qemu with: qemu-version: ${{ env.qemu-version }} @@ -56,16 +98,20 @@ jobs: with: arch: ${{ matrix.arch }} - name: Run app tests + working-directory: ${{ env.WORKING_DIRECTORY }} run: | make disk_img make test_monolithic ARCH=${{ matrix.arch }} app-test-for-ext4fs: + needs: prepare_for_external_test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest] arch: [x86_64, riscv64, aarch64] + env: + WORKING_DIRECTORY: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -74,6 +120,13 @@ jobs: components: rust-src - uses: Swatinem/rust-cache@v2 - run: cargo install cargo-binutils + - name: Clone Top Repository + if: github.repository != 'Starry-OS/Starry' + run: | + git clone https://github.com/Starry-OS/Starry.git ${{ env.WORKING_DIRECTORY }} + mkdir .github/workflows/actions + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-musl .github/workflows/actions/setup-musl + mv ${{ env.WORKING_DIRECTORY }}/.github/workflows/actions/setup-qemu .github/workflows/actions/setup-qemu - uses: ./.github/workflows/actions/setup-qemu with: qemu-version: ${{ env.qemu-version }} @@ -81,6 +134,7 @@ jobs: with: arch: ${{ matrix.arch }} - name: Run app tests + working-directory: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} run: | sh ./build_img.sh -m ${{ matrix.arch }} -fs ext4 export MONOLITHIC_TESTCASE=other