name: CI

on:
  pull_request:
    branches: [ main ]
  workflow_dispatch:

defaults:
  run:
    shell: bash

jobs:
  compat:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        zig: [ 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.10.0 ]
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Zig
        uses: goto-bus-stop/setup-zig@v2
        with:
          version: ${{ matrix.zig }}

      - name: Check compatibility with old Zig compilers
        run: ci/compat.sh

  test:
    name: Unit Tests
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Zig
        uses: goto-bus-stop/setup-zig@v2
        with:
          version: master

      - name: Run unit tests
        run: zig build test