name: Test
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0/6 * * *'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test (${{ matrix.arch }}-${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: linux
arch: aarch64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos
arch: x86_64
runner: macos-15-intel
target: x86_64-apple-darwin
- os: macos
arch: aarch64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v5
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake clang libclang-dev golang-go perl
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cmake go
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-${{ matrix.arch }}-${{ matrix.os }}
- name: Run cargo check
run: cargo check --all-features
- name: Run cargo test
run: cargo test --all-features
- name: Run cargo clippy
run: cargo clippy --all-features
test-ffi:
name: Test FFI (${{ matrix.arch }}-${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: linux
arch: aarch64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos
arch: x86_64
runner: macos-15-intel
target: x86_64-apple-darwin
- os: macos
arch: aarch64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v5
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake clang libclang-dev golang-go perl
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cmake go
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-ffi-${{ matrix.arch }}-${{ matrix.os }}
- name: Build FFI
run: cargo build --lib --all-features
- name: Check FFI
env:
CARGO_TERM_COLOR: never
run: |
cc -std=c11 -Wall -Wextra -Iinclude tests/ffi.c -Ltarget/debug -lsoyokaze -o ffi-shared
case "${{ matrix.os }}" in
linux) LD_LIBRARY_PATH=target/debug ./ffi-shared ;;
macos) DYLD_LIBRARY_PATH=target/debug ./ffi-shared ;;
esac
libs=$(cargo rustc --lib --all-features --crate-type staticlib -- --print native-static-libs 2>&1 | sed -n 's/^note: native-static-libs: //p' | tail -n1)
if [ -z "$libs" ]; then
echo "::error::rustc reported no native static libs; the link would fail obscurely"
exit 1
fi
echo "native static libs: $libs"
cc -std=c11 -Wall -Wextra -Iinclude tests/ffi.c target/debug/libsoyokaze.a $libs -o ffi-static
./ffi-static
test-python:
name: Test Python Binding (${{ matrix.arch }}-${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x86_64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: linux
arch: aarch64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos
arch: x86_64
runner: macos-15-intel
target: x86_64-apple-darwin
- os: macos
arch: aarch64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v5
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y cmake clang libclang-dev golang-go perl
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cmake go
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-python-${{ matrix.arch }}-${{ matrix.os }}
- name: Build FFI
run: cargo build --lib --all-features
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
- name: Run pytest
working-directory: python
run: uv run pytest
test-doc:
name: Test Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y cmake clang libclang-dev golang-go perl
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-doc
- name: Build Docs
run: cargo doc --no-deps --all-features
osv-scanner:
name: OSV-Scanner
if: ${{ github.event_name != 'pull_request' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.5.0"
permissions:
actions: read
contents: read
security-events: write
osv-scanner-pr:
name: OSV-Scanner (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.5.0"
permissions:
actions: read
contents: read
security-events: write