zencodec 0.1.13

Shared traits and types for zen* image codecs
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  CI: true

jobs:
  # ==========================================================================
  # Native testing (6-platform matrix)
  # ==========================================================================
  test:
    name: Test (${{ matrix.name }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-latest, name: Linux x64 }
          - { os: ubuntu-24.04-arm, name: Linux aarch64 }
          - { os: macos-latest, name: macOS arm64 }
          - { os: macos-26-intel, name: macOS x64 }
          - { os: windows-latest, name: Windows x64 }
          - { os: windows-11-arm, name: Windows arm64 }
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

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

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

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Test
        run: cargo test

      - name: Check no_std (no codec feature)
        run: cargo check --no-default-features

  # ==========================================================================
  # Cross-compiled 32-bit testing (i686 via QEMU)
  # ==========================================================================
  test-i686:
    name: Test i686
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: i686-unknown-linux-gnu

      - name: Install cross
        uses: taiki-e/install-action@cross

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          key: cross-i686

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Test (i686/QEMU)
        run: cross test --target i686-unknown-linux-gnu

  # ==========================================================================
  # WASM check
  # ==========================================================================
  wasm:
    name: WASM (wasm32-wasip1)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-wasip1

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

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Check WASM (no_std)
        run: cargo check --target wasm32-wasip1 --no-default-features

  # ==========================================================================
  # Clippy
  # ==========================================================================
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

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

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

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

  # ==========================================================================
  # Format check
  # ==========================================================================
  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

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

      - name: Format check
        run: cargo fmt --all -- --check

  # ==========================================================================
  # MSRV check
  # ==========================================================================
  msrv:
    name: MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

      - name: Install cargo-hack
        uses: taiki-e/install-action@cargo-hack

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

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Check MSRV
        run: cargo hack check --rust-version

  # ==========================================================================
  # Semver check (API compatibility)
  # ==========================================================================
  semver:
    name: Semver Check
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

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

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

      - name: Install cargo-semver-checks
        uses: taiki-e/install-action@cargo-semver-checks

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Check semver
        run: cargo semver-checks check-release
        # Intentional breaking change in 0.1.5: DecoderConfig::job() now consumes self.
        # All pre-0.1.5 versions are yanked. Re-enable strict checking after this release.
        continue-on-error: true

  # ==========================================================================
  # Code coverage
  # ==========================================================================
  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v6

      - name: Configure git for private repos
        run: git config --global url."https://x-access-token:${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"

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

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

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

      - name: Patch path deps to git refs
        shell: bash
        run: |
          sed \
            -e 's|path = "\.\./zenpixels/zenpixels"|git = "https://github.com/imazen/zenpixels"|g' \
            -e 's|path = "\.\./zenpixels/zenpixels-convert"|git = "https://github.com/imazen/zenpixels"|g' \
            Cargo.toml > Cargo.toml.ci && \
            mv Cargo.toml.ci Cargo.toml
          printf '\n[patch.crates-io]\nzenpixels = { git = "https://github.com/imazen/zenpixels" }\nzenpixels-convert = { git = "https://github.com/imazen/zenpixels" }\n' >> Cargo.toml
          rm -f Cargo.lock

      - name: Generate coverage
        run: cargo llvm-cov --lcov --output-path lcov.info

      - name: Upload to Codecov
        uses: codecov/codecov-action@v5
        with:
          files: lcov.info
          fail_ci_if_error: false
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}