Browse Source

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
changes/88/588588/6
Sorin Sbarnea 10 months ago
parent
commit
04e2fcf4d8

+ 2
- 2
scripts/emit_releases_file/test_write_bash_script.py View File

@@ -1,8 +1,8 @@
1 1
 from emit_releases_file import write_releases_dictionary_to_bash
2 2
 
3
-import os
4 3
 import mock
5 4
 from mock import mock_open
5
+import os
6 6
 from six import PY2
7 7
 
8 8
 import pytest
@@ -64,5 +64,5 @@ def test_output_is_sourceable(mock, releases_dictionary):
64 64
     handle = mock()
65 65
     args, _ = handle.write.call_args
66 66
     written_content = args[0]
67
-    # TODO: check environment variables
67
+    # TODO(Llorente): check environment variables
68 68
     assert (0 == os.system(written_content))

+ 1
- 1
scripts/emit_releases_file/test_yaml_parsing.py View File

@@ -2,8 +2,8 @@ from emit_releases_file import load_featureset_file
2 2
 
3 3
 import mock
4 4
 import pytest
5
-import yaml
6 5
 from six import PY2
6
+import yaml
7 7
 
8 8
 
9 9
 if PY2:

+ 4
- 2
scripts/heat-deploy-times.py View File

@@ -21,6 +21,7 @@ import json
21 21
 import sys
22 22
 import time
23 23
 
24
+
24 25
 def process_events(all_events, events):
25 26
     times = {}
26 27
     for event in all_events:
@@ -41,12 +42,13 @@ def process_events(all_events, events):
41 42
             elif status == 'CREATE_COMPLETE' or status == 'CREATE_FAILED':
42 43
                 times[name]['elapsed'] = etime - times[name]['start']
43 44
     for name, data in sorted(times.items(),
44
-                             key = lambda x: x[1]['elapsed'],
45
+                             key=lambda x: x[1]['elapsed'],
45 46
                              reverse=True):
46 47
         elapsed = 'Still in progress'
47 48
         if times[name]['elapsed'] is not None:
48 49
             elapsed = times[name]['elapsed']
49
-        print '%s %s' % (name, elapsed)
50
+        print('%s %s' % (name, elapsed))
51
+
50 52
 
51 53
 if __name__ == '__main__':
52 54
     stdin = sys.stdin.read()

+ 13
- 8
scripts/tripleo-jobs-gerrit.py View File

@@ -1,11 +1,11 @@
1 1
 #!/usr/bin/python
2 2
 
3 3
 import argparse
4
-import sys
5
-import subprocess
4
+import datetime
6 5
 import json
7 6
 import re
8
-import datetime
7
+import subprocess
8
+import sys
9 9
 
10 10
 # Do not include the -nv suffix in the job name here.  The code will handle
11 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 52
     cmd = 'ssh review.openstack.org -p29418 gerrit' \
53 53
           ' query "%s project: %s branch: %s" --comments' \
54 54
           ' --format JSON limit: %s --patch-sets --current-patch-set'\
55
-          % (status_query, project, branch,limit)
55
+          % (status_query, project, branch, limit)
56 56
     p = subprocess.Popen([cmd], shell=True, stdin=subprocess.PIPE,
57 57
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)
58 58
     stdout = p.stdout
@@ -82,7 +82,7 @@ def process_jenkins_comment_message(message, job_names):
82 82
     job_results = {}
83 83
     for line in message.split('\n'):
84 84
         if line and line[0] == '-':
85
-            split = line.split(" ",6)
85
+            split = line.split(" ", 6)
86 86
             voting_job_name = split[1]
87 87
             if voting_job_name.endswith('-nv'):
88 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 108
     count = 0
109 109
 
110 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 113
     passed_jobs = 0
113 114
     partial_jobs = 0
114 115
     failed_jobs = 0
@@ -219,7 +220,10 @@ def main(args=sys.argv[1:]):
219 220
     # project reviews
220 221
     proj_reviews = []
221 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 227
     results = {}
224 228
     for review in proj_reviews:
225 229
         for ts, message in get_jenkins_comment_message(review).iteritems():
@@ -242,7 +246,8 @@ def main(args=sys.argv[1:]):
242 246
             results[key].setdefault(
243 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
 
247 252
 if __name__ == '__main__':
248 253
     exit(main())

+ 9
- 4
tox.ini View File

@@ -1,5 +1,5 @@
1 1
 [tox]
2
-envlist = pep8, py27, py35
2
+envlist = linters, py27, py35
3 3
 
4 4
 [testenv]
5 5
 usedevelop = True
@@ -14,10 +14,15 @@ commands = {posargs}
14 14
 deps = pyflakes
15 15
 commands = pyflakes setup.py scripts
16 16
 
17
-[testenv:pep8]
18
-changedir = scripts/emit_releases_file
17
+[testenv:linters]
19 18
 whitelist_externals = bash
20
-commands = flake8 --max-line-length 80
19
+commands = flake8 --max-line-length 80 {toxinidir} {posargs}
20
+
21
+# deprecated: use linters instead. kept only as a convenience alias
22
+[testenv:pep8]
23
+envdir = {toxworkdir}/linters
24
+whitelist_externals = {[testenv:linters]whitelist_externals}
25
+commands = {[testenv:linters]commands}
21 26
 
22 27
 [testenv:cireport]
23 28
 passenv =

+ 1
- 3
zuul.d/layout.yaml View File

@@ -19,9 +19,7 @@
19 19
         - openstack-tox-py35:
20 20
             files:
21 21
               - ^scripts/emit_releases_file/.*$
22
-        - openstack-tox-pep8:
23
-            files:
24
-              - ^scripts/emit_releases_file/.*$
22
+        - openstack-tox-linters
25 23
         - tripleo-ci-centos-7-scenario001-multinode-oooq:
26 24
             files:
27 25
               - ^playbooks/tripleo-ci/.*$

Loading…
Cancel
Save