Skip to content

Commit

Permalink
Add GitHub workflow for unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Nov 8, 2021
1 parent 4d8c5f5 commit 1b04331
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Test

on: push
# on:
# push:
# branches:
# - master
# pull_request:
# branches:
# - master

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install linting dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Install python package
run: python3 -m pip install . # Needed to guarantee dependencies are installed
- name: Lint with pylint
run: python3 -m pylint --rcfile=setup.cfg nhl/

test-coverage:
name: Coverage
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install testing dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Install python package
run: python3 -m pip install .
- name: Test with pytest
run: python3 -m pytest --cov=nhl/ --cov-report=xml tests/
- name: Upload coverage report
uses: codecov/codecov-action@v1

build-wheel:
name: Build Wheel
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Build python package
run: |
python3 -m pip install --upgrade setuptools wheel twine
python3 setup.py sdist bdist_wheel
python3 -m twine check dist/*
- name: Upload wheel artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
retention-days: 1

test-min:
name: Minimum Dependencies
needs: build-wheel
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install testing dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Install minimum package dependencies
run: python3 -m pip install -r requirements-min.txt
- name: Remove source code
uses: JesseTG/[email protected]
with:
path: nhl/
- name: Download wheel artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Install package wheel
run: |
python3 -m pip install $(ls dist/nhl-*.whl)
- name: Test with pytest
run: |
python3 -m pytest tests/
test-latest:
name: Latest Dependencies
needs: build-wheel
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install testing dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Remove source code
uses: JesseTG/[email protected]
with:
path: nhl/
- name: Download wheel artifact
uses: actions/download-artifact@v2
with:
name: dist
path: dist/
- name: Install package wheel
run: |
python3 -m pip install $(ls dist/nhl-*.whl)
- name: Test with pytest
run: |
python3 -m pytest tests/

0 comments on commit 1b04331

Please sign in to comment.