Merge pull request #82 from TimLai666/release-0.2.0 #217
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] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # 讓所有 JS actions 在 Node 24 上跑(actions/checkout、cache 等的 Node 20 已棄用)。 | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| lint: | |
| name: lint (fmt + clippy) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| targets: x86_64-unknown-linux-musl | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Format check | |
| run: cargo fmt --all -- --check | |
| # Linux target:涵蓋 guest-agent 的 exec/supervisor 等 cfg(linux) 模組 | |
| - name: Clippy (deny warnings) | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| test: | |
| name: build & test (${{ matrix.os }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build workspace | |
| run: cargo build --workspace --all-targets | |
| - name: Run tests | |
| run: cargo test --workspace | |
| # 每個 OS 各跑一次 clippy,涵蓋平台限定模組(Windows 的 wsl2、macOS 的 vz)。 | |
| - name: Clippy (deny warnings) | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| vz-helper: | |
| name: vz-helper (swiftc compile-check) | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| # 編譯 + ad-hoc 簽章 macOS vz 開機 helper(Swift)。GHA macOS runner 為巢狀虛擬化, | |
| # 開不了 VZ guest,故此處僅 compile-check + 簽章驗證;VM 真正開機需實體 Mac。 | |
| - name: Build + sign chefer-vz-helper | |
| run: bash scripts/build-vz-helper.sh dist | |
| - name: Verify entitlement is present | |
| run: | | |
| codesign -d --entitlements - dist/chefer-vz-helper-* 2>&1 | tee ent.txt | |
| grep -q "com.apple.security.virtualization" ent.txt \ | |
| || { echo "::error::vz helper is missing the virtualization entitlement"; exit 1; } | |
| whp-helper: | |
| name: whp-helper (windows compile-check) | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x86_64-pc-windows-msvc, aarch64-pc-windows-msvc] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: whp-helper-${{ matrix.target }} | |
| - name: Build chefer-whp-helper | |
| run: cargo build --release -p whp-helper --target ${{ matrix.target }} | |
| musl-guest-agent: | |
| name: guest-agent (x86_64 musl static) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Rust (musl target) | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: x86_64-unknown-linux-musl | |
| - name: Install musl tools | |
| run: sudo apt-get update && sudo apt-get install -y musl-tools | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build static guest-agent | |
| run: cargo build --release -p guest-agent --target x86_64-unknown-linux-musl | |
| - name: Verify static linkage | |
| run: | | |
| file target/x86_64-unknown-linux-musl/release/guest-agent | |
| if ldd target/x86_64-unknown-linux-musl/release/guest-agent 2>&1 | grep -qv 'not a dynamic executable\|statically linked'; then | |
| echo "::warning::guest-agent 可能不是靜態連結" | |
| fi |