diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b5d0e33 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +language: python + +# Needed so we can spawn docker containers +sudo: required +services: + - docker + +addons: + apt: + packages: + - build-essential + +python: + - 3.5 + - 3.4 +env: + - JHUB_VERSION=master + - JHUB_VERSION=latest # latest released version + +before_install: + - npm install + - npm install -g configurable-http-proxy + - git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels +install: ./build_tools/travis/install.sh + +script: + - nose2 -v --start-dir everware # unit tests live in everware/ + - ./build_tools/travis/test_frontend.sh + +# Make travis quiet +notifications: + email: false diff --git a/base_config.py b/base_config.py new file mode 100644 index 0000000..ae25a20 --- /dev/null +++ b/base_config.py @@ -0,0 +1,34 @@ +import os +import everware +import jupyterhub.handlers.pages +import jupyterhub.handlers.base + + +# TODO: find a way to change default handlers +# instead of this shit +jupyterhub.handlers.base.UserSpawnHandler.get = everware.UserSpawnHandler.get +jupyterhub.handlers.pages.SpawnHandler.post = everware.SpawnHandler.post +jupyterhub.handlers.pages.SpawnHandler.get = everware.SpawnHandler.get +jupyterhub.handlers.pages.SpawnHandler._spawn = everware.SpawnHandler._spawn +jupyterhub.handlers.pages.HomeHandler.get = everware.HomeHandler.get + +c = get_config() + +# spawn with custom docker containers +c.JupyterHub.spawner_class = 'everware.CustomDockerSpawner' + +c.Spawner.tls = False +c.Spawner.debug = True +c.Spawner.start_timeout = 1000 +c.Spawner.remove_containers = True +c.Spawner.tls_assert_hostname = False +c.Spawner.use_docker_client_env = True + +# The docker containers need access to the Hub, so the default loopback +# port doesn't work: +from jupyter_client.localinterfaces import public_ips +c.JupyterHub.hub_ip = public_ips()[0] +c.JupyterHub.hub_api_ip = public_ips()[0] + +c.JupyterHub.data_files_path = 'share' +c.JupyterHub.template_paths = ['share/static/html'] diff --git a/build_tools/travis/frontend_test_config.py b/build_tools/travis/frontend_test_config.py new file mode 100644 index 0000000..fce645e --- /dev/null +++ b/build_tools/travis/frontend_test_config.py @@ -0,0 +1,4 @@ +c = get_config() +load_subconfig('base_config.py') + +c.JupyterHub.authenticator_class = 'dummyauthenticator.DummyAuthenticator' diff --git a/build_tools/travis/install.sh b/build_tools/travis/install.sh new file mode 100755 index 0000000..4d43f91 --- /dev/null +++ b/build_tools/travis/install.sh @@ -0,0 +1,15 @@ +#! /usr/bin/env bash + +if [[ "$JHUB_VERSION" == "master" ]]; then + echo "Using jupyterhub master" + pushd /tmp + git clone --quiet --depth 1 https://github.com/jupyter/jupyterhub.git + cd jupyterhub + pip install -r requirements.txt -e. + python setup.py js + python setup.py css + popd + echo "Done installing jupyterhub master" +fi + +pip install -f travis-wheels/wheelhouse -r requirements.txt . diff --git a/build_tools/travis/test_frontend.sh b/build_tools/travis/test_frontend.sh new file mode 100755 index 0000000..13be3ad --- /dev/null +++ b/build_tools/travis/test_frontend.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# This script is meant to be run from the script step in .travis.yml +# The tests run by this script are "frontend" testing + +set -e +echo "In" `pwd` + +# Start a hub that our tests can interact with +echo "Starting everware" +jupyterhub -f build_tools/travis/frontend_test_config.py \ + --no-ssl --debug & +sleep 3 + +echo "Start running frontend tests" +nose2 -v --start-dir frontend_tests diff --git a/frontend_tests/.empty b/frontend_tests/.empty new file mode 100644 index 0000000..e69de29 diff --git a/local_dockermachine_config.py b/local_dockermachine_config.py new file mode 100644 index 0000000..ba7e4e3 --- /dev/null +++ b/local_dockermachine_config.py @@ -0,0 +1,21 @@ +import os +import everware + + +c = get_config() +load_subconfig('base_config.py') + +authenticator = everware.GitHubOAuthenticator +c.JupyterHub.authenticator_class = 'everware.GitHubOAuthenticator' +whitelist_file = 'whitelist.txt' +whitelist_handler = everware.DefaultWhitelistHandler(whitelist_file, + c, + authenticator) +c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL'] +c.GitHubOAuthenticator.client_id = os.environ['GITHUB_CLIENT_ID'] +c.GitHubOAuthenticator.client_secret = os.environ['GITHUB_CLIENT_SECRET'] + +# change this to the ip that `boot2docker ip` or +# `docker-machine ip `tells you if +# you use boot2docker/a VM, otherwise remove the line +c.Spawner.container_ip = '192.168.99.100' diff --git a/requirements.txt b/requirements.txt index f3faa05..c52a3ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ ipython[notebook] coveralls -pytest-cov -pytest +nose2 +selenium +jupyterhub-dummyauthenticator jupyterhub dockerspawner GitPython==1.0.1