name: build

on:
  schedule:
    # Every friday at 4am UTC
    - cron:  '0 4 * * 5'
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
        python_version:
          - '3.8'
          - '3.9'
          - '3.10'
        include:
          - os: windows-latest
            python_version: '3.10'
          - os: ubuntu-latest
            python_version: '3.10'
            coverage: true
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install global dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install pytest pytest-cov coveralls
        python -m pip install pandas
    - name: Install minimal dependencies
      if: ${{ matrix.python_version == '3.8' }}
      run: python -m pip install scikit-learn==1.1.0 joblib==1.0.0
    - name: Install gplearn
      run: python -m pip install .
    - name: Describe Python environment
      run: |
        python --version
        python -c "import sklearn; print('sklearn %s' % sklearn.__version__)"
        python -c "import joblib; print('joblib %s' % joblib.__version__)"
        python -c "import numpy; print('numpy %s' % numpy.__version__)"
        python -c "import scipy; print('scipy %s' % scipy.__version__)"
    - name: Test with pytest
      run: pytest -v --cov
    - name: Coverage
      if: ${{ matrix.coverage }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: coveralls --service=github
