Files
Sylvestre Ledru 782744f35c ci: build and lint the wasm32-wasip1 target
Add a job that installs the wasm32-wasip1 target plus the WASI SDK (so the
bundled C in onig_sys can be cross-compiled) and runs cargo build and
clippy -D warnings, so non-Unix compilation can't regress.
2026-06-10 07:45:04 +02:00

124 lines
3.6 KiB
YAML

on: [push, pull_request]
name: Basic CI
env:
CARGO_INCREMENTAL: "0"
jobs:
check:
name: cargo check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v6
# For bindgen: https://github.com/rust-lang/rust-bindgen/issues/1797
- uses: KyleMayes/install-llvm-action@v2
if: matrix.os == 'windows-latest'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-latest'
- name: Check
run: |
cargo check --all --all-features
test:
name: cargo test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v6
# For bindgen: https://github.com/rust-lang/rust-bindgen/issues/1797
- uses: KyleMayes/install-llvm-action@v2
if: matrix.os == 'windows-latest'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: matrix.os == 'windows-latest'
- name: Test
run: |
cargo test
fmt:
name: cargo fmt --all -- --check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: cargo fmt
run: |
cargo fmt --all -- --check
clippy:
name: cargo clippy -- -D warnings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: |
cargo clippy --all-targets -- -D warnings
wasm:
name: cargo build (wasm32-wasip1)
runs-on: ubuntu-latest
env:
WASI_SDK_VERSION: "33"
WASI_SDK_PATH: ${{ github.workspace }}/wasi-sdk
# onig_sys compiles bundled C, so it needs a C compiler with a WASI
# sysroot to cross-compile to wasm.
CC_wasm32_wasip1: ${{ github.workspace }}/wasi-sdk/bin/clang
AR_wasm32_wasip1: ${{ github.workspace }}/wasi-sdk/bin/llvm-ar
steps:
- uses: actions/checkout@v6
- name: Install wasm target
run: rustup target add wasm32-wasip1
- name: Install WASI SDK
run: |
curl -sSfL "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz" | tar xz
mv "wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux" "${WASI_SDK_PATH}"
- name: Build
run: cargo build --target wasm32-wasip1
- name: Clippy
run: cargo clippy --target wasm32-wasip1 -- -D warnings
grcov:
name: Code coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
cargo_flags:
- "--all-features"
steps:
- name: Checkout source code
uses: actions/checkout@v6
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
env:
RUSTC_BOOTSTRAP: 1
run: |
cargo llvm-cov --all-features --lcov --branch --output-path lcov.info
- name: Upload coverage as artifact
uses: actions/upload-artifact@v7
with:
name: lcov.info
path: lcov.info
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v7
with:
files: lcov.info
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}