ci #39
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ main, dev ] | |
| pull_request: | |
| branches: [ main, dev ] | |
| workflow_dispatch: | |
| jobs: | |
| lint-and-license: | |
| name: Linter & License Check | |
| runs-on: ubuntu-22.04 | |
| container: ghcr.io/jaxtonmax/hvisor-ci:22.04_pro | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Format Check | |
| run: make fmt-test | |
| - name: License Check | |
| run: ./tools/license_checker.sh | |
| unittest: | |
| name: Unittest | |
| runs-on: ubuntu-22.04 | |
| container: ghcr.io/jaxtonmax/hvisor-ci:22.04_pro | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { arch: aarch64, board: "qemu-gicv3" } | |
| - { arch: aarch64, board: "qemu-gicv2" } | |
| - { arch: riscv64, board: "qemu-plic" } | |
| - { arch: riscv64, board: "qemu-aia" } | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up environment variables | |
| run: | | |
| echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
| echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV | |
| - name: Run Unit Test | |
| run: make test | |
| build: | |
| name: Build All Targets | |
| runs-on: ubuntu-22.04 | |
| container: ghcr.io/jaxtonmax/hvisor-ci:22.04_pro | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { arch: aarch64, board: "qemu-gicv3" } | |
| - { arch: aarch64, board: "qemu-gicv2" } | |
| - { arch: aarch64, board: "zcu102" } | |
| - { arch: aarch64, board: "imx8mp" } | |
| - { arch: aarch64, board: "rk3568" } | |
| - { arch: aarch64, board: "rk3588" } | |
| - { arch: aarch64, board: "ok6254-c" } | |
| - { arch: riscv64, board: "qemu-aia" } | |
| - { arch: riscv64, board: "qemu-plic" } | |
| - { arch: loongarch64, board: "ls3a5000" } | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Cache and Install LoongArch Toolchain | |
| if: matrix.arch == 'loongarch64' | |
| uses: actions/cache@v4 | |
| with: | |
| path: /opt/loongarch-toolchain | |
| key: ${{ runner.os }}-loongarch-toolchain-v8.0 | |
| - name: Download LoongArch Toolchain if not cached | |
| if: matrix.arch == 'loongarch64' && steps.cache-loongarch.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p /opt/loongarch-toolchain | |
| wget -qO- https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/8.0/loongarch64-clfs-8.0-cross-tools-gcc-full.tar.xz | tar -xJ -C /opt/loongarch-toolchain | |
| - name: Add LoongArch Toolchain to PATH | |
| if: matrix.arch == 'loongarch64' | |
| run: echo "/opt/loongarch-toolchain/cross-tools/bin" >> $GITHUB_PATH | |
| - name: Set up environment variables | |
| run: | | |
| echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
| echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV | |
| - name: Build | |
| run: make | |
| systemtest: | |
| name: Systemtest | |
| runs-on: ubuntu-22.04 | |
| container: | |
| image: ghcr.io/jaxtonmax/hvisor-ci:22.04_pro | |
| options: --cap-add=SYS_ADMIN --privileged | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { arch: aarch64, board: "qemu-gicv3" } | |
| - { arch: riscv64, board: "qemu-plic" } | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Set up environment variables | |
| run: | | |
| echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
| echo "BOARD=${{ matrix.board }}" >> $GITHUB_ENV | |
| - name: Clone and Build hvisor-tool in an Isolated Environment | |
| run: | | |
| echo "--- Cloning and building hvisor-tool for ${{ matrix.arch }} ---" | |
| # 1. 定义 hvisor-tool 应该被克隆到的目录 | |
| VIRDISK_DIR="${{ github.workspace }}/platform/${{ matrix.arch }}/${{ matrix.board }}/image/virtdisk" | |
| # 2. (关键修复) 确保目标目录存在,再进入它 | |
| echo "Ensuring directory exists: ${VIRDISK_DIR}" | |
| mkdir -p "${VIRDISK_DIR}" | |
| cd "${VIRDISK_DIR}" | |
| # 3. 克隆 hvisor-tool 仓库 | |
| echo "Cloning hvisor-tool into the current directory" | |
| git clone https://github.com/syswonder/hvisor-tool.git | |
| # 4. 定义 hvisor-tool 内部的 'tools' 目录的完整路径 | |
| HVISOR_TOOL_TOOLS_DIR="${VIRDISK_DIR}/hvisor-tool/tools" | |
| # 5. 确定传递给 Makefile 的架构参数 | |
| MAKE_ARCH="" | |
| if [ "${{ matrix.arch }}" = "aarch64" ]; then | |
| MAKE_ARCH="arm64" | |
| elif [ "${{ matrix.arch }}" = "riscv64" ]; then | |
| MAKE_ARCH="riscv" | |
| fi | |
| # 6. 在隔离的环境中执行构建 | |
| echo "Running make in ${HVISOR_TOOL_TOOLS_DIR}" | |
| make -C "${HVISOR_TOOL_TOOLS_DIR}" all ARCH=${MAKE_ARCH} LIBC=gnu | |
| echo "--- hvisor-tool build complete ---" | |
| - name: Run System Test (skipping tool build) | |
| run: | | |
| export SKIP_HVISOR_TOOL_BUILD=true | |
| make stest |