libcramjam 0.8.0

Compression library combining a plethora of algorithms in a similar as possible API
Documentation
name: CI

on:
  push:
    branches:
      - main
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
  cancel-in-progress: true

jobs:
  build-test:
    name: ${{ matrix.os }}-capi=${{ matrix.capi }}-codec=${{ matrix.codec || 'all' }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false #${{ !( startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/tags/') ) }}
      matrix:
        os:
          - macos-14  # arm64
          - macos-13  # x86_64
          - windows-latest
          - ubuntu-latest
        capi:
          - true
          - false
        codec:
          - zstd
          - blosc2
          - gzip
          - brotli
          - lz4
          - xz
          - deflate
          - bzip2
          - null  # Use all codecs

        # TODO: codecs not implemented in capi feature
        exclude:
          - capi: true
            codec: blosc2
          - capi: true
            codec: xz
          - capi: true
            codec: deflate

          # TODO: capi feature fails with all enabled due to duplicate export of 'compress' symbol
          # first from the capi here, then from blosc2 internal zlib-ng; probably just rename ours
          # prefixed with 'cramjam_' or something.
          - capi: true
            codec: null
            os: ubuntu-latest
          - capi: true
            codec: null
            os: windows-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        name: Rust Cache

      - name: Install nasm
        if: runner.os != 'macOS'
        uses: ilammy/setup-nasm@v1

      - name: Install build deps (OSX)
        if: runner.os == 'macOS'
        run: brew install automake autoconf coreutils libtool nasm

      - name: Set MSVC developer prompt
        if: runner.os == 'Windows'
        uses: ilammy/msvc-dev-cmd@v1.6.0

      - name: Audit
        if: |
          !matrix.codec && matrix.capi
        run: cargo install cargo-audit && cargo audit

      - name: Test capi and single codec
        if: matrix.capi && matrix.codec
        run: cargo test -p libcramjam --no-default-features --features ${{ matrix.codec }} --features capi --lib

      - name: Test capi and all codecs
        if: matrix.capi && !matrix.codec
        run: cargo test -p libcramjam --features capi --lib

      - name: Test no capi and all codecs
        if: |
          !matrix.capi && !matrix.codec
        run: cargo test -p libcramjam --lib

      - name: Test no capi and single codec
        if: |
          !matrix.capi && matrix.codec
        run: cargo test -p libcramjam --lib --no-default-features --features ${{ matrix.codec }}

  # build-wasm32:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v4

  #     - name: Install Rust toolchain
  #       uses: dtolnay/rust-toolchain@stable
  #       with:
  #         target: wasm32-unknown-emscripten

  #     - name: Install Emscripten
  #       uses: mymindstorm/setup-emsdk@v14

  #     - name: Build
  #       run: cargo build --target wasm32-unknown-emscripten --features wasm32-compat