name: CI

on: [push, pull_request]

jobs:
  direct:
    runs-on: ${{ matrix.os }}-latest
    strategy:
      matrix:
        os: [ubuntu, macos]
        python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
        exclude:
          # Run only the latest 2.x and 3.x on macOS
          - os: macos
            python-version: 3.6
          - os: macos
            python-version: 3.7
          - os: macos
            python-version: 3.8

    steps:
      - name: Checkout pysam
        uses: actions/checkout@v2

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

      - name: Install prerequisite Python libraries
        run:  pip install cython pytest pytest-pep8

      - name: Install build prerequisites
        if:   runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -q --no-install-recommends --no-install-suggests libcurl4-openssl-dev

      - name: Build (directly from checkout)
        run:  python setup.py build

      - name: Install test prerequisites
        run: |
          case $RUNNER_OS in
          Linux)
              sudo apt-get install -q --no-install-recommends --no-install-suggests samtools bcftools tabix
              ;;
          macOS)
              brew install -q samtools bcftools
              ;;
          esac

      - name: Run tests
        run: |
          export PYTHONPATH=$(echo $GITHUB_WORKSPACE/build/lib.*)
          export REF_PATH=':'
          pytest

Add basic CI GitHub Actions workflow
Add basic CI GitHub Actions workflow

Basic build (directly from the checked-out source code) and test on
a matrix of Python versions on Linux and macOS.

(Factoring "-latest" out of matrix.os shortens the annotated job names
so they aren't trimmed when displayed. If in future we need to pin to
e.g. macos-10.15 we will need to undo that and accept the trimming.)
