Merge pull request #3 from checktheroads/ci-cleanup

ci cleanups - No longer doing auto blackformatting or auto pylint badging
This commit is contained in:
Matt Love 2019-06-19 08:50:52 -07:00 committed by GitHub
commit 83b81a037d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 31 deletions

View file

@ -12,15 +12,10 @@ install:
- pip3 install -r requirements.txt - pip3 install -r requirements.txt
before_script: before_script:
- pip3 install -r ./tests/requirements_dev.txt - pip3 install -r ./tests/requirements_dev.txt
- pip3 install anybadge - black --check hyperglass
- git checkout master - python3 ./manage.py pylint-check --integer-only True
- black hyperglass
- python3 ./manage.py pylint-badge --integer-only True
- ./tests/ci_git.sh
- python3 ./tests/ci_prepare.py - python3 ./tests/ci_prepare.py
script: script:
- nohup python3 ./tests/ci_dev_server.py & - nohup python3 ./tests/ci_dev_server.py &
- sleep 20 - sleep 20
- python3 ./tests/ci_test.py - python3 ./tests/ci_test.py
after_success:
- git push origin master

View file

@ -35,8 +35,7 @@ def construct_test(test_query, location, test_target):
def hg(): def hg():
pass pass
@hg.command("pylint-check", help="Runs Pylint and generates a badge for GitHub")
@hg.command("pylint-badge", help="Runs Pylint and generates a badge for GitHub")
@click.option( @click.option(
"-i", "-i",
"--integer-only", "--integer-only",
@ -45,7 +44,8 @@ def hg():
default=False, default=False,
help="Output Pylint score as integer", 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: try:
import re import re
import anybadge import anybadge
@ -58,12 +58,13 @@ def pylint_badge(int_only):
).group(1) ).group(1)
if not pylint_score == "10.00": if not pylint_score == "10.00":
raise RuntimeError(f"Pylint score {pylint_score} not acceptable.") raise RuntimeError(f"Pylint score {pylint_score} not acceptable.")
badge_file = os.path.join(working_directory, "pylint.svg") if create_badge:
if os.path.exists(badge_file): badge_file = os.path.join(working_directory, "pylint.svg")
os.remove(badge_file) if os.path.exists(badge_file):
ab_thresholds = {1: "red", 10: "green"} os.remove(badge_file)
badge = anybadge.Badge("pylint", pylint_score, thresholds=ab_thresholds) ab_thresholds = {1: "red", 10: "green"}
badge.write_badge("pylint.svg") badge = anybadge.Badge("pylint", pylint_score, thresholds=ab_thresholds)
badge.write_badge("pylint.svg")
if not int_only: if not int_only:
click.secho( click.secho(
f"Created Pylint badge for score: {pylint_score}", fg="blue", bold=True f"Created Pylint badge for score: {pylint_score}", fg="blue", bold=True

View file

@ -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

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
commit_black() { commit_black() {
git add hyperglass/*.py git add hyperglass/*.py
@ -10,12 +10,6 @@ commit_pylint() {
git commit --message "Pylint Badge - travis $TRAVIS_BUILD_NUMBER" 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_black
commit_pylint commit_pylint

28
tests/ci_git_prep.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/sh
echo "Travis Pull Request: $TRAVIS_PULL_REQUEST"
echo "Travis Branch: $TRAVIS_BRANCH"
git_setup() {
git config user.email "travis@travis-ci.org"
git config user.name "Travis CI"
}
detect_branch() {
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo $TRAVIS_BRANCH
else
echo $TRAVIS_PULL_REQUEST_BRANCH
fi
}
export CURRENT_BRANCH=$(detect_branch)
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..."
git checkout origin/$CURRENT_BRANCH

2
tests/ci_git_push.sh Normal file
View file

@ -0,0 +1,2 @@
#!/bin/sh
git push $GH_TOKEN@github.com:$TRAVIS_PULL_REQUEST_SLUG.git origin $CURRENT_BRANCH > /dev/null 2>&1

0
tests/ci_prepare.py Normal file → Executable file
View file