1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

testing pre-commit

This commit is contained in:
checktheroads
2019-06-16 13:04:47 -07:00
parent cb356ffc11
commit 74d3fd36a2
4 changed files with 44 additions and 1 deletions

6
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/python/black
rev: stable
hooks:
- id: black
language_version: python3

14
.travis.yml Normal file
View File

@@ -0,0 +1,14 @@
language: python
python:
- "3.6"
before_install:
- sudo apt-get update -q
- sudo apt-get install -y redis
- pip3 install black
install:
- pip3 install -r requirements.txt
- pip3 install gunicorn
- pip3 install pylint
before_script:
- black hyperglass/
- pylint hyperglass/

View File

@@ -33,6 +33,30 @@ def hg():
pass
@hg.command("pylint-badge", help="Runs Pylint and generates a badge for GitHub")
def pylint_badge():
try:
import re
import anybadge
from pylint import epylint
pylint_stdout, pylint_stderr = epylint.py_run("hyperglass", return_std=True)
pylint_score = re.search(
r"Your code has been rated at (\d+\.\d+)\/10 \(previous run:.*",
pylint_stdout.getvalue(),
).group(1)
if not pylint_score == "10.00":
raise RuntimeError(f"Pylint score {pylint_score} not acceptable.")
ab_thresholds = {1: "red", 10: "green"}
badge = anybadge.Badge("pylint", pylint_score, thresholds=ab_thresholds)
badge.write_badge("pylint.svg")
click.secho(
f"Created Pylint badge for score: {pylint_score}", fg="blue", bold=True
)
except ImportError as error_exception:
click.secho(f"Import error:\n{error_exception}", fg="red", bold=True)
@hg.command("pre-check", help="Check hyperglass config & readiness")
def pre_check():
if sys.version_info < (3, 6):

View File

@@ -1,6 +1,5 @@
Flask
Flask-Limiter
flask-caching
Jinja2
toml
netmiko