diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..05c6e97 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,21 @@ +[bumpversion] +current_version = 0.4.0.dev +parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z0-9]+))? +tag_name = {new_version} +allow_dirty = True +commit = True +tag = False +serialize = + {major}.{minor}.{patch}.{release} + {major}.{minor}.{patch} + +[bumpversion:file:ltiauthenticator/__init__.py] + +[bumpversion:file:setup.py] + +[bumpversion:part:release] +optional_value = stable +values = + dev + stable + diff --git a/.travis.yml b/.travis.yml index 1998d36..46cb02f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,31 @@ +dist: bionic language: python -sudo: false python: + - 3.8 + - 3.7 - 3.6 - 3.5 -# install dependencies +# initial step - install dependencies install: - - pip install --no-cache-dir -e . - - pip install --no-cache-dir -r dev-requirements.txt + - pip install --upgrade pip + - pip install -r dev-requirements.txt + - pip install . + - pip freeze -# command to run tests +# middle step - run tests script: - - py.test tests/ + - pytest --verbose --flakes -matrix: - fast_finish: true +# final step - optionally deploy +deploy: + provider: pypi + user: "__token__" + # password: set by TravisCI's environment variable PYPI_PASSWORD + # ref: https://travis-ci.org/jupyterhub/ltiauthenticator/settings + distributions: sdist bdist_wheel + on: + # Only deploy on tagged commits instead of the default of only doing it to + # the master branch. A tag does not belong specifically to a branch, so + # without this it would fail to deploy for tags. + tags: true diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..55f7ce7 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,71 @@ +# How to make a release + +`jupyterhub-ltiauthenticator` is a package [available on +PyPI](https://pypi.org/project/jupyterhub-ltiauthenticator/). These are +instructions on how to make a release on PyPI. The PyPI release is packaged and +published automatically by TravisCI when a git tag is pushed. + +For you to follow along according to these instructions, you need: +- To have push rights to the [ltiauthenticator GitHub + repository](https://github.com/jupyterhub/ltiauthenticator). + +## Steps to make a release + +1. Update [CHANGELOG.md](CHANGELOG.md) if it is not up to date, and verify + [README.md](README.md) has an updated output of running `--help`. Make a PR + to review the CHANGELOG notes. + + To get the foundation of the changelog written, you can install + [github-activity](https://github.com/choldgraf/github-activity) and run + `github-activity --kind pr jupyterhub/ltiauthenticator` after setting up + credentials as described in the project's README.md file. + +1. Once the changelog is up to date, checkout master and make sure it is up to date and clean. + + ```bash + ORIGIN=${ORIGIN:-origin} # set to the canonical remote, e.g. 'upstream' if 'origin' is not the official repo + git checkout master + git fetch $ORIGIN master + git reset --hard $ORIGIN/master + # WARNING! This next command deletes any untracked files in the repo + git clean -xfd + ``` + +1. Update the version with `bump2version` (can be installed with `pip install -r + dev-requirements.txt`) + + ```bash + VERSION=... # e.g. 1.2.3 + bump2version --tag --new-version $VERSION - + ``` + +1. Reset the version to the next development version with `bump2version` + + ```bash + bump2version --no-tag patch + ``` + +1. Push your two commits to master along with the annotated tags referencing + commits on master. + + ``` + git push --follow-tags $ORIGIN master + ``` + +## Manually uploading to PyPI + +We are using CD with Travis to automatically update PyPI, but if you want to do +it manually when you are on a tagged commit in a otherwise cleaned repository, +you can do this. + +1. Package the release + + ```bash + python3 setup.py sdist bdist_wheel + ``` + +1. Upload it to PyPI + + ```bash + twine upload dist/* + ``` diff --git a/dev-requirements.txt b/dev-requirements.txt index e079f8a..c44a964 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1,3 @@ +bump2version pytest +pytest-flakes diff --git a/ltiauthenticator/__init__.py b/ltiauthenticator/__init__.py index 79bf6af..0f2b8d3 100644 --- a/ltiauthenticator/__init__.py +++ b/ltiauthenticator/__init__.py @@ -1,6 +1,6 @@ import time -from traitlets import Bool, Dict +from traitlets import Dict from tornado import gen, web from jupyterhub.auth import Authenticator @@ -10,6 +10,8 @@ from oauthlib.oauth1.rfc5849 import signature from collections import OrderedDict +__version__ = '0.4.0.dev' + class LTILaunchValidator: # Record time when process starts, so we can reject requests made # before this @@ -184,5 +186,30 @@ class LTIAuthenticateHandler(BaseHandler): @gen.coroutine def post(self): - user = yield self.login_user() - self.redirect(self.get_body_argument('custom_next', self.get_next_url())) + """ + Technical reference of relevance to understand this function + ------------------------------------------------------------ + 1. Class dependencies + - jupyterhub.handlers.BaseHandler: https://github.com/jupyterhub/jupyterhub/blob/abb93ad799865a4b27f677e126ab917241e1af72/jupyterhub/handlers/base.py#L69 + - tornado.web.RequestHandler: https://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler + 2. Function dependencies + - login_user: https://github.com/jupyterhub/jupyterhub/blob/abb93ad799865a4b27f677e126ab917241e1af72/jupyterhub/handlers/base.py#L696-L715 + login_user is defined in the JupyterHub wide BaseHandler class, + mainly wraps a call to the authenticate function and follow up. + a successful authentication with a call to auth_to_user that + persists a JupyterHub user and returns it. + - get_next_url: https://github.com/jupyterhub/jupyterhub/blob/abb93ad799865a4b27f677e126ab917241e1af72/jupyterhub/handlers/base.py#L587 + - get_body_argument: https://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.get_body_argument + """ + # FIXME: Figure out if we want to pass the user returned from + # self.login_user() to self.get_next_url(). It is named + # _ for now as pyflakes is fine about having an unused + # variable named _. + _ = yield self.login_user() + next_url = self.get_next_url() + body_argument = self.get_body_argument( + name='custom_next', + default=next_url, + ) + + self.redirect(body_argument) diff --git a/setup.py b/setup.py index 09872e3..68f5f35 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='jupyterhub-ltiauthenticator', - version='0.3', + version='0.4.0.dev', description='JupyterHub authenticator implementing LTI v1', url='https://github.com/yuvipanda/jupyterhub-ltiauthenticator', author='Yuvi Panda',