rev: v2.5.0
hooks:
- id: check-json
- - id: flake8
- args: ['--max-line-length=88']
- exclude: docs/*
- id: trailing-whitespace
- repo: https://github.com/jorisroovers/gitlint
jenkins-config/.*
)$
+ - repo: https://github.com/ambv/black
+ rev: stable
+ hooks:
+ - id: black
+
+ - repo: https://gitlab.com/pycqa/flake8
+ rev: 3.8.3
+ hooks:
+ - id: flake8
+ args: ["--max-line-length=88"]
+
+ - repo: https://github.com/pycqa/bandit
+ rev: 1.6.2
+ hooks:
+ - id: bandit
+ # Bandit does not need to run on test code
+ exclude: tests/*
+
+ - repo: https://github.com/pycqa/pydocstyle
+ rev: 5.0.2
+ hooks:
+ - id: pydocstyle
+
- repo: https://github.com/adrienverge/yamllint
rev: v1.23.0
hooks:
##############################################################################
"""Ensures that the jjb-version in tox and releng-jobs.yaml match."""
-__author__ = 'Thanh Ha'
+__author__ = "Thanh Ha"
import os
def check_jjb_version(tox_file, releng_jobs_file):
- with open(tox_file, 'r') as _file:
+ """Check that JJB version matches in job cfg and tox.ini."""
+ with open(tox_file, "r") as _file:
for num, line in enumerate(_file, 1):
- if re.search('env:JJB_VERSION:', line):
- jjb_version_tox = line.rsplit(':', 1)[1].replace('}', '').strip()
+ if re.search("env:JJB_VERSION:", line):
+ jjb_version_tox = line.rsplit(":", 1)[1].replace("}", "").strip()
break
- with open(releng_jobs_file, 'r') as _file:
+ with open(releng_jobs_file, "r") as _file:
for num, line in enumerate(_file, 1):
- if re.search('jjb-version: ', line):
- jjb_version = line.rsplit(':', 1)[1].strip()
+ if re.search("jjb-version: ", line):
+ jjb_version = line.rsplit(":", 1)[1].strip()
break
- print('JJB version in jjb/releng-jobs.yaml: {}'.format(jjb_version))
- print('JJB version in tox.ini: {}'.format(jjb_version_tox))
+ print("JJB version in jjb/releng-jobs.yaml: {}".format(jjb_version))
+ print("JJB version in tox.ini: {}".format(jjb_version_tox))
if jjb_version != jjb_version_tox:
- print('ERROR: JJB version in jjb/releng-jobs.yaml and tox.ini MUST match.')
+ print("ERROR: JJB version in jjb/releng-jobs.yaml and tox.ini MUST match.")
sys.exit(1)
if __name__ == "__main__":
- check_jjb_version('tox.ini', os.path.join('jjb', 'releng-jobs.yaml'))
+ check_jjb_version("tox.ini", os.path.join("jjb", "releng-jobs.yaml"))
The production prefix MUST always be a blank string.
"""
-__author__ = 'Thanh Ha'
+__author__ = "Thanh Ha"
import os
def check_prefix(filename):
- with open(filename, 'r') as _file:
+ """Check if a prefix was checked into this repo."""
+ with open(filename, "r") as _file:
for num, line in enumerate(_file, 1):
- if re.search('prefix:', line):
- if "''" not in line:
+ if re.search("prefix:", line):
+ if '""' not in line:
print(
- 'ERROR: A non-blank prefix is defined in '
- 'jjb/defaults.yaml. The prefix MUST be set to blank '
- '\'\' in production!'
+ "ERROR: A non-blank prefix is defined in "
+ "jjb/defaults.yaml. The prefix MUST be set to blank "
+ '"" in production!'
)
sys.exit(1)
if __name__ == "__main__":
- check_prefix(os.path.join('jjb', 'defaults.yaml'))
+ check_prefix(os.path.join("jjb", "defaults.yaml"))
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
-# Ensures that we are only ever using one robot system
-#
-# Due to the way the Jenkins OpenStack Cloud plugin works we can only limit
-# max parallel robot systems by the VM. So having multiple VM types makes it
-# very difficult for us to properly limit the amount of parallel robot runs.
+"""Ensures that we are only ever using one robot system.
+
+Due to the way the Jenkins OpenStack Cloud plugin works we can only limit
+max parallel robot systems by the VM. So having multiple VM types makes it
+very difficult for us to properly limit the amount of parallel robot runs.
+"""
-__author__ = 'Thanh Ha'
+__author__ = "Thanh Ha"
import fnmatch
"""
robots = set()
- with open(filename, 'r') as _file:
+ with open(filename, "r") as _file:
for num, line in enumerate(_file, 1):
- if re.search('centos7-robot', line):
+ if re.search("centos7-robot", line):
robots.add(line.rsplit(maxsplit=1)[1])
return robots
if __name__ == "__main__":
robots = []
- for root, dirnames, filenames in os.walk('jjb'):
- for filename in fnmatch.filter(filenames, '*.yaml'):
+ for root, dirnames, filenames in os.walk("jjb"):
+ for filename in fnmatch.filter(filenames, "*.yaml"):
robots += get_robot_systems(os.path.join(root, filename))
if len(robots) > 1:
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
##############################################################################
+"""Configuration for Sphinx."""
-from docs_conf.conf import *
-
+from docs_conf.conf import * # noqa
- defaults:
name: global
- prefix: '' # A prefix for job names sandbox for example: user-
+ prefix: "" # A prefix for job names sandbox for example: user-
karaf-version: karaf4
build-days-to-keep: 30