Files
kcp-sys/.github/workflows/rust.yml
T
2026-05-22 23:58:41 +08:00

188 lines
5.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# ──────────────────────────────────────────────
# Lint: rustfmt + clippy
# ──────────────────────────────────────────────
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Clippy
run: cargo clippy -- -D warnings
# ──────────────────────────────────────────────
# Native build + test matrix
# 6 runners × 2 profiles = 12 jobs
# ──────────────────────────────────────────────
build:
name: ${{ matrix.name }} (${{ matrix.profile }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux x64
- name: Linux x64
runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
profile: debug
- name: Linux x64
runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
profile: release
# Linux arm64
- name: Linux arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
profile: debug
- name: Linux arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
profile: release
# Windows x64
- name: Windows x64
runner: windows-latest
target: x86_64-pc-windows-msvc
profile: debug
- name: Windows x64
runner: windows-latest
target: x86_64-pc-windows-msvc
profile: release
# Windows arm64
- name: Windows arm64
runner: windows-11-arm
target: aarch64-pc-windows-msvc
profile: debug
- name: Windows arm64
runner: windows-11-arm
target: aarch64-pc-windows-msvc
profile: release
# macOS x64 (Intel)
- name: macOS x64
runner: macos-15-intel
target: x86_64-apple-darwin
profile: debug
- name: macOS x64
runner: macos-15-intel
target: x86_64-apple-darwin
profile: release
# macOS arm64 (Apple Silicon)
- name: macOS arm64
runner: macos-15
target: aarch64-apple-darwin
profile: debug
- name: macOS arm64
runner: macos-15
target: aarch64-apple-darwin
profile: release
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-${{ matrix.profile }}
# Linux: install libclang for bindgen
- name: Install libclang (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libclang-dev
- name: Build
run: cargo build --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}
- name: Test
run: cargo test --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}
- name: Install CMake 4
uses: step-security/get-cmake@v4
with:
cmakeVersion: "^4.0.0"
- name: Build KCP native test
run: |
cmake -S kcp -B kcp/build -DBUILD_TESTING=ON
cmake --build kcp/build --target kcp_test
# ──────────────────────────────────────────────
# Cross-compilation via zigbuild (musl targets)
# 3 targets × 2 profiles = 6 jobs
# ──────────────────────────────────────────────
cross:
name: Cross ${{ matrix.target }} (${{ matrix.profile }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-musl
profile: debug
- target: aarch64-unknown-linux-musl
profile: release
- target: x86_64-unknown-linux-musl
profile: debug
- target: x86_64-unknown-linux-musl
profile: release
- target: riscv64gc-unknown-linux-musl
profile: debug
- target: riscv64gc-unknown-linux-musl
profile: release
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: mlugg/setup-zig@v2
- uses: Swatinem/rust-cache@v2
with:
key: cross-${{ matrix.target }}-${{ matrix.profile }}
- name: Install libclang and cargo-zigbuild
run: |
sudo apt-get update && sudo apt-get install -y libclang-dev
cargo install cargo-zigbuild
- name: Build (zigbuild)
run: cargo zigbuild --target ${{ matrix.target }} --verbose ${{ matrix.profile == 'release' && '--release' || '' }}