Skip to content

Commit 8f9a7d5

Browse files
authored
Merge pull request #349 from bollwyvl/master
add github actions
2 parents bc27465 + d831456 commit 8f9a7d5

File tree

7 files changed

+247
-3
lines changed

7 files changed

+247
-3
lines changed

.github/workflows/ci.yml

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: '*'
8+
9+
env:
10+
PIP_DISABLE_PIP_VERSION_CHECK: 1
11+
PYTHONUNBUFFERED: 1
12+
PYTHONIOENCODING: utf-8
13+
CACHE_EPOCH: 0
14+
15+
defaults:
16+
run:
17+
shell: bash -l {0}
18+
19+
jobs:
20+
build:
21+
name: build
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check out
25+
uses: actions/checkout@v2
26+
- name: Set up python
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: 3.9
30+
- name: Set up node
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: 14.x
34+
- name: Cache pip packages
35+
uses: actions/cache@v1
36+
with:
37+
path: ~/.cache/pip
38+
key: |
39+
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-${{ hashFiles('setup.py', 'pyproject.toml') }}
40+
restore-keys: |
41+
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-
42+
- name: Install installation dependencies
43+
run: |
44+
set -eux
45+
python -m pip install -vv -U --user pip wheel setuptools
46+
yarn --version || npm install -g yarn
47+
- name: Install packaging dependencies
48+
run: |
49+
set -eux
50+
python -m pip install -vv 'jupyterlab~=3.0'
51+
- name: Pre-install node dependencies
52+
run: |
53+
set -eux
54+
cd js
55+
yarn --ignore-optional
56+
- name: Build sdist
57+
run: python setup.py sdist
58+
- name: Build wheel
59+
run: python setup.py bdist_wheel
60+
- name: Collect and hash distributions
61+
run: |
62+
set -eux
63+
cp js/lab-dist/jupyter-threejs-*.tgz dist
64+
cd dist
65+
sha256sum * | tee SHA256SUMS
66+
- name: Upload distributions
67+
uses: actions/upload-artifact@v2
68+
with:
69+
name: dist ${{ github.run_number }}
70+
path: ./dist
71+
72+
docs:
73+
name: docs
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Check out
77+
uses: actions/checkout@v2
78+
- name: Install apt dependencies
79+
run: |
80+
set -eux
81+
sudo apt install pandoc
82+
- name: Set up python
83+
uses: actions/setup-python@v2
84+
with:
85+
python-version: 3.9
86+
- name: Install installation dependencies
87+
run: |
88+
set -eux
89+
python -m pip install -vv -U --user pip wheel setuptools
90+
- name: Set up node
91+
uses: actions/setup-node@v2
92+
with:
93+
node-version: 14.x
94+
- name: Install package and docs dependencies
95+
run: |
96+
set -eux
97+
pip install -vv -U -e .[docs,examples,test] requests_cache
98+
- name: Validate docs environment
99+
run: |
100+
set -eux
101+
pip freeze
102+
pip check
103+
- name: Build docs
104+
run: |
105+
set -eux
106+
cd docs
107+
make html
108+
- name: Upload docs
109+
uses: actions/upload-artifact@v2
110+
with:
111+
name: docs ${{ github.run_number }}
112+
path: ./docs/build
113+
- name: Get current date
114+
id: date
115+
run: |
116+
echo "::set-output name=year::$(date +'%Y')"
117+
echo "::set-output name=week::$(date +'%U')"
118+
- name: Cache links
119+
uses: actions/cache@v1
120+
with:
121+
path: ./build/links
122+
key: |
123+
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-${{ steps.date.outputs.year }}-${{ steps.date.outputs.week }}
124+
restore-keys: |
125+
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-${{ steps.date.outputs.year }}-
126+
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-
127+
- name: Check links
128+
run: |
129+
set -eux
130+
mkdir -p build/links/cache
131+
pytest-check-links --check-links-cache --check-links-cache-name ./build/links/cache
132+
133+
test:
134+
name: test ${{ matrix.os }}${{ matrix.python }} ${{ matrix.node }} ${{ matrix.lab }}
135+
needs: [build]
136+
runs-on: ${{ matrix.os }}-latest
137+
strategy:
138+
fail-fast: false
139+
matrix:
140+
os: [ubuntu, macos, windows]
141+
python: [3.6, 3.7, 3.8, 3.9]
142+
include:
143+
- python: 3.6
144+
dist: 'pythreejs*.tar.gz'
145+
- python: 3.7
146+
dist: 'pythreejs*.whl'
147+
lab: 1
148+
node: 10
149+
- python: 3.8
150+
dist: 'pythreejs*.whl'
151+
lab: 2
152+
node: 14
153+
- python: 3.9
154+
dist: 'pythreejs*.whl'
155+
lab: 3
156+
- os: windows
157+
py_cmd: python
158+
- os: macos
159+
py_cmd: python3
160+
- os: ubuntu
161+
py_cmd: python
162+
steps:
163+
- name: Check out
164+
uses: actions/checkout@v2
165+
- name: Set up python
166+
uses: actions/setup-python@v2
167+
with:
168+
python-version: 3.8
169+
- if: ${{ matrix.node }}
170+
name: Set up node
171+
uses: actions/setup-node@v2
172+
with:
173+
node-version: ${{ matrix.node }}
174+
- name: Download distributions
175+
uses: actions/download-artifact@v2
176+
with:
177+
name: dist ${{ github.run_number }}
178+
path: ./dist
179+
- name: Install installation dependencies
180+
run: |
181+
set -eux
182+
${{ matrix.py_cmd }} -m pip install -vv --user -U pip wheel setuptools
183+
- name: Install package
184+
run: |
185+
set -eux
186+
cd dist
187+
${{ matrix.py_cmd }} -m pip install -vv ${{ matrix.dist }}
188+
- name: Validate environment
189+
run: |
190+
set -eux
191+
${{ matrix.py_cmd }} -m pip freeze
192+
${{ matrix.py_cmd }} -m pip check
193+
- if: ${{ matrix.lab }}
194+
name: Install JupyterLab
195+
run: |
196+
set -eux
197+
${{ matrix.py_cmd }} -m pip install -vv 'jupyterlab==${{ matrix.lab }}.*'
198+
- name: Install test dependencies
199+
# explicit file installs don't support extras, skimage brings most along
200+
run: |
201+
set -eux
202+
${{ matrix.py_cmd }} -m pip install -vv nbval scikit-image ipywebrtc pytest-cov codecov
203+
- name: Run python tests
204+
# remove the source directory to avoid surprises
205+
run: |
206+
set -eux
207+
rm -rf pythreejs
208+
${{ matrix.py_cmd }} -m pytest -vv -l --nbval-lax --current-env . --cov pythreejs --cov-report term-missing:skip-covered --no-cov-on-fail
209+
- name: Upload coverage
210+
run: |
211+
set -eux
212+
codecov
213+
- name: Check notebook extension
214+
run: |
215+
set -eux
216+
jupyter nbextension list
217+
jupyter nbextension list 2>&1 | grep -ie "jupyter-threejs/extension.*enabled" -
218+
- if: ${{ matrix.node }}
219+
name: Install lab extension
220+
run: |
221+
set -eux
222+
jupyter labextension install --no-build --debug ./dist/*.tgz @jupyter-widgets/jupyterlab-manager
223+
- if: ${{ matrix.node }}
224+
name: Build lab
225+
run: |
226+
set -eux
227+
jupyter lab build --debug
228+
- if: ${{ matrix.lab }}
229+
name: Check lab extension
230+
run: |
231+
set -eux
232+
jupyter labextension list
233+
jupyter labextension list 2>&1 | grep -ie "jupyter-threejs.*enabled.*ok" -

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ docs/source/examples/img
3535

3636
js/lab-dist
3737
js/package-lock.json
38+
pythreejs/labextension

docs/source/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
# Ensure our extension is available:
3838
import sys
3939
from os.path import dirname, join as pjoin
40+
from sphinx.util import logging
41+
logger = logging.getLogger(__name__)
4042
docs = dirname(dirname(__file__))
4143
root = dirname(docs)
4244
sys.path.insert(0, root)
@@ -210,7 +212,7 @@ def setup(app):
210212
def add_scripts(app):
211213
for fname in ['jupyter-threejs.js']:
212214
if not os.path.exists(os.path.join(here, '_static', fname)):
213-
app.warn('missing javascript file: %s' % fname)
215+
logger.warn('missing javascript file: %s' % fname)
214216
app.add_javascript(fname)
215217

216218
def add_images(app):

js/scripts/templates/py_enums.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class EnumNamespace:
1515
def __contains__(self, key):
1616
return key in self.__dict__
1717

18+
def __iter__(self):
19+
yield from filter(lambda e: not e.startswith('_'), dir(self))
20+
1821
def __repr__(self):
1922
return str(list(filter(lambda e: not e.startswith('_'), dir(self))))
2023

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[build-system]
22
requires = ["jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
3-
build-backend = "setuptools.build_meta"

pythreejs/enums.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def __init__(self, **kwargs):
1515
def __contains__(self, key):
1616
return key in self.__dict__
1717

18+
def __iter__(self):
19+
yield from filter(lambda e: not e.startswith('_'), dir(self))
20+
1821
def __repr__(self):
1922
return str(list(filter(lambda e: not e.startswith('_'), dir(self))))
2023

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# -*- coding: utf-8 -*-
22
from pathlib import Path
33

4+
HERE = Path(__file__).parent.resolve()
5+
6+
import setupbase
7+
48
from setupbase import (
59
log,
610
create_cmdclass,
@@ -14,7 +18,6 @@
1418

1519
LONG_DESCRIPTION = 'A Python/ThreeJS bridge utilizing the Jupyter widget infrastructure.'
1620

17-
HERE = Path(__file__).parent.resolve()
1821
name = 'pythreejs'
1922
py_path = (HERE / name)
2023
js_path = (HERE / "js")

0 commit comments

Comments
 (0)