From 6510bd99a1e67df8523298f21465a73d76ad6f1e Mon Sep 17 00:00:00 2001 From: David Brochart Date: Fri, 22 May 2020 11:30:07 +0200 Subject: [PATCH] Use GH actions to test on OSX and Windows as well (#63) --- .github/workflows/main.yml | 42 +++++++++++++++++++++++++++++++++++ README.md | 1 + nbclient/tests/test_client.py | 17 +++++++------- requirements-dev.txt | 1 - tox.ini | 8 ++++++- 5 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..310ca41e --- /dev/null +++ b/.github/workflows/main.yml @@ -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 diff --git a/README.md b/README.md index 665a219d..6c4c1f5d 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/nbclient/tests/test_client.py b/nbclient/tests/test_client.py index 5831da88..de41435a 100644 --- a/nbclient/tests/test_client.py +++ b/nbclient/tests/test_client.py @@ -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 @@ -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. @@ -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 == "" diff --git a/requirements-dev.txt b/requirements-dev.txt index c4c246b2..484c6fe8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,7 +9,6 @@ check-manifest flake8 tox bumpversion -pebble xmltodict black; python_version >= '3.6' pip>=18.1 diff --git a/tox.ini b/tox.ini index e316ca31..77a23631 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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]