mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
testing pre-commit
This commit is contained in:
6
.pre-commit-config.yaml
Normal file
6
.pre-commit-config.yaml
Normal 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
14
.travis.yml
Normal 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/
|
24
manage.py
24
manage.py
@@ -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):
|
||||
|
@@ -1,6 +1,5 @@
|
||||
Flask
|
||||
Flask-Limiter
|
||||
flask-caching
|
||||
Jinja2
|
||||
toml
|
||||
netmiko
|
||||
|
Reference in New Issue
Block a user