Bug 1186834 - run flake8 automatically on harness for talos. r=jmaher
authorJulien Pagès <j.parkouss@gmail.com>
Mon, 23 Nov 2015 17:04:51 +0100
changeset 274233 eac92ea657736ebe6d64aa0de12f63d1417f1eb3
parent 274232 587e0f970a893362197cb55de2b51d8c51f1193b
child 274234 b27bdc3c663a2e482ae93351ae2fe64ae389754a
push id29727
push usercbook@mozilla.com
push dateThu, 26 Nov 2015 15:54:54 +0000
treeherdermozilla-central@74c7941a9e22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1186834
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1186834 - run flake8 automatically on harness for talos. r=jmaher
testing/mozharness/mozharness/mozilla/testing/talos.py
--- a/testing/mozharness/mozharness/mozilla/testing/talos.py
+++ b/testing/mozharness/mozharness/mozilla/testing/talos.py
@@ -315,16 +315,18 @@ class Talos(TestingMixin, MercurialScrip
         # talos in harness requires what else is
         # listed in talos requirements.txt file.
         self.install_module(
             requirements=[os.path.join(self.talos_path,
                                        'requirements.txt')]
         )
         # install jsonschema for perfherder validation
         self.install_module(module="jsonschema")
+        # install flake8 for static code validation
+        self.install_module(module="flake8")
 
     def _validate_treeherder_data(self, parser):
         # late import is required, because install is done in create_virtualenv
         import jsonschema
 
         if len(parser.found_perf_data) != 1:
             self.critical("PERFHERDER_DATA was seen %d times, expected 1."
                           % len(parser.found_perf_data))
@@ -338,16 +340,22 @@ class Talos(TestingMixin, MercurialScrip
             with open(schema_path) as f:
                 schema = json.load(f)
             data = json.loads(parser.found_perf_data[0])
             jsonschema.validate(data, schema)
         except:
             self.exception("Error while validating PERFHERDER_DATA")
             parser.update_worst_log_and_tbpl_levels(WARNING, TBPL_WARNING)
 
+    def _flake8_check(self, parser):
+        if self.run_command([self.query_python_path('flake8'),
+                             os.path.join(self.talos_path, 'talos')]) != 0:
+            self.critical('flake8 check failed.')
+            parser.update_worst_log_and_tbpl_levels(WARNING, TBPL_WARNING)
+
     def run_tests(self, args=None, **kw):
         """run Talos tests"""
 
         # get talos options
         options = self.talos_options(args=args, **kw)
 
         # XXX temporary python version check
         python = self.query_python_path()
@@ -363,16 +371,18 @@ class Talos(TestingMixin, MercurialScrip
             self.mkdir_p(env['MOZ_UPLOAD_DIR'])
         env = self.query_env(partial_env=env, log_level=INFO)
         # adjust PYTHONPATH to be able to use talos as a python package
         if 'PYTHONPATH' in env:
             env['PYTHONPATH'] = self.talos_path + os.pathsep + env['PYTHONPATH']
         else:
             env['PYTHONPATH'] = self.talos_path
 
+        self._flake8_check(parser)
+
         # sets a timeout for how long talos should run without output
         output_timeout = self.config.get('talos_output_timeout', 3600)
         # run talos tests
         run_tests = os.path.join(self.talos_path, 'talos', 'run_tests.py')
         command = [python, run_tests, '--debug'] + options
         self.return_code = self.run_command(command, cwd=self.workdir,
                                             output_timeout=output_timeout,
                                             output_parser=parser,