Skip to content

Commit

Permalink
Use GH actions to test on OSX and Windows as well (jupyter#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart authored May 22, 2020
1 parent 10956c6 commit 6510bd9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 10 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on: push

jobs:
build-n-test-n-coverage:
name: Build, test and code coverage
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ 3.6, 3.7, 3.8 ]
exclude:
- os: windows-latest
python-version: 3.8
env:
OS: ${{ matrix.os }}
PYTHON: '3.8'

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
pip install tox coverage codecov tox-gh-actions
- name: Run the tests
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyter/nbclient/master?filepath=binder%2Frun_nbclient.ipynb)
[![Travis Build Status](https://travis-ci.org/jupyter/nbclient.svg?branch=master)](https://travis-ci.org/jupyter/nbclient)
[![Build Status](https://github.com/jupyter/nbclient/workflows/CI/badge.svg)](https://github.com/jupyter/nbclient/actions)
[![Documentation Status](https://readthedocs.org/projects/nbclient/badge/?version=latest)](https://nbclient.readthedocs.io/en/latest/?badge=latest)
[![image](https://codecov.io/github/jupyter/nbclient/coverage.svg?branch=master)](https://codecov.io/github/jupyter/nbclient?branch=master)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
Expand Down
17 changes: 9 additions & 8 deletions nbclient/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from nbconvert.filters import strip_ansi
from testpath import modified_env
from ipython_genutils.py3compat import string_types
from pebble import ProcessPool
import concurrent.futures

from queue import Empty
from unittest.mock import MagicMock, Mock
Expand Down Expand Up @@ -82,6 +82,12 @@ def run_notebook(filename, opts, resources=None):
return input_nb, output_nb


def run_notebook_wrapper(args):
# since concurrent.futures.ProcessPoolExecutor doesn't have starmap,
# we need to unpack the arguments
return run_notebook(*args)


async def async_run_notebook(filename, opts, resources=None):
"""Loads and runs a notebook, returning both the version prior to
running it and the version after running it.
Expand Down Expand Up @@ -301,13 +307,8 @@ def test_many_parallel_notebooks(capfd):
# run once, to trigger creating the original context
run_notebook(input_file, opts, res)

with ProcessPool(max_workers=2) as pool:
futures = [
pool.schedule(run_notebook, args=(input_file, opts, res))
for i in range(8)
]
for index, future in enumerate(futures):
future.result()
with concurrent.futures.ProcessPoolExecutor(max_workers=2) as executor:
executor.map(run_notebook_wrapper, [(input_file, opts, res) for i in range(8)])

captured = capfd.readouterr()
assert captured.err == ""
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ check-manifest
flake8
tox
bumpversion
pebble
xmltodict
black; python_version >= '3.6'
pip>=18.1
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
skipsdist = true
envlist = py{36,37,38}, flake8, dist, manifest, docs

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, flake8, dist, manifest

# Linters
[testenv:flake8]
skip_install = true
Expand Down Expand Up @@ -50,7 +56,7 @@ basepython =
docs: python3.8
deps = .[dev]
commands =
pytest -vv --maxfail=2 --cov=nbclient -W always {posargs}
pytest -vv --maxfail=2 --cov=nbclient --cov-report=xml -W always {posargs}

# Binder
[testenv:binder]
Expand Down

0 comments on commit 6510bd9

Please sign in to comment.