wip 0.4.0: skip zlib FetchContent on emscripten #50
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: | |
| # Invoked by release.yml before publishing to crates.io. | |
| workflow_call: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| # ----------------------------------------------------------------------- | |
| # Native builds (+ tests where the runner matches the target) | |
| # ----------------------------------------------------------------------- | |
| native: | |
| name: native ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - { os: macos-latest, target: aarch64-apple-darwin, run-tests: true } | |
| - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, run-tests: true } | |
| - { os: windows-latest, target: x86_64-pc-windows-msvc, run-tests: false } # link flow only for now | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| components: clippy, rustfmt | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: cargo fmt --check | |
| if: runner.os == 'Linux' | |
| run: cargo fmt --all -- --check | |
| - name: cargo build | |
| run: cargo build --workspace --exclude xtask --target ${{ matrix.target }} | |
| - name: cargo clippy | |
| if: runner.os == 'Linux' | |
| run: cargo clippy --workspace --all-targets -- -D warnings | |
| - name: cargo doc | |
| if: runner.os == 'Linux' | |
| env: | |
| RUSTDOCFLAGS: -D warnings | |
| run: cargo doc --workspace --no-deps --exclude xtask | |
| - name: cargo test | |
| if: matrix.run-tests | |
| run: cargo test --workspace --exclude xtask --target ${{ matrix.target }} | |
| # ----------------------------------------------------------------------- | |
| # Cross-target builds (Linux arm64 + Android arm64/x86_64) via cross-rs. | |
| # These confirm build.rs + linker + committed bindings work under the | |
| # real target toolchain. Tests are skipped (Android tests would need | |
| # emulator instrumentation). | |
| # ----------------------------------------------------------------------- | |
| cross: | |
| name: cross ${{ matrix.target }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - aarch64-unknown-linux-gnu | |
| - aarch64-linux-android | |
| - x86_64-linux-android | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: cross-${{ matrix.target }} | |
| - name: install cross | |
| run: cargo install cross --locked --version ^0.2 | |
| - name: cross build | |
| run: cross build -p litert-sys --target ${{ matrix.target }} | |
| - name: cross build litert | |
| run: cross build -p litert --target ${{ matrix.target }} | |
| # ----------------------------------------------------------------------- | |
| # Bindings drift check (native host only): regenerate the x86_64 Linux | |
| # binding file with the runner's own bindgen + libclang and diff it | |
| # against what's committed. Non-host targets (Windows MSVC, macOS, Android, | |
| # Linux arm64) are currently seeded from the macOS host and cross-verified | |
| # at link time by the native / cross jobs above; their committed .rs files | |
| # are updated via `cargo xtask regen-bindings --target <T>` on a matching | |
| # host or container by maintainers. | |
| # ----------------------------------------------------------------------- | |
| bindings-drift: | |
| name: bindings drift (linux x86_64) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: bindings-drift | |
| - name: install libclang | |
| run: sudo apt-get update && sudo apt-get install -y libclang-dev clang | |
| - name: regenerate bindings for native host target | |
| run: cargo xtask regen-bindings --target x86_64-unknown-linux-gnu | |
| - name: assert no drift | |
| run: | | |
| if ! git diff --exit-code litert-sys/src/bindings/x86_64-unknown-linux-gnu.rs; then | |
| echo "::error::Committed Linux x86_64 bindings differ from freshly generated output." | |
| echo "Run 'cargo xtask regen-bindings --target x86_64-unknown-linux-gnu' and commit the diff." | |
| exit 1 | |
| fi | |
| - uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: bindings-regenerated | |
| path: litert-sys/src/bindings/ |