Skip to content

Commit

Permalink
Merge pull request #134 from marcusianlevine/master
Browse files Browse the repository at this point in the history
Add Travis CI setup and simple tests
  • Loading branch information
betatim authored Jul 29, 2019
2 parents 455432a + 676fe1e commit 8f597a8
Show file tree
Hide file tree
Showing 13 changed files with 395 additions and 125 deletions.
16 changes: 16 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[run]
parallel = True
branch = False
omit =
ldapauthenticator/tests/*

[report]
exclude_lines =
if self.debug:
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
ignore_errors = True
omit =
ldapauthenticator/tests/*
*/site-packages/*
22 changes: 22 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[flake8]
# Ignore style and complexity
# E: style errors
# W: style warnings
# C: complexity
# F401: module imported but unused
# F403: import *
# F811: redefinition of unused `name` from line `N`
# F841: local variable assigned but never used
# E402: module level import not at top of file
# I100: Import statements are in the wrong order
# I101: Imported names are in the wrong order. Should be
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
builtins = c, get_config
exclude =
.cache,
.github,
onbuild,
scripts,
share,
tools,
setup.py
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.5
hooks:
- id: reorder-python-imports
language_version: python3.6
- repo: https://github.com/ambv/black
rev: 18.9b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: flake8
59 changes: 59 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
dist: xenial
language: python
sudo: false
cache:
- pip
python:
- 3.7
- 3.6
env:
global:
- ASYNC_TEST_TIMEOUT=15
- LDAP_HOST=127.0.0.1
services:
- docker

# installing dependencies
before_install:
- set -e
install:
- pip install --upgrade pip
- pip install --upgrade --pre -r dev-requirements.txt .
- pip freeze
- |
# start LDAP server
if [[ -z "$TEST" ]]; then
ci/docker-ldap.sh
fi
# running tests
script:
- |
# run tests
if [[ -z "$TEST" ]]; then
pytest -v --maxfail=2 --cov=ldapauthenticator ldapauthenticator/tests
fi
- |
# run autoformat
if [[ "$TEST" == "lint" ]]; then
pre-commit run --all-files
fi
after_success:
- codecov
after_failure:
- |
# point to auto-lint-fix
if [[ "$TEST" == "lint" ]]; then
echo "You can install pre-commit hooks to automatically run formatting"
echo "on each commit with:"
echo " pre-commit install"
echo "or you can run by hand on staged files with"
echo " pre-commit run"
echo "or after-the-fact on already committed files with"
echo " pre-commit run --all-files"
fi
matrix:
fast_finish: true
include:
- python: 3.6
env: TEST=lint
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ldapauthenticator

[![Build Status](https://travis-ci.com/jupyterhub/ldapauthenticator.svg?branch=master)](https://travis-ci.com/jupyterhub/ldapauthenticator)

Simple LDAP Authenticator Plugin for JupyterHub

## Installation ##
Expand All @@ -11,7 +13,7 @@ pip install jupyterhub-ldapauthenticator
```
...or using conda with:
```
conda install -c conda-forge jupyterhub-ldapauthenticator
conda install -c conda-forge jupyterhub-ldapauthenticator
```


Expand Down Expand Up @@ -219,4 +221,3 @@ JupyterHub create local accounts using the LDAPAuthenticator.

Issue [#19](https://github.com/jupyterhub/ldapauthenticator/issues/19) provides
additional discussion on local user creation.

13 changes: 13 additions & 0 deletions ci/docker-ldap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# source this file to setup LDAP
# for local testing (as similar as possible to docker)

set -e

NAME="hub-test-ldap"
DOCKER_RUN="docker run -d --name $NAME"
RUN_ARGS="-p 389:389 -p 636:636 rroemhild/test-openldap"

docker rm -f "$NAME" 2>/dev/null || true

$DOCKER_RUN $RUN_ARGS
13 changes: 13 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
beautifulsoup4
codecov
coverage
cryptography
html5lib # needed for beautifulsoup
mock
notebook
pre-commit
pytest-asyncio
pytest-cov
pytest>=3.3
requests-mock
virtualenv
Loading

0 comments on commit 8f597a8

Please sign in to comment.