name: build

on: [push, pull_request]

jobs:

  style:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Style
      run: |
        shopt -s globstar &&
        ! grep -E '.{80}' **/*.py

  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        cibw-build: ['cp36-*', 'cp37-*', 'cp38-*', 'cp39-*', 'cp310-*', 'cp311-*']
      fail-fast: false
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v3
    - uses: docker/setup-qemu-action@v2
      if: runner.os == 'Linux'
    - uses: pypa/cibuildwheel@v2.12.1
      env:
        CIBW_ENVIRONMENT: SETUPTOOLS_SCM_PRETEND_VERSION=0.3.0
        CIBW_BUILD: ${{ matrix.cibw-build }}
        CIBW_SKIP: '*-musllinux_*'
        CIBW_TEST_SKIP: '*-macosx_universal2:arm64'
        CIBW_ARCHS_LINUX: 'x86_64 aarch64'
        CIBW_ARCHS_MACOS: 'x86_64 universal2'
        CIBW_ARCHS_WINDOWS: 'AMD64'
        CIBW_TEST_REQUIRES: pytest
        CIBW_TEST_COMMAND: python -mpytest --pyargs hmmlearn.tests
    - uses: actions/upload-artifact@v3
      with:
        name: wheels
        path: wheelhouse/*.whl
      if: ${{ always() }}
