name: run units target on macOS

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  testing:

    strategy:
      matrix:
        os: [macos-14, macos-13, macos-12, macos-11]

    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v4

    # temporarily disabled, because it always fails these days.
    #- run: brew update

    # NOTE: DO NOT try to install libiconv and libxml2 package via brew, because macOS already provides them.
    # NOTE: DO NOT try to install python3 package via brew, it has already been included in macos-xx runner images
    # https://github.com/actions/runner-images/blob/macos-13/20231002.1/images/macos/macos-13-Readme.md#python

    # https://github.com/universal-ctags/ctags/pull/3954
    - if: matrix.os == 'macos-13'
      run: brew install --overwrite python@3.12

    - run: brew install automake pkg-config jansson libyaml pcre2

    - run: pip3 install docutils --break-system-packages

    - run: cc --version
    - run: make --version

    - run: ./autogen.sh
    - run: ./configure --enable-debugging --enable-iconv
    - run: make -j2

    - run: ./ctags --version
    - run: ./ctags --list-features

    - run: make check
    - run: make roundtrip
    - run: make tmain
    - run: make units
