name: CI

on:
  push:
    branches: [dev]
  pull_request:
    branches: [master]

jobs:
  pre-commit:
    name: pre-commit
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.7
      - uses: actions/cache@v1
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
      - uses: pre-commit/action@v2.0.0
  tests:
    name: "Python ${{ matrix.python-version }}"
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.7", "3.8"]
        os: [ubuntu-latest, macOS-latest, windows-latest]
    steps:
      - uses: "actions/checkout@v2"
      - name: Set up Python ${{ matrix.python-version }}
        uses: "actions/setup-python@v2"
        with:
          python-version: "${{ matrix.python-version }}"
      - name: Setup Conda Environment
        uses: goanpeca/setup-miniconda@v1
        with:
          miniconda-version: "latest"
          python-version: ${{ matrix.python-version }}
          environment-file: environments/environment-dev.yml
          activate-environment: footings-dev
          auto-activate-base: false
      - name: Install nox
        run: |
          python -m pip install --upgrade pip
          pip install nox
      - name: Run tests
        run:  nox -s test-${{ matrix.python-version }}
