name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --release --all-features
- name: Run tests
run: cargo test --all-features
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run Clippy
run: cargo clippy --all-features -- -D warnings
build-ffi:
name: Build FFI Library
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
lib: libunpdf.so
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
lib: libunpdf.so
- os: windows-latest
target: x86_64-pc-windows-msvc
lib: unpdf.dll
- os: macos-latest
target: x86_64-apple-darwin
lib: libunpdf.dylib
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl-tools
if: contains(matrix.target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Set RUSTFLAGS for musl
if: contains(matrix.target, 'musl')
run: echo "RUSTFLAGS=-C target-feature=-crt-static" >> $GITHUB_ENV
- name: Build FFI library
run: cargo build --release --features ffi --target ${{ matrix.target }}