Skip to content

Commit 0db51e9

Browse files
committed
🧪 TESTS: Move to GitHub Actions for CI
1 parent 5bd7c7f commit 0db51e9

5 files changed

Lines changed: 107 additions & 58 deletions

File tree

.github/workflows/tests.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: continuous-integration
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre-commit:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python 3.7
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: 3.7
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -e .[cli,code_style]
20+
- name: Run pre-commit
21+
run: |
22+
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
23+
24+
25+
tests:
26+
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest]
30+
python-version: [3.6, 3.7, 3.8]
31+
include:
32+
- os: windows-latest
33+
python-version: 3.7
34+
35+
runs-on: ${{ matrix.os }}
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Set up Python ${{ matrix.python-version }}
40+
uses: actions/setup-python@v1
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
- name: Install dependencies
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install -e .[cli,testing]
47+
- name: Run pytest
48+
run: |
49+
pytest --durations=10 --cov=jupyter_cache --cov-report=xml --cov-report=term-missing
50+
coverage xml
51+
# for some reason the tests/conftest.py::check_nbs fixture breaks pytest-cov's cov-report outputting
52+
# this is why we run `coverage xml` afterwards (required by codecov)
53+
- name: Upload to Codecov
54+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7 && github.repository == 'executablebooks/jupyter-cache'
55+
uses: codecov/codecov-action@v1
56+
with:
57+
name: jupyter-cache-pytests-py3.7
58+
flags: pytests
59+
file: ./coverage.xml
60+
fail_ci_if_error: true
61+
62+
publish:
63+
64+
name: Publish to PyPi
65+
needs: [pre-commit, tests]
66+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout source
70+
uses: actions/checkout@v2
71+
- name: Set up Python 3.7
72+
uses: actions/setup-python@v1
73+
with:
74+
python-version: 3.7
75+
- name: Build package
76+
run: |
77+
pip install wheel
78+
python setup.py sdist bdist_wheel
79+
- name: Publish
80+
uses: pypa/gh-action-pypi-publish@v1.1.0
81+
with:
82+
user: __token__
83+
password: ${{ secrets.PYPI_KEY }}

.readthedocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ python:
77
path: .
88
extra_requirements:
99
- rtd
10+
11+
sphinx:
12+
builder: html
13+
fail_on_warning: true

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

jupyter_cache/executors/basic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ def execute(self, input_iterator, timeout=30):
157157
and "timeout" in nb_bundle.nb.metadata.execution
158158
):
159159
timeout = nb_bundle.nb.metadata.execution.timeout
160-
executenb(nb_bundle.nb, cwd=tmpdirname, timeout=timeout)
160+
# TODO: for now we don't use the new record_timing feature
161+
# because it can affect test results
162+
executenb(
163+
nb_bundle.nb,
164+
cwd=tmpdirname,
165+
timeout=timeout,
166+
record_timing=False,
167+
)
161168
except Exception:
162169
exc_string = "".join(traceback.format_exc())
163170
self.logger.error("Execution Failed: {}".format(uri))

tests/notebooks/external_output.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 1,
14+
"execution_count": 2,
1515
"metadata": {},
1616
"source": [
17-
"with open('artifact.txt', 'w',encoding=\"utf-8\") as handle:"
17+
"with open('artifact.txt', 'w', encoding='utf-8') as handle:\n",
18+
" handle.write('hi')"
1819
],
19-
"outputs": []
20-
},
21-
{
22-
"cell_type": "code",
23-
"execution_count": null,
24-
"metadata": {},
25-
"outputs": [],
26-
"source": []
20+
"outputs": [
21+
{
22+
"name": "stdout",
23+
"output_type": "stream",
24+
"text": [
25+
"1\n"
26+
]
27+
}
28+
]
2729
}
2830
],
2931
"metadata": {

0 commit comments

Comments
 (0)