vips-sys 0.3.0

libvips bindings for Rust
Documentation
name: Rust

on:
  push:
    branches: [ "main", "feature/**" ]
  pull_request:
    branches: [ "main", "feature/**" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            link_tests: true
          - os: macos-latest
            link_tests: true
          - os: windows-latest
            link_tests: true

    steps:
      - uses: actions/checkout@v7

      - uses: dtolnay/rust-toolchain@stable

      - name: Install libvips (Linux)
        if: runner.os == 'Linux' && matrix.link_tests
        run: |
          sudo apt-get update
          sudo apt-get install -y pkg-config libvips-dev

      - name: Install libvips (macOS)
        if: runner.os == 'macOS' && matrix.link_tests
        run: |
          brew install vips pkg-config
          echo "PKG_CONFIG_PATH=$(brew --prefix vips)/lib/pkgconfig:$(brew --prefix)/lib/pkgconfig" >> "$GITHUB_ENV"

      - name: Cache cargo
        uses: actions/cache@v6
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache vcpkg binaries (Windows)
        if: runner.os == 'Windows'
        uses: actions/cache@v6
        with:
          path: ~\AppData\Local\vcpkg\archives
          key: windows-vcpkg-libvips-${{ hashFiles('Cargo.lock') }}

      - name: Install libvips (Windows vcpkg)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          $root = $env:VCPKG_INSTALLATION_ROOT
          if (-not $root -or -not (Test-Path "$root/vcpkg.exe")) {
            throw "The Windows runner must provide VCPKG_INSTALLATION_ROOT"
          }
          & "$root/vcpkg.exe" install libvips:x64-windows
          if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
          "VCPKG_ROOT=$root" >> $env:GITHUB_ENV
          "VCPKGRS_TRIPLET=x64-windows" >> $env:GITHUB_ENV
          "VCPKGRS_DYNAMIC=1" >> $env:GITHUB_ENV
          "$root/installed/x64-windows/bin" >> $env:GITHUB_PATH

      - name: cargo check
        run: cargo check --features helpers

      - name: cargo clippy
        run: cargo clippy --features helpers -- -D warnings

      - name: cargo test (with system libvips)
        if: matrix.link_tests
        run: cargo test --features helpers

      - name: cargo build (release)
        if: matrix.link_tests
        run: cargo build --release --features helpers

  # Prove `cargo test` works with no system libvips (feature `stub`).
  test-stub:
    name: no-system-libvips (stub)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        # vendor/ not required for the stub path

      - uses: dtolnay/rust-toolchain@stable

      - name: Ensure libvips is absent
        run: |
          if pkg-config --exists vips 2>/dev/null; then
            echo "unexpected system vips; this job must run without it" >&2
            exit 1
          fi

      - name: cargo test with stub
        run: cargo test --features helpers,stub

      - name: cargo clippy with stub
        run: cargo clippy --features helpers,stub -- -D warnings