name: Test

on: [push, pull_request]

permissions:
  contents: read

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Install bats
      run: git clone --depth 1 --branch v1.10.0 https://github.com/bats-core/bats-core.git bats
    - name: Run tests
      run: PATH="./bats/bin:$PATH" script/test
    - name: Verify download URL checksums
      if: github.event_name == 'pull_request'
      run: ./script/mirror verify "$COMMIT_RANGE"
      env:
        COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..
