From 882096139d1a0d549d24d7f5a43931051192b1cb Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 16:02:14 -0500 Subject: [PATCH 01/17] Allow building from tags Adds --build-tags flag. How to use is described in the recipes in the docs. Will need to push some tags to GitHub to test this. Fixes #29. --- docs/recipes.rst | 19 +++++++++++++++++++ doctr/__main__.py | 10 +++++++--- doctr/travis.py | 14 +++++++++++--- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docs/recipes.rst b/docs/recipes.rst index c1b0791a..d82f7610 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -37,6 +37,25 @@ For security purposes, it is not possible to deploy from branches on forks requests from forks). If you want to deploy the docs for a branch from a pull request, you will need to push it up to the main repository. +Deploy docs from git tags +========================= + +Travis CI runs separate builds for git tags that are pushed to your repo. By +default, doctr does not deploy on these builds, but it can be enabled with the +``--build-tags`` flag to ``doctr deploy``. This is useful if you want to use +doctr to deploy versioned docs for releases, for example. + +On Travis CI, the tag is set to the environment variable ``$TRAVIS_TAG``, +which is empty otherwise. The following will deploy the docs to ``dev`` for +normal ``master`` builds, and ``version-`` for tag builds: + + - if [[ -z "$TRAVIS_TAG" ]]; then + DEPLOY_DIR=dev; + else + DEPLOY_DIR="version-$TRAVIS_TAG"; + fi + - doctr deploy --build-tags --built-docs build/ $DEPLOY_DIR + Deploy to a separate repo ========================= diff --git a/doctr/__main__.py b/doctr/__main__.py index ff6a4a64..cc8d6d84 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -159,6 +159,9 @@ def get_parser(config=None): deploy_parser_add_argument('--no-push', dest='push', action='store_false', default=True, help="Run all the steps except the last push step. " "Useful for debugging") + deploy_parser_add_argument('--build-tags', default=False, help="""Deploy + on tag builds. On a tag build, $TRAVIS_TAG is set to the name of the + tag. The default is to not deploy on tag builds.""") deploy_parser_add_argument('--gh-pages-docs', default=None, help="""!!DEPRECATED!! Directory to deploy the html documentation to on gh-pages. The default is %(default)r. The deploy directory should be passed as @@ -255,9 +258,10 @@ def deploy(args, parser): branch_whitelist.update(set(config.get('branches',set({})))) canpush = setup_GitHub_push(deploy_repo, deploy_branch=deploy_branch, - auth_type='token' if args.token else 'deploy_key', - full_key_path=args.key_path, - branch_whitelist=branch_whitelist) + auth_type='token' if args.token else 'deploy_key', + full_key_path=args.key_path, + branch_whitelist=branch_whitelist, + build_tag=args.build_tag) if args.command: run(args.command, shell=True) diff --git a/doctr/travis.py b/doctr/travis.py index 32cf8c0e..968da1f2 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -160,7 +160,9 @@ def get_travis_branch(): else: return os.environ.get("TRAVIS_BRANCH", "") -def setup_GitHub_push(deploy_repo, auth_type='deploy_key', full_key_path='github_deploy_key.enc', require_master=None, branch_whitelist=None, deploy_branch='gh-pages'): +def setup_GitHub_push(deploy_repo, auth_type='deploy_key', + full_key_path='github_deploy_key.enc', require_master=None, + branch_whitelist=None, deploy_branch='gh-pages', build_tags=False): """ Setup the remote to push to GitHub (to be run on Travis). @@ -172,6 +174,8 @@ def setup_GitHub_push(deploy_repo, auth_type='deploy_key', full_key_path='github For ``auth_type='deploy_key'``, this sets up the remote with ssh access. """ + # Set to the name of the tag for tag builds + TRAVIS_TAG = os.environ.get("TRAVIS_TAG", "") if not branch_whitelist: branch_whitelist={'master'} @@ -190,7 +194,7 @@ def setup_GitHub_push(deploy_repo, auth_type='deploy_key', full_key_path='github TRAVIS_PULL_REQUEST = os.environ.get("TRAVIS_PULL_REQUEST", "") canpush = determine_push_rights(branch_whitelist, TRAVIS_BRANCH, - TRAVIS_PULL_REQUEST) + TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags) print("Setting git attributes") set_git_user_email() @@ -457,12 +461,16 @@ def push_docs(deploy_branch='gh-pages', retries=3): return sys.exit("Giving up...") -def determine_push_rights(branch_whitelist, TRAVIS_BRANCH, TRAVIS_PULL_REQUEST): +def determine_push_rights(branch_whitelist, TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags): """Check if Travis is running on ``master`` (or a whitelisted branch) to determine if we can/should push the docs to the deploy repo """ canpush = True + if TRAVIS_TAG: + return build_tags + if not any([re.compile(x).match(TRAVIS_BRANCH) for x in branch_whitelist]): print("The docs are only pushed to gh-pages from master. To allow pushing from " "a non-master branch, use the --no-require-master flag", file=sys.stderr) From 3579bf6862fd202bd251884ad20f5201debe0943 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:20:33 -0500 Subject: [PATCH 02/17] Print a message when not building on a tag build --- doctr/travis.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doctr/travis.py b/doctr/travis.py index 968da1f2..c90268ac 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -469,6 +469,8 @@ def determine_push_rights(branch_whitelist, TRAVIS_BRANCH, canpush = True if TRAVIS_TAG: + if not build_tags: + print("The docs are not pushed on tag builds. To push on future tag builds, use --build-tags") return build_tags if not any([re.compile(x).match(TRAVIS_BRANCH) for x in branch_whitelist]): From 54c573ea37072d196566c2f44e3d987b5d09e90f Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:20:46 -0500 Subject: [PATCH 03/17] Make determine_push_rights have keyword only args --- doctr/travis.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doctr/travis.py b/doctr/travis.py index c90268ac..fc3c6f11 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -193,8 +193,12 @@ def setup_GitHub_push(deploy_repo, auth_type='deploy_key', TRAVIS_BRANCH = os.environ.get("TRAVIS_BRANCH", "") TRAVIS_PULL_REQUEST = os.environ.get("TRAVIS_PULL_REQUEST", "") - canpush = determine_push_rights(branch_whitelist, TRAVIS_BRANCH, - TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags) + canpush = determine_push_rights( + branch_whitelist=branch_whitelist, + TRAVIS_BRANCH=TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST=TRAVIS_PULL_REQUEST, + TRAVIS_TAG=TRAVIS_TAG, + build_tags=build_tags) print("Setting git attributes") set_git_user_email() @@ -461,7 +465,7 @@ def push_docs(deploy_branch='gh-pages', retries=3): return sys.exit("Giving up...") -def determine_push_rights(branch_whitelist, TRAVIS_BRANCH, +def determine_push_rights(*, branch_whitelist, TRAVIS_BRANCH, TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags): """Check if Travis is running on ``master`` (or a whitelisted branch) to determine if we can/should push the docs to the deploy repo From 8cc5e84d0c300314177adaf77303313e027c8f0b Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:20:55 -0500 Subject: [PATCH 04/17] Fix the determine_push_rights tests --- doctr/tests/test_travis.py | 59 ++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/doctr/tests/test_travis.py b/doctr/tests/test_travis.py index 6a4c3bbe..136ddeaf 100644 --- a/doctr/tests/test_travis.py +++ b/doctr/tests/test_travis.py @@ -144,16 +144,51 @@ def test_sync_from_log(src, dst): os.chdir(old_curdir) -@pytest.mark.parametrize("travis_branch, travis_pr, whitelist, canpush", - [('doctr', 'true', 'master', False), - ('doctr', 'false', 'master', False), - ('master', 'true', 'master', False), - ('master', 'false', 'master', True), - ('doctr', 'True', 'doctr', False), - ('doctr', 'false', 'doctr', True), - ('doctr', 'false', 'set()', False), - ]) -def test_determine_push_rights(travis_branch, travis_pr, whitelist, canpush, monkeypatch): - branch_whitelist = {whitelist} +@pytest.mark.parametrize("""branch_whitelist, TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags, + canpush""", + [ + + ('master', 'doctr', 'true', "", False, False), + ('master', 'doctr', 'false', "", False, False), + ('master', 'master', 'true', "", False, False), + ('master', 'master', 'false', "", False, True), + ('doctr', 'doctr', 'True', "", False, False), + ('doctr', 'doctr', 'false', "", False, True), + ('set()', 'doctr', 'false', "", False, False), + + ('master', 'doctr', 'true', "tagname", False, False), + ('master', 'doctr', 'false', "tagname", False, False), + ('master', 'master', 'true', "tagname", False, False), + ('master', 'master', 'false', "tagname", False, False), + ('doctr', 'doctr', 'True', "tagname", False, False), + ('doctr', 'doctr', 'false', "tagname", False, False), + ('set()', 'doctr', 'false', "tagname", False, False), + + ('master', 'doctr', 'true', "", True, False), + ('master', 'doctr', 'false', "", True, False), + ('master', 'master', 'true', "", True, False), + ('master', 'master', 'false', "", True, True), + ('doctr', 'doctr', 'True', "", True, False), + ('doctr', 'doctr', 'false', "", True, True), + ('set()', 'doctr', 'false', "", True, False), + + ('master', 'doctr', 'true', "tagname", True, True), + ('master', 'doctr', 'false', "tagname", True, True), + ('master', 'master', 'true', "tagname", True, True), + ('master', 'master', 'false', "tagname", True, True), + ('doctr', 'doctr', 'True', "tagname", True, True), + ('doctr', 'doctr', 'false', "tagname", True, True), + ('set()', 'doctr', 'false', "tagname", True, True), - assert determine_push_rights(branch_whitelist, travis_branch, travis_pr) == canpush + ]) +def test_determine_push_rights(branch_whitelist, TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags, canpush, monkeypatch): + branch_whitelist = {branch_whitelist} + + assert determine_push_rights( + branch_whitelist=branch_whitelist, + TRAVIS_BRANCH=TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST=TRAVIS_PULL_REQUEST, + TRAVIS_TAG=TRAVIS_TAG, + build_tags=build_tags) == canpush From 7fe407f6f4d4652a1e435a04fd40ba9f0d5aa33f Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:22:08 -0500 Subject: [PATCH 05/17] Deploy from tags in .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e2c11f93..85aa7a78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,7 @@ script: python -m doctr deploy --no-require-master --command "echo test; ls; touch docs/_build/html/test" docs; # Test syncing a tracked file with a change python -m doctr deploy --sync . --built-docs test; + python -m doctr deploy --sync "tag-$TRAVIS_TAG" --build-tags; fi - if [[ "${TESTS}" == "true" ]]; then pyflakes doctr; From c915d779ca746c24e508c73001a5c5a73135fecc Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:25:17 -0500 Subject: [PATCH 06/17] Fix the docs build --- docs/recipes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/recipes.rst b/docs/recipes.rst index d82f7610..6e915513 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -49,6 +49,8 @@ On Travis CI, the tag is set to the environment variable ``$TRAVIS_TAG``, which is empty otherwise. The following will deploy the docs to ``dev`` for normal ``master`` builds, and ``version-`` for tag builds: +.. code:: yaml + - if [[ -z "$TRAVIS_TAG" ]]; then DEPLOY_DIR=dev; else From f48d6cdeab65e62ccffebea2cd46473ff4748f77 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:26:22 -0500 Subject: [PATCH 07/17] Fix argument name --- doctr/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index cc8d6d84..b4c6e743 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -261,7 +261,7 @@ def deploy(args, parser): auth_type='token' if args.token else 'deploy_key', full_key_path=args.key_path, branch_whitelist=branch_whitelist, - build_tag=args.build_tag) + build_tags=args.build_tags) if args.command: run(args.command, shell=True) From 643b476f76b44a2477d7450550ae2e96ee2a8ac3 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:32:48 -0500 Subject: [PATCH 08/17] Add --branch-whitelist command line flag --- doctr/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doctr/__main__.py b/doctr/__main__.py index b4c6e743..37ed8f68 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -142,6 +142,9 @@ def get_parser(config=None): help=argparse.SUPPRESS) deploy_parser_add_argument('--deploy-repo', default=None, help="""Repo to deploy the docs to. By default, it deploys to the repo Doctr is run from.""") + deploy_parser_add_argument('--branch-whitelist', default=set(), nargs='*', + help="""Additional branches to deploy from. Note that you can deploy from + any branch with --no-require-master.""", type=set, metavar="BRANCH") deploy_parser_add_argument('--no-require-master', dest='require_master', action='store_false', default=True, help="""Allow docs to be pushed from a branch other than master""") deploy_parser_add_argument('--command', default=None, help="""Command to @@ -256,6 +259,7 @@ def deploy(args, parser): try: branch_whitelist = {'master'} if args.require_master else set(get_travis_branch()) branch_whitelist.update(set(config.get('branches',set({})))) + branch_whitelist.update(args.branch_whitelist) canpush = setup_GitHub_push(deploy_repo, deploy_branch=deploy_branch, auth_type='token' if args.token else 'deploy_key', From 43539af80dbc607af5d57c48cd9dcee0fe0d504a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:34:22 -0500 Subject: [PATCH 09/17] Require master to be included in the branch whitelist This is technically backwards incompatible, but without this it's impossible to not build on master. --- doctr/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index 37ed8f68..046b793f 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -143,7 +143,7 @@ def get_parser(config=None): deploy_parser_add_argument('--deploy-repo', default=None, help="""Repo to deploy the docs to. By default, it deploys to the repo Doctr is run from.""") deploy_parser_add_argument('--branch-whitelist', default=set(), nargs='*', - help="""Additional branches to deploy from. Note that you can deploy from + help="""Branches to deploy from. Note that you can deploy from any branch with --no-require-master.""", type=set, metavar="BRANCH") deploy_parser_add_argument('--no-require-master', dest='require_master', action='store_false', default=True, help="""Allow docs to be pushed from a branch other than master""") @@ -257,9 +257,11 @@ def deploy(args, parser): current_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip() try: - branch_whitelist = {'master'} if args.require_master else set(get_travis_branch()) + branch_whitelist = set() if args.require_master else set(get_travis_branch()) branch_whitelist.update(set(config.get('branches',set({})))) branch_whitelist.update(args.branch_whitelist) + if not branch_whitelist: + branch_whitelist = {'master'} canpush = setup_GitHub_push(deploy_repo, deploy_branch=deploy_branch, auth_type='token' if args.token else 'deploy_key', From 634a30de212a89aa9e7db696dffc6ae85545bad2 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:36:54 -0500 Subject: [PATCH 10/17] Allow --branch-whitelist with no args to not deploy to any branch Fixes #227. --- doctr/__main__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index 046b793f..0d73ff98 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -142,9 +142,10 @@ def get_parser(config=None): help=argparse.SUPPRESS) deploy_parser_add_argument('--deploy-repo', default=None, help="""Repo to deploy the docs to. By default, it deploys to the repo Doctr is run from.""") - deploy_parser_add_argument('--branch-whitelist', default=set(), nargs='*', - help="""Branches to deploy from. Note that you can deploy from - any branch with --no-require-master.""", type=set, metavar="BRANCH") + deploy_parser_add_argument('--branch-whitelist', default=None, nargs='*', + help="""Branches to deploy from. Pass no arguments to not build on any branch + (typically used in conjunction with --build-tags). Note that you can + deploy from every branch with --no-require-master.""", type=set, metavar="BRANCH") deploy_parser_add_argument('--no-require-master', dest='require_master', action='store_false', default=True, help="""Allow docs to be pushed from a branch other than master""") deploy_parser_add_argument('--command', default=None, help="""Command to @@ -260,7 +261,7 @@ def deploy(args, parser): branch_whitelist = set() if args.require_master else set(get_travis_branch()) branch_whitelist.update(set(config.get('branches',set({})))) branch_whitelist.update(args.branch_whitelist) - if not branch_whitelist: + if not branch_whitelist and args.branch_whitelist is not None: branch_whitelist = {'master'} canpush = setup_GitHub_push(deploy_repo, deploy_branch=deploy_branch, From 6c59653fda51a3707739c3f88ce141e97a63e4f5 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:37:28 -0500 Subject: [PATCH 11/17] Don't build the tags test on any branches --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 85aa7a78..e8fcbc68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ script: python -m doctr deploy --no-require-master --command "echo test; ls; touch docs/_build/html/test" docs; # Test syncing a tracked file with a change python -m doctr deploy --sync . --built-docs test; - python -m doctr deploy --sync "tag-$TRAVIS_TAG" --build-tags; + python -m doctr deploy --sync "tag-$TRAVIS_TAG" --build-tags --branch-whitelist; fi - if [[ "${TESTS}" == "true" ]]; then pyflakes doctr; From 1549a91595028a3ccccb90bbcefa6d734e1e59ca Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:40:14 -0500 Subject: [PATCH 12/17] Add an example in the docs to only deploying from tags --- docs/recipes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/recipes.rst b/docs/recipes.rst index 6e915513..93be728d 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -58,6 +58,14 @@ normal ``master`` builds, and ``version-`` for tag builds: fi - doctr deploy --build-tags --built-docs build/ $DEPLOY_DIR +If you want to deploy only on a tag, use ``--branch-whitelist`` with no +arguments to tell doctr to not deploy from any branch. For instance, to deploy +only tags to ``latest``: + +.. code:: yaml + + - doctr deploy latest --built-docs build/ --build-tags --branch-whitelist + Deploy to a separate repo ========================= From a2a6082734c8a3d2aff71dabb125af9a172d898a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 17:58:00 -0500 Subject: [PATCH 13/17] Fix --branch-whitelist not being given logic --- doctr/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index 0d73ff98..95960890 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -260,9 +260,10 @@ def deploy(args, parser): try: branch_whitelist = set() if args.require_master else set(get_travis_branch()) branch_whitelist.update(set(config.get('branches',set({})))) - branch_whitelist.update(args.branch_whitelist) - if not branch_whitelist and args.branch_whitelist is not None: - branch_whitelist = {'master'} + if args.branch_whitelist is not None: + branch_whitelist.update(args.branch_whitelist) + if not args.branch_whitelist: + branch_whitelist = {'master'} canpush = setup_GitHub_push(deploy_repo, deploy_branch=deploy_branch, auth_type='token' if args.token else 'deploy_key', From 309d5922229b82f42bcdc00c934aa592867a0a7d Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 18:01:32 -0500 Subject: [PATCH 14/17] Fix --build-tags flag --- doctr/__main__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index c7e65da9..07ded056 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -163,9 +163,10 @@ def get_parser(config=None): deploy_parser_add_argument('--no-push', dest='push', action='store_false', default=True, help="Run all the steps except the last push step. " "Useful for debugging") - deploy_parser_add_argument('--build-tags', default=False, help="""Deploy - on tag builds. On a tag build, $TRAVIS_TAG is set to the name of the - tag. The default is to not deploy on tag builds.""") + deploy_parser_add_argument('--build-tags', action='store_true', + default=False, help="""Deploy on tag builds. On a tag build, + $TRAVIS_TAG is set to the name of the tag. The default is to not + deploy on tag builds.""") deploy_parser_add_argument('--gh-pages-docs', default=None, help="""!!DEPRECATED!! Directory to deploy the html documentation to on gh-pages. The default is %(default)r. The deploy directory should be passed as From e49add95d007f50e1198d0e555dbd6b191b8a014 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 16 Jul 2017 18:04:09 -0500 Subject: [PATCH 15/17] Add note about --branch-whitelist to --build-tags flag --- doctr/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doctr/__main__.py b/doctr/__main__.py index 07ded056..0920028b 100644 --- a/doctr/__main__.py +++ b/doctr/__main__.py @@ -166,7 +166,8 @@ def get_parser(config=None): deploy_parser_add_argument('--build-tags', action='store_true', default=False, help="""Deploy on tag builds. On a tag build, $TRAVIS_TAG is set to the name of the tag. The default is to not - deploy on tag builds.""") + deploy on tag builds. Note that this will still build on a branch, + unless --branch-whitelist (with no arguments) is passed.""") deploy_parser_add_argument('--gh-pages-docs', default=None, help="""!!DEPRECATED!! Directory to deploy the html documentation to on gh-pages. The default is %(default)r. The deploy directory should be passed as From a74f4409eb2312081971d5c53440978e7d17a052 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 19 Nov 2017 16:37:35 -0700 Subject: [PATCH 16/17] Use keyword only args in setup_GitHub_push() --- doctr/travis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doctr/travis.py b/doctr/travis.py index 5cdf2cb2..f8a044a3 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -183,8 +183,10 @@ def get_travis_branch(): else: return os.environ.get("TRAVIS_BRANCH", "") -def setup_GitHub_push(deploy_repo, auth_type='deploy_key', full_key_path='github_deploy_key.enc', - require_master=None, branch_whitelist=None, deploy_branch='gh-pages', env_name='DOCTR_DEPLOY_ENCRYPTION_KEY', build_tags=False): +def setup_GitHub_push(deploy_repo, *, auth_type='deploy_key', + full_key_path='github_deploy_key.enc', require_master=None, + branch_whitelist=None, deploy_branch='gh-pages', + env_name='DOCTR_DEPLOY_ENCRYPTION_KEY', build_tags=False): """ Setup the remote to push to GitHub (to be run on Travis). From 2324e4bda9022b7c6957317ae9a012a07a3459b7 Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Sun, 19 Nov 2017 17:06:38 -0700 Subject: [PATCH 17/17] Say "tag" in the commit message for tag builds --- doctr/travis.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doctr/travis.py b/doctr/travis.py index f8a044a3..9682022c 100644 --- a/doctr/travis.py +++ b/doctr/travis.py @@ -449,6 +449,9 @@ def commit_docs(*, added, removed): TRAVIS_COMMIT = os.environ.get("TRAVIS_COMMIT", "") TRAVIS_REPO_SLUG = os.environ.get("TRAVIS_REPO_SLUG", "") TRAVIS_JOB_ID = os.environ.get("TRAVIS_JOB_ID", "") + TRAVIS_TAG = os.environ.get("TRAVIS_TAG", "") + branch = "tag" if TRAVIS_TAG else "branch" + DOCTR_COMMAND = ' '.join(map(shlex.quote, sys.argv)) for f in added: @@ -460,7 +463,7 @@ def commit_docs(*, added, removed): Update docs after building Travis build {TRAVIS_BUILD_NUMBER} of {TRAVIS_REPO_SLUG} -The docs were built from the branch '{TRAVIS_BRANCH}' against the commit +The docs were built from the {branch} '{TRAVIS_BRANCH}' against the commit {TRAVIS_COMMIT}. The Travis build that generated this commit is at @@ -470,6 +473,7 @@ def commit_docs(*, added, removed): {DOCTR_COMMAND} """.format( + branch=branch, TRAVIS_BUILD_NUMBER=TRAVIS_BUILD_NUMBER, TRAVIS_BRANCH=TRAVIS_BRANCH, TRAVIS_COMMIT=TRAVIS_COMMIT,