forked from mirrors/thatmattlove-hyperglass
Merge pull request #3 from checktheroads/ci-cleanup
ci cleanups - No longer doing auto blackformatting or auto pylint badging
This commit is contained in:
commit
83b81a037d
7 changed files with 43 additions and 31 deletions
|
|
@ -12,15 +12,10 @@ install:
|
|||
- pip3 install -r requirements.txt
|
||||
before_script:
|
||||
- pip3 install -r ./tests/requirements_dev.txt
|
||||
- pip3 install anybadge
|
||||
- git checkout master
|
||||
- black hyperglass
|
||||
- python3 ./manage.py pylint-badge --integer-only True
|
||||
- ./tests/ci_git.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:
|
||||
- git push origin master
|
||||
|
|
|
|||
19
manage.py
19
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
28
tests/ci_git_prep.sh
Executable file
28
tests/ci_git_prep.sh
Executable 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
2
tests/ci_git_push.sh
Normal 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
0
tests/ci_prepare.py
Normal file → Executable file
Loading…
Add table
Reference in a new issue