name: Mac OS X

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

# When a PR is updated, cancel the jobs from the previous version. Merges
# do not define head_ref, so use run_id to never cancel those jobs.
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  # 20M measured cache size (August 2023).
  CCACHE_SIZE: "25M"

jobs:
  macos:
    runs-on: macos-latest
    steps:
      - name: Clone picolibc
        uses: actions/checkout@v4

      - name: Setup python
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'

      - name: Install meson and ninja
        run: pip install meson ninja

      - name: ccache
        uses: hendrikmuhs/ccache-action@v1.2.11
        with:
          key: compilation-${{ runner.os }}-${{ github.job }}
          max-size: ${{ env.CCACHE_SIZE }}

      - name: MacOS tests
        run: ./.github/do-arm
