name: CI

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: oven-sh/setup-bun@v2
      - uses: Swatinem/rust-cache@v2
      - run: make setup
      - run: make cargo-test
      - run: make cargo-test-help
      - run: make lint

  build-x86_64-apple-darwin:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup target add x86_64-apple-darwin
      - run: cargo build --target x86_64-apple-darwin --release

  build-aarch64-apple-darwin:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain list
      - run: make build-release

  build-x86_64-pc-windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain list
      - run: make build-release

  build-aarch64-pc-windows:
    runs-on: windows-11-arm
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain list
      - run: make build-release

  build-x86_64-unknown-linux-gnu:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain list
      - run: make build-release

  build-aarch64-unknown-linux-gnu:
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - uses: Swatinem/rust-cache@v2
      - run: rustup toolchain list
      - run: make build-release
