# This the main GridPath CI workflow
# It installs Cbc and Python dependencies, runs the GridPath test suite with coverage,
# and sends coverage results to coveralls

name: test-suite

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]
  schedule:
    - cron: "0 17 * * *"

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ "3.9", "3.10", "3.11" ]

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Cbc and check version
      run: |
        sudo apt-get install coinor-cbc
        sudo apt-get install -y apt-show-versions
        apt-show-versions coinor-cbc
    - name: Install Python dependencies
      run: |
        python -m pip install .[coverage] --upgrade pip
    - name: Test GridPath with coverage
      run: |
        coverage run -m unittest discover tests
    - name: Send coverage results to Coveralls
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        coveralls --service=github
