nstarman/utilipy

View on GitHub
.github/workflows/ci_tests.yml

Summary

Maintainability
Test Coverage
name: CI

#########################
# Run Conditions

on:
  push:
    # only build on select branches
    branches:
      - main
      - master  # TODO delete when transition
      - release/*

  pull_request:
    # only build on PRs against main
    branches:
      - main
      - master  # TODO delete when transition

  schedule:
    - cron: '0 0 * * 0' # run weekly, even if no push / PR.


#########################
# Environment Variables

env:  # Set defaults to avoid repeating in most cases

  SETUP_XVFB: True  # avoid issues if mpl tries to open a GUI window


#########################
# The Tests

jobs:

  # ---------------------------------------------
  # Initial Tests

  inital:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))"

    strategy:
      fail-fast: false

      matrix:
        include:

          - name: py3.8, min deps | coverage
            os: ubuntu-latest
            python: 3.8
            toxenv: py38-test-cov

          # Done with pre-commit
          # - name: code style
          #   os: ubuntu-latest
          #   python: 3.x
          #   toxenv: codestyle

          # - name: Documentation Build  # Done with RTD
          #   os: ubuntu-latest
          #   python: 3.x
          #   toxenv: build_docs

    steps:
    # --------------------
    # Setup
    - name: Checkout code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}
    - name: Install base dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install --upgrade tox codecov
    - name: Install 'build_docs' dependency
      if: "contains(matrix.tox_env, 'build_docs')"
      run: |
        sudo apt-get -y install graphviz
        sudo apt-get -y install pandoc
    - name: Print Python, pip, setuptools, and tox versions
      run: |
        python -c "import sys; print(f'Python {sys.version}')"
        python -c "import pip; print(f'pip {pip.__version__}')"
        python -c "import setuptools; print(f'setuptools {setuptools.__version__}')"
        python -c "import tox; print(f'tox {tox.__version__}')"
    # --------------------
    # Run Tests
    - name: Run tests
      run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
    # TODO: Do we need --gcov-glob "*cextern*" ?
    # --------------------
    # Cleanup
    - name: Upload coverage to codecov
      if: contains(matrix.toxenv,'-cov')
      uses: codecov/codecov-action@v1
      with:
        file: ./coverage.xml

  # ---------------------------------------------
  # Further Tests

  further:
    needs: inital
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}

    strategy:
      # TODO: Change to true when we know how to handle remote data job correctly
      fail-fast: false

      matrix:
        include:

          # FIXME
          # - name: py3.8 - all deps, remote data | coverage
          #   os: ubuntu-latest
          #   python: 3.8
          #   toxenv: py38-test-alldeps-cov
          #   toxargs: -v --develop
          #   toxposargs: --durations=50 --remote-data=any  # in case it runs long

          # NOTE: In the build below we also check that tests do not open and
          # leave open any files. This has a performance impact on running the
          # tests, hence why it is not enabled by default.
          - name: py3.7 - oldest deps
            os: ubuntu-16.04
            python: 3.7
            toxenv: py37-test-oldestdeps

          - name: py3.7 - all deps, numpy 1.17 | coverage
            os: ubuntu-latest
            python: 3.7
            toxenv: py37-test-alldeps-numpy117-cov-clocale
            # toxposargs: --remote-data=discO

          - name: py3.8 - all deps (MacOS X)
            os: macos-latest
            python: 3.8
            toxenv: py38-test-alldeps

          - name: py3.8 - all deps (Windows)
            os: windows-latest
            python: 3.8
            toxenv: py38-test-alldeps

    steps:
    - name: Checkout code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}
    - name: Install base dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install --upgrade tox codecov
    - name: Run tests
      run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
    # TODO: Do we need --gcov-glob "*cextern*" ?
    - name: Upload coverage to codecov
      if: contains(matrix.toxenv,'-cov')
      uses: codecov/codecov-action@v1
      with:
        file: ./coverage.xml


  # ---------------------------------------------
  # Many Versions

  versions:
    needs: further
    name: ${{ matrix.os }}, py${{ matrix.python }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false  # run all the tests, even if one fails

      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python: [3.7, 3.8]

    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python }}
    - name: Setup
      run: |
        python -m pip install --upgrade pip
        python -m pip install --upgrade tox codecov
    - name: Test  # Run tox using the version of Python in `PATH`
      run: tox -e py