From d9b566c30c75aa2176ef5a1fec0ad6b6a871092d Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 13:51:37 -0700 Subject: [PATCH 01/25] removed unused ci shell script, made ci python script permissions consistent --- tests/ci_commit.sh | 8 -------- tests/ci_prepare.py | 0 2 files changed, 8 deletions(-) delete mode 100755 tests/ci_commit.sh mode change 100644 => 100755 tests/ci_prepare.py diff --git a/tests/ci_commit.sh b/tests/ci_commit.sh deleted file mode 100755 index bc1ab70..0000000 --- a/tests/ci_commit.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -git_commit() { - git remote add origin https://${GH_TOKEN}@github.com/checktheroads/hyperglass.git > /dev/null 2>&1 - git push --quiet --set-upstream origin master -} - -git_commit diff --git a/tests/ci_prepare.py b/tests/ci_prepare.py old mode 100644 new mode 100755 From 582476d2be2963cda17d0e84855317b2164225fa Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 13:56:37 -0700 Subject: [PATCH 02/25] Added git `git fetch` to CI build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ced7b18..89dfbeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ install: before_script: - pip3 install -r ./tests/requirements_dev.txt - pip3 install anybadge + - git fetch - git checkout master - black hyperglass - python3 ./manage.py pylint-badge --integer-only True From fc3b7bb12ced935bb77b4790faa287e32ff24d7e Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 14:54:01 -0700 Subject: [PATCH 03/25] Moved fetch & checkout to script --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89dfbeb..31c467a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ install: before_script: - pip3 install -r ./tests/requirements_dev.txt - pip3 install anybadge - - git fetch - - git checkout master + - ./tests/ci_git_prep.sh - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - ./tests/ci_git.sh From 5b1c327b7f5f0ec9669cf2f63be7e976c47d32df Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 14:54:41 -0700 Subject: [PATCH 04/25] Evaluate PR state & set branch to commit accordingly --- tests/ci_git_prep.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/ci_git_prep.sh diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh new file mode 100644 index 0000000..d93da8e --- /dev/null +++ b/tests/ci_git_prep.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +THIS_BRANCH=0 + +git_setup() { + git config --global user.email "travis@travis-ci.org" + git config --global user.name "Travis CI" +} + +set_branch() { + if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then + THIS_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH + else + THIS_BRANCH='master' + fi +} + +git_setup +git fetch +set_branch +git checkout $THIS_BRANCH +exit 0 From 1be09e94e0e86e4e12b90d5744938299ed70c464 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 14:55:34 -0700 Subject: [PATCH 05/25] Moved setup_git() to new script --- tests/ci_git.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/ci_git.sh b/tests/ci_git.sh index fc65577..228b522 100755 --- a/tests/ci_git.sh +++ b/tests/ci_git.sh @@ -1,4 +1,4 @@ - #!/bin/sh +#!/bin/sh commit_black() { git add hyperglass/*.py @@ -10,12 +10,6 @@ commit_pylint() { git commit --message "Pylint Badge - travis $TRAVIS_BUILD_NUMBER" } -setup_git() { - git config --global user.email "travis@travis-ci.org" - git config --global user.name "Travis CI" -} - -setup_git commit_black commit_pylint From 025acb93bc9f9ea464f729bbacb8b5ffc94d406b Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:07:00 -0700 Subject: [PATCH 06/25] renamed script to more logical name --- tests/{ci_git.sh => ci_git_commit.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{ci_git.sh => ci_git_commit.sh} (100%) diff --git a/tests/ci_git.sh b/tests/ci_git_commit.sh similarity index 100% rename from tests/ci_git.sh rename to tests/ci_git_commit.sh From be95acc98c76d3a40471d26f7808f7f98ad2f7be Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:08:16 -0700 Subject: [PATCH 07/25] moved fetch/checkout to script with travis variables --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31c467a..104b4a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,11 +16,11 @@ before_script: - ./tests/ci_git_prep.sh - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - - ./tests/ci_git.sh + - ./tests/ci_git_commit.sh - python3 ./tests/ci_prepare.py script: - nohup python3 ./tests/ci_dev_server.py & - sleep 20 - python3 ./tests/ci_test.py after_success: - - git push origin master + - git push origin $TRAVIS_BRANCH From dd084f58909ea100fc3b27e870a7c89c658508b6 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:09:14 -0700 Subject: [PATCH 08/25] simplified script; switched to TRAVIS_BRANCH env variable --- tests/ci_git_prep.sh | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index d93da8e..abbf58f 100644 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,22 +1,7 @@ #!/bin/sh -THIS_BRANCH=0 - -git_setup() { - git config --global user.email "travis@travis-ci.org" - git config --global user.name "Travis CI" -} - -set_branch() { - if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then - THIS_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - else - THIS_BRANCH='master' - fi -} - -git_setup +git config --global user.email "travis@travis-ci.org" +git config --global user.name "Travis CI" git fetch -set_branch -git checkout $THIS_BRANCH +git checkout $TRAVIS_BRANCH exit 0 From bd5440ab45d1d6b3e89b931192608c111eee1192 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:12:29 -0700 Subject: [PATCH 09/25] fixed missing executable permissions after rewrite --- tests/ci_git_prep.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/ci_git_prep.sh diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh old mode 100644 new mode 100755 From f5c778d7872ae34a62f526c78d2b8f7023eec778 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:20:50 -0700 Subject: [PATCH 10/25] Removed `git fetch` now that env vars are being used --- tests/ci_git_prep.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index abbf58f..b7ec8cf 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -2,6 +2,5 @@ git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" -git fetch git checkout $TRAVIS_BRANCH exit 0 From 6431f9a751e2dfd68ef8b12b710e93c17b9327c7 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:46:41 -0700 Subject: [PATCH 11/25] Fixed issue with branch detection for PRs --- tests/ci_git_prep.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index b7ec8cf..64784e3 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,6 +1,27 @@ #!/bin/sh - +echo "Travis thinks the branch is $TRAVIS_BRANCH" git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" git checkout $TRAVIS_BRANCH exit 0 + + +git_setup() { + git config user.email "travis@travis-ci.org" + git config user.name "Travis CI" +} + +detect_branch() { + if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then + echo $TRAVIS_PULL_REQUEST_BRANCH + else + echo $TRAVIS_BRANCH + fi +} + +CURRENT_BRANCH=$(detect_branch) + +git_setup +git checkout $CURRENT_BRANCH +export $CURRENT_BRANCH +exit 0 From 41d8a1259081205b7599d7951450738e6e4d257c Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:47:53 -0700 Subject: [PATCH 12/25] Switched to exported branch variable --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 104b4a8..21329b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,4 @@ script: - sleep 20 - python3 ./tests/ci_test.py after_success: - - git push origin $TRAVIS_BRANCH + - git push origin $CURRENT_BRANCH From d38d83d4e5c695c44f3407b6467cf5cf08700baf Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:49:56 -0700 Subject: [PATCH 13/25] removed old code block --- tests/ci_git_prep.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 64784e3..6870af0 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,11 +1,4 @@ #!/bin/sh -echo "Travis thinks the branch is $TRAVIS_BRANCH" -git config --global user.email "travis@travis-ci.org" -git config --global user.name "Travis CI" -git checkout $TRAVIS_BRANCH -exit 0 - - git_setup() { git config user.email "travis@travis-ci.org" git config user.name "Travis CI" From fc7db9137a9912be5fed964db87fa6d05c0963e2 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:55:49 -0700 Subject: [PATCH 14/25] Added debug statements --- tests/ci_git_prep.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 6870af0..ce15867 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,4 +1,8 @@ #!/bin/sh + +echo "Travis Pull Request State: $TRAVIS_PULL_REQUEST" +echo "Travis Branch: $TRAVIS_BRANCH" + git_setup() { git config user.email "travis@travis-ci.org" git config user.name "Travis CI" @@ -14,6 +18,8 @@ detect_branch() { CURRENT_BRANCH=$(detect_branch) +echo "Detected Branch: $CURRENT_BRANCH" + git_setup git checkout $CURRENT_BRANCH export $CURRENT_BRANCH From 08634d208ab66d66a845a7aa1bf47ca4e7e3894f Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 15:59:56 -0700 Subject: [PATCH 15/25] added debug statement to see if env var is making it out of shell script --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 21329b3..5e3a5f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_script: - pip3 install -r ./tests/requirements_dev.txt - pip3 install anybadge - ./tests/ci_git_prep.sh + - echo "Current Branch in Travis Context - $CURRENT_BRANCH" - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - ./tests/ci_git_commit.sh From 337e945f60f7d039240ff43c4fbc39301fb22e71 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 16:05:52 -0700 Subject: [PATCH 16/25] reversed PR validation logic --- tests/ci_git_prep.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index ce15867..198fb71 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -9,10 +9,10 @@ git_setup() { } detect_branch() { - if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then - echo $TRAVIS_PULL_REQUEST_BRANCH - else + if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo $TRAVIS_BRANCH + else + echo $TRAVIS_PULL_REQUEST_BRANCH fi } From c963de641dd21b6e205026fab80e243980ea40e8 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 16:40:14 -0700 Subject: [PATCH 17/25] removed travis echo statement --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e3a5f3..21329b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ before_script: - pip3 install -r ./tests/requirements_dev.txt - pip3 install anybadge - ./tests/ci_git_prep.sh - - echo "Current Branch in Travis Context - $CURRENT_BRANCH" - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - ./tests/ci_git_commit.sh From 3183bbbff935ca3d9fa00072997a6a56826dc092 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 17:00:45 -0700 Subject: [PATCH 18/25] Run branch variable script in current shell env --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 21329b3..6567214 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ install: before_script: - pip3 install -r ./tests/requirements_dev.txt - pip3 install anybadge - - ./tests/ci_git_prep.sh + - . ./tests/ci_git_prep.sh - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - ./tests/ci_git_commit.sh From 17ae52f9588242902c81db57acde8292512dbc93 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 17:02:28 -0700 Subject: [PATCH 19/25] Remove exit 0 from script --- tests/ci_git_prep.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 198fb71..02db093 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -23,4 +23,3 @@ echo "Detected Branch: $CURRENT_BRANCH" git_setup git checkout $CURRENT_BRANCH export $CURRENT_BRANCH -exit 0 From 782f5685384e969150d539b127358b43ddd8fc48 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 17:07:54 -0700 Subject: [PATCH 20/25] Fix invalid export syntax; re-add git fetch --- tests/ci_git_prep.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 02db093..e27e4fa 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -16,10 +16,10 @@ detect_branch() { fi } -CURRENT_BRANCH=$(detect_branch) +export CURRENT_BRANCH=$(detect_branch) echo "Detected Branch: $CURRENT_BRANCH" git_setup +git fetch git checkout $CURRENT_BRANCH -export $CURRENT_BRANCH From 127489f5b8833b3259e36d1ab5f50c02abb7a0c4 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 17:30:12 -0700 Subject: [PATCH 21/25] Add origin/ to git statements --- tests/ci_git_prep.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index e27e4fa..12ef955 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -21,5 +21,5 @@ export CURRENT_BRANCH=$(detect_branch) echo "Detected Branch: $CURRENT_BRANCH" git_setup -git fetch -git checkout $CURRENT_BRANCH +git fetch origin +git checkout origin/$CURRENT_BRANCH From d4ebb07b1965ee17569a53ae17283d76e7faed69 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 17:44:04 -0700 Subject: [PATCH 22/25] Set git to fetch remote branch --- tests/ci_git_prep.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 12ef955..3049111 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -1,6 +1,6 @@ #!/bin/sh -echo "Travis Pull Request State: $TRAVIS_PULL_REQUEST" +echo "Travis Pull Request: $TRAVIS_PULL_REQUEST" echo "Travis Branch: $TRAVIS_BRANCH" git_setup() { @@ -17,9 +17,13 @@ detect_branch() { } export CURRENT_BRANCH=$(detect_branch) - echo "Detected Branch: $CURRENT_BRANCH" +echo "Setting git config parameters..." git_setup -git fetch origin +echo "Initiating git fetch..." +git fetch --depth=1 git@github.com:$TRAVIS_PULL_REQUEST_SLUG.git refs/heads/$CURRENT_BRANCH:refs/remotes/origin/$CURRENT_BRANCH +echo "Running git checkout..." git checkout origin/$CURRENT_BRANCH + +exit 0 From ead1c99230dedae1fbd9984b4691d8d320f71921 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 18:11:45 -0700 Subject: [PATCH 23/25] Move push to shell script --- .travis.yml | 4 ++-- tests/ci_git_prep.sh | 4 +--- tests/ci_git_push.sh | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 tests/ci_git_push.sh diff --git a/.travis.yml b/.travis.yml index 6567214..34fa1db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,11 +16,11 @@ before_script: - . ./tests/ci_git_prep.sh - black hyperglass - python3 ./manage.py pylint-badge --integer-only True - - ./tests/ci_git_commit.sh + - . ./tests/ci_git_commit.sh - python3 ./tests/ci_prepare.py script: - nohup python3 ./tests/ci_dev_server.py & - sleep 20 - python3 ./tests/ci_test.py after_success: - - git push origin $CURRENT_BRANCH + - . ./tests/ci_git_push.sh diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 3049111..5b66678 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -22,8 +22,6 @@ echo "Detected Branch: $CURRENT_BRANCH" echo "Setting git config parameters..." git_setup echo "Initiating git fetch..." -git fetch --depth=1 git@github.com:$TRAVIS_PULL_REQUEST_SLUG.git refs/heads/$CURRENT_BRANCH:refs/remotes/origin/$CURRENT_BRANCH +git fetch --depth=1 $GH_TOKEN@github.com:$TRAVIS_PULL_REQUEST_SLUG.git refs/heads/$CURRENT_BRANCH:refs/remotes/origin/$CURRENT_BRANCH > /dev/null 2>&1 echo "Running git checkout..." git checkout origin/$CURRENT_BRANCH - -exit 0 diff --git a/tests/ci_git_push.sh b/tests/ci_git_push.sh new file mode 100644 index 0000000..186e4f9 --- /dev/null +++ b/tests/ci_git_push.sh @@ -0,0 +1,2 @@ +#!/bin/sh +git push $GH_TOKEN@github.com:$TRAVIS_PULL_REQUEST_SLUG.git origin $CURRENT_BRANCH > /dev/null 2>&1 From 736424c82eb3415e7e21551a327b9d042df27a3a Mon Sep 17 00:00:00 2001 From: checktheroads Date: Tue, 18 Jun 2019 18:26:21 -0700 Subject: [PATCH 24/25] Add git branches debug --- tests/ci_git_prep.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ci_git_prep.sh b/tests/ci_git_prep.sh index 5b66678..3dc6be5 100755 --- a/tests/ci_git_prep.sh +++ b/tests/ci_git_prep.sh @@ -21,6 +21,7 @@ echo "Detected Branch: $CURRENT_BRANCH" echo "Setting git config parameters..." git_setup +echo "git branches:\n$(git branch -a)" echo "Initiating git fetch..." git fetch --depth=1 $GH_TOKEN@github.com:$TRAVIS_PULL_REQUEST_SLUG.git refs/heads/$CURRENT_BRANCH:refs/remotes/origin/$CURRENT_BRANCH > /dev/null 2>&1 echo "Running git checkout..." From ea49ecd760010525d6475bf46b69bf51de4cd726 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Wed, 19 Jun 2019 08:37:59 -0700 Subject: [PATCH 25/25] Make CI fail on black/pylint failure, but not change files --- .travis.yml | 9 ++------- manage.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 34fa1db..c8764f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,15 +12,10 @@ install: - pip3 install -r requirements.txt before_script: - pip3 install -r ./tests/requirements_dev.txt - - pip3 install anybadge - - . ./tests/ci_git_prep.sh - - black hyperglass - - python3 ./manage.py pylint-badge --integer-only True - - . ./tests/ci_git_commit.sh + - black --check hyperglass + - python3 ./manage.py pylint-check --integer-only True - python3 ./tests/ci_prepare.py script: - nohup python3 ./tests/ci_dev_server.py & - sleep 20 - python3 ./tests/ci_test.py -after_success: - - . ./tests/ci_git_push.sh diff --git a/manage.py b/manage.py index 2844cf6..b52a0ee 100755 --- a/manage.py +++ b/manage.py @@ -35,8 +35,7 @@ def construct_test(test_query, location, test_target): def hg(): pass - -@hg.command("pylint-badge", help="Runs Pylint and generates a badge for GitHub") +@hg.command("pylint-check", help="Runs Pylint and generates a badge for GitHub") @click.option( "-i", "--integer-only", @@ -45,7 +44,8 @@ def hg(): default=False, help="Output Pylint score as integer", ) -def pylint_badge(int_only): +@click.option("-b", "--badge", "create_badge", type=bool, default=False, help="Create Pylint badge") +def pylint_check(int_only, create_badge): try: import re import anybadge @@ -58,12 +58,13 @@ def pylint_badge(int_only): ).group(1) if not pylint_score == "10.00": raise RuntimeError(f"Pylint score {pylint_score} not acceptable.") - badge_file = os.path.join(working_directory, "pylint.svg") - if os.path.exists(badge_file): - os.remove(badge_file) - ab_thresholds = {1: "red", 10: "green"} - badge = anybadge.Badge("pylint", pylint_score, thresholds=ab_thresholds) - badge.write_badge("pylint.svg") + if create_badge: + badge_file = os.path.join(working_directory, "pylint.svg") + if os.path.exists(badge_file): + os.remove(badge_file) + ab_thresholds = {1: "red", 10: "green"} + badge = anybadge.Badge("pylint", pylint_score, thresholds=ab_thresholds) + badge.write_badge("pylint.svg") if not int_only: click.secho( f"Created Pylint badge for score: {pylint_score}", fg="blue", bold=True