Skip to content

add github actions #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: '*'

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PYTHONUNBUFFERED: 1
PYTHONIOENCODING: utf-8
CACHE_EPOCH: 0

defaults:
run:
shell: bash -l {0}

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Cache pip packages
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-${{ hashFiles('setup.py', 'pyproject.toml') }}
restore-keys: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-
- name: Install installation dependencies
run: |
set -eux
python -m pip install -vv -U --user pip wheel setuptools
yarn --version || npm install -g yarn
- name: Install packaging dependencies
run: |
set -eux
python -m pip install -vv 'jupyterlab~=3.0'
- name: Pre-install node dependencies
run: |
set -eux
cd js
yarn --ignore-optional
- name: Build sdist
run: python setup.py sdist
- name: Build wheel
run: python setup.py bdist_wheel
- name: Collect and hash distributions
run: |
set -eux
cp js/lab-dist/jupyter-threejs-*.tgz dist
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v2
with:
name: dist ${{ github.run_number }}
path: ./dist

docs:
name: docs
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: Install apt dependencies
run: |
set -eux
sudo apt install pandoc
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install installation dependencies
run: |
set -eux
python -m pip install -vv -U --user pip wheel setuptools
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install package and docs dependencies
run: |
set -eux
pip install -vv -U -e .[docs,examples,test] requests_cache
- name: Validate docs environment
run: |
set -eux
pip freeze
pip check
- name: Build docs
run: |
set -eux
cd docs
make html
- name: Upload docs
uses: actions/upload-artifact@v2
with:
name: docs ${{ github.run_number }}
path: ./docs/build
- name: Get current date
id: date
run: |
echo "::set-output name=year::$(date +'%Y')"
echo "::set-output name=week::$(date +'%U')"
- name: Cache links
uses: actions/cache@v1
with:
path: ./build/links
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-${{ steps.date.outputs.year }}-${{ steps.date.outputs.week }}
restore-keys: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-${{ steps.date.outputs.year }}-
${{ env.CACHE_EPOCH }}-${{ runner.os }}-links-
- name: Check links
run: |
set -eux
mkdir -p build/links/cache
pytest-check-links --check-links-cache --check-links-cache-name ./build/links/cache

test:
name: test ${{ matrix.os }}${{ matrix.python }} ${{ matrix.node }} ${{ matrix.lab }}
needs: [build]
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python: [3.6, 3.7, 3.8, 3.9]
include:
- python: 3.6
dist: 'pythreejs*.tar.gz'
- python: 3.7
dist: 'pythreejs*.whl'
lab: 1
node: 10
- python: 3.8
dist: 'pythreejs*.whl'
lab: 2
node: 14
- python: 3.9
dist: 'pythreejs*.whl'
lab: 3
- os: windows
py_cmd: python
- os: macos
py_cmd: python3
- os: ubuntu
py_cmd: python
steps:
- name: Check out
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.8
- if: ${{ matrix.node }}
name: Set up node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Download distributions
uses: actions/download-artifact@v2
with:
name: dist ${{ github.run_number }}
path: ./dist
- name: Install installation dependencies
run: |
set -eux
${{ matrix.py_cmd }} -m pip install -vv --user -U pip wheel setuptools
- name: Install package
run: |
set -eux
cd dist
${{ matrix.py_cmd }} -m pip install -vv ${{ matrix.dist }}
- name: Validate environment
run: |
set -eux
${{ matrix.py_cmd }} -m pip freeze
${{ matrix.py_cmd }} -m pip check
- if: ${{ matrix.lab }}
name: Install JupyterLab
run: |
set -eux
${{ matrix.py_cmd }} -m pip install -vv 'jupyterlab==${{ matrix.lab }}.*'
- name: Install test dependencies
# explicit file installs don't support extras, skimage brings most along
run: |
set -eux
${{ matrix.py_cmd }} -m pip install -vv nbval scikit-image ipywebrtc pytest-cov codecov
- name: Run python tests
# remove the source directory to avoid surprises
run: |
set -eux
rm -rf pythreejs
${{ matrix.py_cmd }} -m pytest -vv -l --nbval-lax --current-env . --cov pythreejs --cov-report term-missing:skip-covered --no-cov-on-fail
- name: Upload coverage
run: |
set -eux
codecov
- name: Check notebook extension
run: |
set -eux
jupyter nbextension list
jupyter nbextension list 2>&1 | grep -ie "jupyter-threejs/extension.*enabled" -
- if: ${{ matrix.node }}
name: Install lab extension
run: |
set -eux
jupyter labextension install --no-build --debug ./dist/*.tgz @jupyter-widgets/jupyterlab-manager
- if: ${{ matrix.node }}
name: Build lab
run: |
set -eux
jupyter lab build --debug
- if: ${{ matrix.lab }}
name: Check lab extension
run: |
set -eux
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyter-threejs.*enabled.*ok" -
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ docs/source/examples/img

js/lab-dist
js/package-lock.json
pythreejs/labextension
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# Ensure our extension is available:
import sys
from os.path import dirname, join as pjoin
from sphinx.util import logging
logger = logging.getLogger(__name__)
docs = dirname(dirname(__file__))
root = dirname(docs)
sys.path.insert(0, root)
Expand Down Expand Up @@ -210,7 +212,7 @@ def setup(app):
def add_scripts(app):
for fname in ['jupyter-threejs.js']:
if not os.path.exists(os.path.join(here, '_static', fname)):
app.warn('missing javascript file: %s' % fname)
logger.warn('missing javascript file: %s' % fname)
app.add_javascript(fname)

def add_images(app):
Expand Down
3 changes: 3 additions & 0 deletions js/scripts/templates/py_enums.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class EnumNamespace:
def __contains__(self, key):
return key in self.__dict__

def __iter__(self):
yield from filter(lambda e: not e.startswith('_'), dir(self))

def __repr__(self):
return str(list(filter(lambda e: not e.startswith('_'), dir(self))))

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[build-system]
requires = ["jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
3 changes: 3 additions & 0 deletions pythreejs/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, **kwargs):
def __contains__(self, key):
return key in self.__dict__

def __iter__(self):
yield from filter(lambda e: not e.startswith('_'), dir(self))

def __repr__(self):
return str(list(filter(lambda e: not e.startswith('_'), dir(self))))

Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
from pathlib import Path

HERE = Path(__file__).parent.resolve()

import setupbase

from setupbase import (
log,
create_cmdclass,
Expand All @@ -14,7 +18,6 @@

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

HERE = Path(__file__).parent.resolve()
name = 'pythreejs'
py_path = (HERE / name)
js_path = (HERE / "js")
Expand Down