name: continuous-integration
on:
  push:
    branches:
      - main
      - master
      - releases/*
  pull_request: null

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: 
          - ubuntu-latest
        py:
          - 3.8
        CC:
          - gcc

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python ${{ matrix.py }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.py }}

      - name: Install GSL, FFTW, fitsio
        run: |
          sudo -H apt-get install libgsl-dev libfftw3-dev libcfitsio-dev

      - name: Install python dependencies
        run: |
          python -m pip install -U pip
          pip install -U numpy
          pip install -U scipy
          pip install -U healpy
          pip install -U flake8
          pip install -U pytest
          pip install -U pytest-cov
          pip install -U coveralls

      - name: Flake
        run: |
          flake8 pymaster --exclude=nmtlib.py
          flake8 test --exclude=benchmarks

      - name: Build NaMaster
        run: |
          python setup.py install

      - name: C tests
        run: |
          make check

      - name: Python tests
        run: |
          pytest -vv pymaster --cov=pymaster

#      - name: Clean install with threads
#        run: |
#          pip uninstall pymaster -y
#          rm _deps/lib/libnmt.a
#          python setup.py install --enable-fftw-pthreads --disable-openmp
#
#      - name: C tests with threads
#        run: |
#          make check
#
#      - name: Python tests with threads
#        run: |
#          pytest -vv pymaster
#
      - name: coveralls
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          coveralls --service=github
