SGD NaN Fix #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests & Docs | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
branches: | |
- main | |
- master | |
jobs: | |
# Job (1): Run testing in parallel against multiples OSs and Python versions | |
test: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
name: Test | |
runs-on: ${{ matrix.os }} | |
# Determines whether the entire workflow should pass/fail based on parallel jobs | |
continue-on-error: ${{ matrix.ok-fail }} | |
defaults: | |
# This ensures each step gets properly configured bash shell for conda commands to work | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
# OSs to test | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
# Python versions to test | |
python-version: [3.7, 3.8] | |
# By default everything should pass for the workflow to pass | |
ok-fail: [false] | |
include: | |
# Rather than include 3.9 in the python versions, do it here so we can ignore failures on mac and windows with 3.9 (they have install issues) | |
- os: ubuntu-latest | |
python-version: 3.9 | |
ok-fail: true | |
- os: macos-latest | |
python-version: 3.9 | |
ok-fail: true | |
- os: windows-latest | |
python-version: 3.9 | |
ok-fail: true | |
steps: | |
# Step up miniconda | |
- name: Download and setup Miniconda | |
uses: conda-incubator/setup-miniconda@059455a698430d8b68fa317268fa2e3da3492a98 | |
with: | |
miniconda-version: "latest" | |
python-version: ${{ matrix.python-version }} | |
# Check out latest code on github | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
# Install common sci-py packages via conda as well as testing packages and requirements | |
- name: Install Dependencies | |
run: | | |
conda activate test | |
conda env list | |
conda install -y numpy numba pandas scipy seaborn | |
conda install -y -c conda-forge pytest pytest-cov pytest-xdist pytest-sugar coveralls black | |
pip install . -r requirements.txt | |
# Check code formatting | |
- name: Check code formatting | |
run: | | |
black . --check --diff | |
# Actually run the tests with coverage | |
- name: Run Tests | |
run: | | |
conda activate test | |
conda env list | |
pytest --cov=neighbors -rs -n auto | |
# Send coverage to coveralls.io but waiting on parallelization to finish | |
# Not using the official github action in the marketplace to upload because it requires a .lcov file, which pytest doesn't generate. It's just easier to use the coveralls python library which does the same thing, but works with pytest. | |
- name: Upload Coverage | |
# The coveralls python package has some 422 server issues with uploads from github-actions so try both service providers, for more see: | |
# https://github.com/TheKevJames/coveralls-python/issues/252 | |
run: coveralls --service=github || coveralls --service=github-actions | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COVERALLS_FLAG_NAME: $${{ matrix}} | |
COVERALLS_PARALLEL: true | |
# Job (2): Send a finish notification to coveralls.io to integrate coverage across parallel tests | |
coveralls: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
name: Coveralls.io Upload | |
needs: test | |
runs-on: ubuntu-latest | |
container: python:3-slim | |
continue-on-error: true | |
steps: | |
- name: Finished | |
run: | | |
pip3 install --upgrade coveralls | |
coveralls --service=github --finish || coveralls --service=github-actions --finish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Job (3): Build and deploy docs | |
docs: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
name: Build & deploy docs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Upgrade pip | |
run: | | |
# install pip=>20.1 to use "pip cache dir" | |
python3 -m pip install --upgrade pip | |
- name: Setup pip-cache | |
id: pip-cache | |
run: echo "::set-output name=dir::$(pip cache dir)" | |
- name: Cache deps | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install deps | |
run: | | |
python3 -m pip install . -r requirements.txt | |
python3 -m pip install -r ./requirements-dev.txt | |
- name: Build docs | |
run: | | |
mkdocs build | |
echo 'neighbors.cosanlab.com' > ./site/CNAME | |
- name: Deploy docs | |
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./site |