name: build
on: [push, pull_request]
permissions: read-all
jobs:
  build_macos:
    runs-on: macos-latest
    strategy:
      matrix:
        include:
        - python-version: '3.13'
          toxenv: 'py313'
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install build dependencies
      run: |
        brew update -q
        brew install -q autoconf automake gettext gnu-sed libtool pkgconfig python@${{ matrix.python-version }} tox
        brew link --force gettext
        ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
        python3 -m pip install setuptools
    - name: Build and test Python module
      run: |
        python setup.py update
        export CXXFLAGS="-std=c++14"
        python setup.py build
        tox -e${{ matrix.toxenv }}
  build_ubuntu:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        include:
        - python-version: '3.8'
          toxenv: 'py38'
        - python-version: '3.9'
          toxenv: 'py39'
        - python-version: '3.10'
          toxenv: 'py310'
        - python-version: '3.11'
          toxenv: 'py311'
        - python-version: '3.12'
          toxenv: 'py312'
        - python-version: '3.13'
          toxenv: 'py313'
    steps:
    - uses: actions/checkout@v4
    - name: Install build dependencies
      run: |
        sudo add-apt-repository universe &&
        sudo add-apt-repository -y ppa:deadsnakes/ppa &&
        sudo apt-get update &&
        sudo apt-get install -y autoconf automake autopoint autotools-dev build-essential git libtool pkg-config python${{ matrix.python-version }} python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python3-distutils python3-pip python3-setuptools
    - name: Install tox
      run: |
        python3 -m pip install tox
    - name: Build and test Python module
      run: |
        python setup.py update
        python setup.py build
        tox -e${{ matrix.toxenv }}
  build_windows:
    runs-on: windows-latest
    strategy:
      matrix:
        python-version: ['3.13']
        architecture: ['x86', 'x64']
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install build dependencies
      run: |
        python3 -m pip install setuptools
    - name: Build Python module
      run: |
        python setup.py update
        python setup.py build
        python setup.py install
    - name: Test Python module
      run: |
        python run_tests.py
