name: Tests on macOS

on:
  pull_request:
  push:
    branches:
      - nightly
      - main
      - release/*
  workflow_dispatch:

jobs:
  unittests:
    strategy:
      matrix:
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
        runner: ["macos-12"]
        include:
          - python-version: "3.8"
            runner: macos-m1-12
      fail-fast: false
    uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
    with:
      repository: pytorch/vision
      # We need an increased timeout here, since the macos-12 runner is the free one from GH
      # and needs roughly 2 hours to just run the test suite
      timeout: 240
      runner: ${{ matrix.runner }}
      script: |
        set -euo pipefail

        export PYTHON_VERSION=${{ matrix.python-version }}
        export GPU_ARCH_TYPE=cpu
        export GPU_ARCH_VERSION=''

        ./.github/scripts/unittest.sh
