Add a tox environment for flexible candidate checking
By default ci_check_all_candidate_files.py, does as it implies and checks all candidates for the current election. Add new operation modes for: 1. Checking all files for the current git commit '--HEAD' 2. Checking all files specified on the command line We also add a voting job on the check pipeline only for validating the current review. Local users are encouraged to use this as: tox -e ci-checks-review ; or tox -e ci-checks-review -- path/to/file Change-Id: I0c82c59409bb58169840de42c02072aeae182b2b Co-authored-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
3efc347226
commit
60fb423adf
@ -1,10 +1,21 @@
|
||||
- job:
|
||||
name: election-tox-ci-checks
|
||||
name: election-tox-ci-checks-election
|
||||
parent: openstack-tox
|
||||
description: |
|
||||
Run the ci-checks tox environment
|
||||
Run the ci-checks-election tox environment
|
||||
|
||||
This environment runs the easy, for a machine, to validate election
|
||||
checks.
|
||||
vars:
|
||||
tox_envlist: ci-checks
|
||||
tox_envlist: ci-checks-election
|
||||
|
||||
- job:
|
||||
name: election-tox-ci-checks-review
|
||||
parent: openstack-tox
|
||||
description: |
|
||||
Run the ci-checks-review tox environment
|
||||
|
||||
This environment runs the easy, for a machine, to validate election
|
||||
checks against only files modified in the current review.
|
||||
vars:
|
||||
tox_envlist: ci-checks-review
|
||||
|
@ -7,12 +7,13 @@
|
||||
jobs:
|
||||
- openstack-tox-py27
|
||||
- openstack-tox-linters
|
||||
- election-tox-ci-checks
|
||||
- election-tox-ci-checks-review
|
||||
- election-tox-ci-checks-election
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-py27
|
||||
- openstack-tox-linters
|
||||
- election-tox-ci-checks
|
||||
- election-tox-ci-checks-election
|
||||
post:
|
||||
jobs:
|
||||
- publish-tox-docs-static
|
||||
|
@ -16,6 +16,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from openstack_election import check_candidacy
|
||||
from openstack_election import utils
|
||||
@ -75,6 +76,19 @@ def check_for_changes(projects, filepath, limit):
|
||||
return bool(changes_found)
|
||||
|
||||
|
||||
def find_modified_candidate_files():
|
||||
"Return a list of files modified by the most recent commit."
|
||||
results = subprocess.check_output(
|
||||
['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^']
|
||||
).decode('utf-8')
|
||||
filenames = [
|
||||
l.strip()
|
||||
for l in results.splitlines()
|
||||
if l.startswith(utils.CANDIDATE_PATH + '/')
|
||||
]
|
||||
return filenames
|
||||
|
||||
|
||||
def main():
|
||||
description = ('Check all files under the current open election are valid')
|
||||
parser = argparse.ArgumentParser(description)
|
||||
@ -90,6 +104,14 @@ def main():
|
||||
default=utils.conf['release'],
|
||||
help=('The relase to validate candidates against. '
|
||||
'Default: %(default)s'))
|
||||
parser.add_argument('--HEAD',
|
||||
dest='head_only',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Validate all candidates.')
|
||||
parser.add_argument('files',
|
||||
nargs='*',
|
||||
help='Candidate files to validate.')
|
||||
|
||||
args = parser.parse_args()
|
||||
errors = False
|
||||
@ -99,7 +121,14 @@ def main():
|
||||
|
||||
projects = utils.get_projects(tag=args.tag, fallback_to_master=True)
|
||||
|
||||
for filepath in utils.find_candidate_files(election=args.release):
|
||||
if args.files:
|
||||
to_process = args.files
|
||||
elif args.head_only:
|
||||
to_process = find_modified_candidate_files()
|
||||
else:
|
||||
to_process = utils.find_candidate_files(election=args.release)
|
||||
|
||||
for filepath in to_process:
|
||||
candidate_ok = True
|
||||
|
||||
candidate_ok &= validate_filename(filepath)
|
||||
|
5
tox.ini
5
tox.ini
@ -29,7 +29,10 @@ commands = {posargs}
|
||||
[testenv:docs]
|
||||
commands = sphinx-build -v -W -b html -d doc/build/doctrees doc/source doc/build/html
|
||||
|
||||
[testenv:ci-checks]
|
||||
[testenv:ci-checks-review]
|
||||
commands = ci-check-all-candidate-files {posargs:--HEAD}
|
||||
|
||||
[testenv:ci-checks-election]
|
||||
commands = ci-check-all-candidate-files
|
||||
|
||||
[flake8]
|
||||
|
Loading…
x
Reference in New Issue
Block a user