moxcms 0.9.0

Simple Color Management in Rust
Documentation
name: Build

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    branches:
      - 'master'
      - '!ci_test_*'
    tags-ignore:
      - '*'
  pull_request:
    branches:
      - 'master'

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust: [ "1.89.0", stable ]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}
      - run: rustup target add aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu i686-unknown-linux-gnu powerpc-unknown-linux-gnu wasm32-unknown-unknown
      - run: RUSTFLAGS="-C target-feature=+neon" cargo build --target aarch64-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+neon" cargo build --target aarch64-unknown-linux-gnu --no-default-features
      - run: RUSTFLAGS="-C target-feature=+avx2" cargo build --target i686-unknown-linux-gnu
      - run: cargo build --target powerpc-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+avx2" cargo build --target x86_64-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+avx2" cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx
      - run: RUSTFLAGS="-C target-feature=+avx2" cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse
      - run: RUSTFLAGS="-C target-feature=+avx2" cargo +nightly build --target x86_64-unknown-linux-gnu --no-default-features --features avx,avx512
      - run: RUSTFLAGS="-C target-feature=+simd128" cargo build --target wasm32-unknown-unknown
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx_shaper_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx_shaper_optimized_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx_shaper_fixed_point_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx_luts
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features avx_shaper_fixed_point_paths,in_place
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse_shaper_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse_shaper_optimized_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse_shaper_fixed_point_paths
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse_luts
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features sse_shaper_fixed_point_paths,in_place
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features neon_shaper_paths
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features neon_shaper_optimized_paths
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features neon_shaper_fixed_point_paths
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features neon_luts
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features neon_shaper_fixed_point_paths,in_place
      - run: cargo build --target x86_64-unknown-linux-gnu --no-default-features --features in_place
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features in_place
      - run: cargo build --target aarch64-unknown-linux-gnu --no-default-features --features any_to_any

  tests_x86_sse_isolated:
    name: Testing x86 SSE isolated
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: |
          sudo apt-get update
          sudo apt-get install -y qemu-user
      - run: |
          failed=0
          tests=$(cargo +nightly test --lib -- --list 2>/dev/null | grep ': test' | sed 's/: test//')
          while read -r test; do
              rc=0
              echo "Running: $test"
              output=$(RUSTFLAGS="-C target-feature=+sse4.1,-avx,-avx2,-fma" \
              CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="qemu-x86_64 -cpu Nehalem" \
              cargo +nightly test --lib -- "$test" --exact 2>&1) || rc=$?
              echo "$output" | grep -E "FAILED|ok|signal 4"
              if [ "${rc:-0}" -ne 0 ]; then
                echo "❌ Test failed: $test"
                echo "$output"
                failed=1
              else
                echo "$output" | grep -E "ok|signal 4"
              fi
          done <<< "$tests"
          exit $failed

  tests_x86_avx2_isolated:
    name: Testing x86 AVX2 isolated (no FMA)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: |
          sudo apt-get update
          sudo apt-get install -y qemu-user
      - run: |
          failed=0
          tests=$(cargo +nightly test --lib -- --list 2>/dev/null | grep ': test' | sed 's/: test//')
          while read -r test; do
              rc=0
              echo "Running: $test"
              output=$(RUSTFLAGS="-C target-feature=+avx2,-fma" \
              CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="qemu-x86_64 -cpu Haswell-noTSX,avx2=on,fma=off" \
              cargo +nightly test --lib --target x86_64-unknown-linux-gnu -- "$test" --exact 2>&1) || rc=$?
              echo "$output" | grep -E "FAILED|ok|signal 4"
              if [ "${rc:-0}" -ne 0 ]; then
                echo "❌ Test failed: $test"
                echo "$output"
                failed=1
              else
                echo "$output" | grep -E "ok|signal 4"
              fi
          done <<< "$tests"
          exit $failed

  tests_arm:
    name: Tests
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: cargo test --no-default-features
      - run: cargo test --features neon_shaper_paths
      - run: cargo test --features neon_shaper_optimized_paths
      - run: cargo test --features neon_shaper_fixed_point_paths
      - run: cargo test --features neon_luts
      - run: cargo test --features neon_shaper_fixed_point_paths,in_place
      - run: cargo test --features sve

  tests_x86:
    name: Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --no-default-features
      - run: cargo test --features avx_shaper_paths
      - run: cargo test --features avx_shaper_optimized_paths
      - run: cargo test --features avx_shaper_fixed_point_paths
      - run: cargo test --features avx_luts
      - run: cargo test --features avx_shaper_fixed_point_paths,in_place
      - run: cargo test --features sse_shaper_paths
      - run: cargo test --features sse_shaper_optimized_paths
      - run: cargo test --features sse_shaper_fixed_point_paths
      - run: cargo test --features sse_luts
      - run: cargo test --features sse_shaper_fixed_point_paths,in_place
      - run: cargo test --features extended_range

  clippy_x86:
    name: Clippy x86 Stable
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo clippy --no-default-features                             -- -D warnings
      - run: cargo clippy --features avx_shaper_paths                       -- -D warnings
      - run: cargo clippy --features avx_shaper_optimized_paths             -- -D warnings
      - run: cargo clippy --features avx_shaper_fixed_point_paths           -- -D warnings
      - run: cargo clippy --features avx_luts                               -- -D warnings
      - run: cargo clippy --features avx_shaper_fixed_point_paths,in_place  -- -D warnings
      - run: cargo clippy --features sse_shaper_paths                       -- -D warnings
      - run: cargo clippy --features sse_shaper_optimized_paths             -- -D warnings
      - run: cargo clippy --features sse_shaper_fixed_point_paths           -- -D warnings
      - run: cargo clippy --features sse_luts                               -- -D warnings
      - run: cargo clippy --features sse_shaper_fixed_point_paths,in_place  -- -D warnings
      - run: cargo clippy --features any_to_any -- -D warnings
      - run: cargo clippy --features extended_range -- -D warnings

  clippy_x86_nightly:
    name: Clippy x86 Nightly
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: rustup component add clippy
      - run: cargo clippy --no-default-features                            -- -D warnings
      - run: cargo clippy --features avx_shaper_paths                      -- -D warnings
      - run: cargo clippy --features avx_shaper_optimized_paths            -- -D warnings
      - run: cargo clippy --features avx_shaper_fixed_point_paths          -- -D warnings
      - run: cargo clippy --features avx_luts                              -- -D warnings
      - run: cargo clippy --features avx_shaper_fixed_point_paths,in_place -- -D warnings
      - run: cargo clippy --features sse_shaper_paths                      -- -D warnings
      - run: cargo clippy --features sse_shaper_optimized_paths            -- -D warnings
      - run: cargo clippy --features sse_shaper_fixed_point_paths          -- -D warnings
      - run: cargo clippy --features sse_luts                              -- -D warnings
      - run: cargo clippy --features sse_shaper_fixed_point_paths,in_place -- -D warnings

  clippy_arm:
    name: Clippy ARM
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo clippy --no-default-features                             -- -D warnings
      - run: cargo clippy --features neon_shaper_paths                      -- -D warnings
      - run: cargo clippy --features neon_shaper_optimized_paths            -- -D warnings
      - run: cargo clippy --features neon_shaper_fixed_point_paths          -- -D warnings
      - run: cargo clippy --features neon_luts                              -- -D warnings
      - run: cargo clippy --features neon_shaper_fixed_point_paths,in_place -- -D warnings
      - run: cargo clippy --features any_to_any -- -D warnings
      - run: cargo clippy --features extended_range  -- -D warnings

  fuzz_arm:
    name: Fuzzing ARM
    runs-on: ubuntu-24.04-arm
    strategy:
      matrix:
        feature: [ neon ]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: cargo install cargo-fuzz
      - run: cargo fuzz run unsafe --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16
      - run: cargo fuzz run lut --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16

  fuzz_nightly_arm_sve:
    name: Fuzzing SVE2
    runs-on: ubuntu-24.04-arm
    strategy:
      matrix:
        feature: [ sve ]
    steps:
      - uses: actions/checkout@v4

      - name: Verify SVE2 available
        run: |
          python3 ./assets/sve_vl.py
          grep -m1 "sve2" /proc/cpuinfo || (echo "SVE2 not available on this runner" && exit 1)

      - uses: dtolnay/rust-toolchain@nightly

      - run: cargo install cargo-fuzz
      - run: cargo fuzz run unsafe --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16
      - run: cargo fuzz run lut --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16

  fuzz_x86_64:
    name: Fuzzing x86_64
    runs-on: ubuntu-latest
    strategy:
      matrix:
        feature: [ sse, avx ]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: cargo install cargo-fuzz
      - run: cargo fuzz run unsafe --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16
      - run: cargo fuzz run lut --no-default-features --features ${{ matrix.feature }} -- -max_total_time=16

  fuzz_reader:
    name: Fuzzing Reader
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@nightly
      - run: cargo install cargo-fuzz
      - run: cargo fuzz run safe_read --no-default-features -- -max_total_time=20 -max_len=512000
      - run: cargo fuzz run safe_read_create --no-default-features -- -max_total_time=20 -max_len=512000