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.93.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: cargo build --target aarch64-unknown-linux-gnu
      - run: cargo build --target i686-unknown-linux-gnu
      - run: cargo build --target powerpc-unknown-linux-gnu
      - run: RUSTFLAGS="-C target-feature=+simd128" cargo build --target wasm32-unknown-unknown

  tests_arm:
    name: Tests
    strategy:
      matrix:
        features: [ "" ]
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --no-default-features --features "${{ matrix.features }}"

  tests_x86:
    name: Tests
    strategy:
      matrix:
        features: [ "" ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --no-default-features --features "${{ matrix.features }}"

  clippy_x86:
    name: Clippy x86 Stable
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo clippy --all-features -- -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 --all-features -- -D warnings

  clippy_arm:
    name: Clippy ARM
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo clippy --all-features -- -D warnings