summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSorin Sbarnea <ssbarnea@redhat.com>2018-08-03 15:51:57 +0100
committerSorin Sbarnea <ssbarnea@redhat.com>2018-08-29 19:03:09 +0100
commit04e2fcf4d8aa23fb3d727fe021a44324b5b92c33 (patch)
tree5ef66cf2274845555bc6ca96ee782f7233342d95
parent1f06003492daac10c2ea462de142aad09f05781a (diff)
replace pep8 check with generic linters
Includes removal of file pattern from pep8 job which prevented it from running on most changes. Linters will use multiple tools and a pattern would make it fail to spot errors. This check should run even if no files are changed, so it would be able to check commit messages. There are no real load implications because linters check is just a simple tox execution which has minimal resource requirements. Includes reactivaction or linting which was not running on the entire repository. This required few minor fixes. Partial-Bug: #1786286 Change-Id: I4d4279309af55c2663e98bd0cdec9224f03c1fa0
Notes
Notes (review): Verified-1: RDO Third Party CI <dmsimard+rdothirdparty@redhat.com> Code-Review+2: Marios Andreou <marios@redhat.com> Code-Review+1: Arx Cruz <arxcruz@redhat.com> Workflow+1: Emilien Macchi <emilien@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 06 Sep 2018 01:42:23 +0000 Reviewed-on: https://review.openstack.org/588588 Project: openstack-infra/tripleo-ci Branch: refs/heads/master
-rw-r--r--scripts/emit_releases_file/test_write_bash_script.py4
-rw-r--r--scripts/emit_releases_file/test_yaml_parsing.py2
-rwxr-xr-xscripts/heat-deploy-times.py6
-rwxr-xr-xscripts/tripleo-jobs-gerrit.py21
-rw-r--r--tox.ini13
-rw-r--r--zuul.d/layout.yaml4
6 files changed, 30 insertions, 20 deletions
diff --git a/scripts/emit_releases_file/test_write_bash_script.py b/scripts/emit_releases_file/test_write_bash_script.py
index e074d5b..24569ad 100644
--- a/scripts/emit_releases_file/test_write_bash_script.py
+++ b/scripts/emit_releases_file/test_write_bash_script.py
@@ -1,8 +1,8 @@
1from emit_releases_file import write_releases_dictionary_to_bash 1from emit_releases_file import write_releases_dictionary_to_bash
2 2
3import os
4import mock 3import mock
5from mock import mock_open 4from mock import mock_open
5import os
6from six import PY2 6from six import PY2
7 7
8import pytest 8import pytest
@@ -64,5 +64,5 @@ def test_output_is_sourceable(mock, releases_dictionary):
64 handle = mock() 64 handle = mock()
65 args, _ = handle.write.call_args 65 args, _ = handle.write.call_args
66 written_content = args[0] 66 written_content = args[0]
67 # TODO: check environment variables 67 # TODO(Llorente): check environment variables
68 assert (0 == os.system(written_content)) 68 assert (0 == os.system(written_content))
diff --git a/scripts/emit_releases_file/test_yaml_parsing.py b/scripts/emit_releases_file/test_yaml_parsing.py
index 5714469..b3f4685 100644
--- a/scripts/emit_releases_file/test_yaml_parsing.py
+++ b/scripts/emit_releases_file/test_yaml_parsing.py
@@ -2,8 +2,8 @@ from emit_releases_file import load_featureset_file
2 2
3import mock 3import mock
4import pytest 4import pytest
5import yaml
6from six import PY2 5from six import PY2
6import yaml
7 7
8 8
9if PY2: 9if PY2:
diff --git a/scripts/heat-deploy-times.py b/scripts/heat-deploy-times.py
index b43aecd..346fafc 100755
--- a/scripts/heat-deploy-times.py
+++ b/scripts/heat-deploy-times.py
@@ -21,6 +21,7 @@ import json
21import sys 21import sys
22import time 22import time
23 23
24
24def process_events(all_events, events): 25def process_events(all_events, events):
25 times = {} 26 times = {}
26 for event in all_events: 27 for event in all_events:
@@ -41,12 +42,13 @@ def process_events(all_events, events):
41 elif status == 'CREATE_COMPLETE' or status == 'CREATE_FAILED': 42 elif status == 'CREATE_COMPLETE' or status == 'CREATE_FAILED':
42 times[name]['elapsed'] = etime - times[name]['start'] 43 times[name]['elapsed'] = etime - times[name]['start']
43 for name, data in sorted(times.items(), 44 for name, data in sorted(times.items(),
44 key = lambda x: x[1]['elapsed'], 45 key=lambda x: x[1]['elapsed'],
45 reverse=True): 46 reverse=True):
46 elapsed = 'Still in progress' 47 elapsed = 'Still in progress'
47 if times[name]['elapsed'] is not None: 48 if times[name]['elapsed'] is not None:
48 elapsed = times[name]['elapsed'] 49 elapsed = times[name]['elapsed']
49 print '%s %s' % (name, elapsed) 50 print('%s %s' % (name, elapsed))
51
50 52
51if __name__ == '__main__': 53if __name__ == '__main__':
52 stdin = sys.stdin.read() 54 stdin = sys.stdin.read()
diff --git a/scripts/tripleo-jobs-gerrit.py b/scripts/tripleo-jobs-gerrit.py
index 420a747..0c2ed56 100755
--- a/scripts/tripleo-jobs-gerrit.py
+++ b/scripts/tripleo-jobs-gerrit.py
@@ -1,11 +1,11 @@
1#!/usr/bin/python 1#!/usr/bin/python
2 2
3import argparse 3import argparse
4import sys 4import datetime
5import subprocess
6import json 5import json
7import re 6import re
8import datetime 7import subprocess
8import sys
9 9
10# Do not include the -nv suffix in the job name here. The code will handle 10# Do not include the -nv suffix in the job name here. The code will handle
11# reading both the voting and non-voting forms of the job if they exist. 11# reading both the voting and non-voting forms of the job if they exist.
@@ -52,7 +52,7 @@ def get_gerrit_reviews(project, status="open", branch="master", limit="30"):
52 cmd = 'ssh review.openstack.org -p29418 gerrit' \ 52 cmd = 'ssh review.openstack.org -p29418 gerrit' \
53 ' query "%s project: %s branch: %s" --comments' \ 53 ' query "%s project: %s branch: %s" --comments' \
54 ' --format JSON limit: %s --patch-sets --current-patch-set'\ 54 ' --format JSON limit: %s --patch-sets --current-patch-set'\
55 % (status_query, project, branch,limit) 55 % (status_query, project, branch, limit)
56 p = subprocess.Popen([cmd], shell=True, stdin=subprocess.PIPE, 56 p = subprocess.Popen([cmd], shell=True, stdin=subprocess.PIPE,
57 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 57 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
58 stdout = p.stdout 58 stdout = p.stdout
@@ -82,7 +82,7 @@ def process_jenkins_comment_message(message, job_names):
82 job_results = {} 82 job_results = {}
83 for line in message.split('\n'): 83 for line in message.split('\n'):
84 if line and line[0] == '-': 84 if line and line[0] == '-':
85 split = line.split(" ",6) 85 split = line.split(" ", 6)
86 voting_job_name = split[1] 86 voting_job_name = split[1]
87 if voting_job_name.endswith('-nv'): 87 if voting_job_name.endswith('-nv'):
88 voting_job_name = voting_job_name[:-3] 88 voting_job_name = voting_job_name[:-3]
@@ -108,7 +108,8 @@ def gen_html(data, html_file, table_file, stats_hours, job_names, options):
108 count = 0 108 count = 0
109 109
110 reversed_sorted_keys = [(x['id'], x['patchset']) for x in 110 reversed_sorted_keys = [(x['id'], x['patchset']) for x in
111 reversed(sorted(data.values(), key=lambda y: y['ts']))] 111 reversed(sorted(data.values(),
112 key=lambda y: y['ts']))]
112 passed_jobs = 0 113 passed_jobs = 0
113 partial_jobs = 0 114 partial_jobs = 0
114 failed_jobs = 0 115 failed_jobs = 0
@@ -219,7 +220,10 @@ def main(args=sys.argv[1:]):
219 # project reviews 220 # project reviews
220 proj_reviews = [] 221 proj_reviews = []
221 for proj in opts.p.split(","): 222 for proj in opts.p.split(","):
222 proj_reviews.extend(get_gerrit_reviews(proj, status=opts.s, branch=opts.b, limit=opts.l)) 223 proj_reviews.extend(get_gerrit_reviews(proj,
224 status=opts.s,
225 branch=opts.b,
226 limit=opts.l))
223 results = {} 227 results = {}
224 for review in proj_reviews: 228 for review in proj_reviews:
225 for ts, message in get_jenkins_comment_message(review).iteritems(): 229 for ts, message in get_jenkins_comment_message(review).iteritems():
@@ -242,7 +246,8 @@ def main(args=sys.argv[1:]):
242 results[key].setdefault( 246 results[key].setdefault(
243 'ci_results', {}).update(ci_results) 247 'ci_results', {}).update(ci_results)
244 248
245 gen_html(results, opts.o, "%s-table" % opts.o, 24, job_names,opts) 249 gen_html(results, opts.o, "%s-table" % opts.o, 24, job_names, opts)
250
246 251
247if __name__ == '__main__': 252if __name__ == '__main__':
248 exit(main()) 253 exit(main())
diff --git a/tox.ini b/tox.ini
index 1f561f2..0dfcb44 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
1[tox] 1[tox]
2envlist = pep8, py27, py35 2envlist = linters, py27, py35
3 3
4[testenv] 4[testenv]
5usedevelop = True 5usedevelop = True
@@ -14,10 +14,15 @@ commands = {posargs}
14deps = pyflakes 14deps = pyflakes
15commands = pyflakes setup.py scripts 15commands = pyflakes setup.py scripts
16 16
17[testenv:pep8] 17[testenv:linters]
18changedir = scripts/emit_releases_file
19whitelist_externals = bash 18whitelist_externals = bash
20commands = flake8 --max-line-length 80 19commands = flake8 --max-line-length 80 {toxinidir} {posargs}
20
21# deprecated: use linters instead. kept only as a convenience alias
22[testenv:pep8]
23envdir = {toxworkdir}/linters
24whitelist_externals = {[testenv:linters]whitelist_externals}
25commands = {[testenv:linters]commands}
21 26
22[testenv:cireport] 27[testenv:cireport]
23passenv = 28passenv =
diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml
index 305386d..575f6ce 100644
--- a/zuul.d/layout.yaml
+++ b/zuul.d/layout.yaml
@@ -19,9 +19,7 @@
19 - openstack-tox-py35: 19 - openstack-tox-py35:
20 files: 20 files:
21 - ^scripts/emit_releases_file/.*$ 21 - ^scripts/emit_releases_file/.*$
22 - openstack-tox-pep8: 22 - openstack-tox-linters
23 files:
24 - ^scripts/emit_releases_file/.*$
25 - tripleo-ci-centos-7-scenario001-multinode-oooq: 23 - tripleo-ci-centos-7-scenario001-multinode-oooq:
26 files: 24 files:
27 - ^playbooks/tripleo-ci/.*$ 25 - ^playbooks/tripleo-ci/.*$