name: Cross

on:
  pull_request:
    branches: [main]
  workflow_dispatch:

jobs:
  cross:
    name: Rust ${{matrix.target}}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target:
          # Android
          - aarch64-linux-android
          - arm-linux-androideabi
          - armv7-linux-androideabi
          - i686-linux-android
          - x86_64-linux-android

          # Linux
          - aarch64-unknown-linux-gnu
          - arm-unknown-linux-gnueabi
          - armv7-unknown-linux-gnueabihf
          - i686-unknown-linux-gnu
          - i686-unknown-linux-musl
          - mips-unknown-linux-gnu
          - mips64-unknown-linux-gnuabi64
          - mips64el-unknown-linux-gnuabi64
          - mipsel-unknown-linux-gnu
          - powerpc64le-unknown-linux-gnu
          - x86_64-unknown-linux-gnu
          - x86_64-unknown-linux-musl

          # Windows
          - x86_64-pc-windows-gnu

    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: ${{matrix.target}}
          override: true
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: check
          args: --target ${{matrix.target}}
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: test
          args: --target ${{matrix.target}}
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: test
          args: --target ${{matrix.target}} --features=compact

  notest:
    name: Rust ${{matrix.target}}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        target:
          # Linux
          - powerpc64-unknown-linux-gnu
          - s390x-unknown-linux-gnu

          # FreeBSD
          - i686-unknown-freebsd
          - x86_64-unknown-freebsd
          - x86_64-unknown-netbsd

    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: ${{matrix.target}}
          override: true
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: check
          args: --target ${{matrix.target}}
