Bug 1468812 - [ccov] Don't re-download MOZ_FETCHES if it's already been setup by run-task r=marco
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 27 Jul 2018 12:44:48 +0000
changeset 428798 bc10207e894dc24c7ab729a0106259f0a249a38d
parent 428797 d5bd9f1381b3fdd998e12c13ab7fb31302c9a338
child 428799 c03547ff07973aa3f3c6b46903d914a585f39f1b
push id34345
push userrgurzau@mozilla.com
push dateSat, 28 Jul 2018 09:44:50 +0000
treeherdermozilla-central@8a1379826329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarco
bugs1468812
milestone63.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 1468812 - [ccov] Don't re-download MOZ_FETCHES if it's already been setup by run-task r=marco The 'codecoverage' mozharness script and a code coverage mach command for Android did their own custom bootstrapping of MOZ_FETCHES. Now that run-task does this automatically, we should make sure we aren't downloading MOZ_FETCHES twice. Depends on D2167. Differential Revision: https://phabricator.services.mozilla.com/D2368
mobile/android/mach_commands.py
testing/mozharness/mozharness/mozilla/testing/codecoverage.py
--- a/mobile/android/mach_commands.py
+++ b/mobile/android/mach_commands.py
@@ -216,30 +216,22 @@ class MachCommands(MachCommandBase):
         self.android_test([enable_ccov])
 
         self.gradle(self.substs['GRADLE_ANDROID_TEST_CCOV_REPORT_TASKS'] +
                     ['--continue', enable_ccov] + args, verbose=True)
         self._process_jacoco_reports()
         return 0
 
     def _process_jacoco_reports(self):
-        def download_grcov(parent_dir):
-            fetch_script_path = os.path.join(self.topsrcdir, 'taskcluster', 'scripts', 'misc',
-                                             'fetch-content')
-            args = [fetch_script_path, 'task-artifacts', os.environ['MOZ_FETCHES'],
-                    '-d', parent_dir]
-            self.run_process(args, ensure_exit_code=True)
-            return os.path.join(parent_dir, 'grcov')
-
         def run_grcov(grcov_path, input_path):
             args = [grcov_path, input_path, '-t', 'lcov']
             return subprocess.check_output(args)
 
-        with TemporaryDirectory() as xml_dir, TemporaryDirectory() as grcov_dir:
-            grcov = download_grcov(grcov_dir)
+        with TemporaryDirectory() as xml_dir:
+            grcov = os.path.join(os.environ['MOZ_FETCHES_DIR'], 'grcov')
 
             report_xml_template = self.topobjdir + '/gradle/build/mobile/android/%s/reports/jacoco/jacocoTestReport/jacocoTestReport.xml'  # NOQA: E501
             shutil.copy(report_xml_template % 'app', os.path.join(xml_dir, 'app.xml'))
             shutil.copy(report_xml_template % 'geckoview', os.path.join(xml_dir, 'geckoview.xml'))
 
             # Parse output files with grcov.
             grcov_output = run_grcov(grcov, xml_dir)
             grcov_zip_path = os.path.join(self.topobjdir, 'code-coverage-grcov.zip')
--- a/testing/mozharness/mozharness/mozilla/testing/codecoverage.py
+++ b/testing/mozharness/mozharness/mozilla/testing/codecoverage.py
@@ -107,29 +107,33 @@ class CodeCoverageMixin(SingleTestMixin)
 
         os.environ['GCOV_PREFIX_STRIP'] = str(strip_count)
 
         # Install grcov on the test machine
         # Get the path to the build machines gcno files.
         self.url_to_gcno = self.query_build_dir_url('target.code-coverage-gcno.zip')
         self.url_to_chrome_map = self.query_build_dir_url('chrome-map.json')
 
-        # Create the grcov directory, then download it.
-        # TODO: use the fetch-content script to download artifacts.
-        self.grcov_dir = tempfile.mkdtemp()
-        ARTIFACT_URL = 'https://queue.taskcluster.net/v1/task/{task}/artifacts/{artifact}'
-        for word in os.getenv('MOZ_FETCHES').split():
-            artifact, task = word.split('@', 1)
-            filename = os.path.basename(artifact)
-            url = ARTIFACT_URL.format(artifact=artifact, task=task)
-            self.download_file(url, parent_dir=self.grcov_dir)
+        fetches_dir = os.environ.get('MOZ_FETCHES_DIR')
+        if fetches_dir and os.path.isfile(os.path.join(fetches_dir, 'grcov')):
+            self.grcov_dir = fetches_dir
+        else:
+            # Create the grcov directory, then download it.
+            # TODO: use the fetch-content script to download artifacts.
+            self.grcov_dir = tempfile.mkdtemp()
+            ARTIFACT_URL = 'https://queue.taskcluster.net/v1/task/{task}/artifacts/{artifact}'
+            for word in os.getenv('MOZ_FETCHES').split():
+                artifact, task = word.split('@', 1)
+                filename = os.path.basename(artifact)
+                url = ARTIFACT_URL.format(artifact=artifact, task=task)
+                self.download_file(url, parent_dir=self.grcov_dir)
 
-            with tarfile.open(os.path.join(self.grcov_dir, filename), 'r') as tar:
-                tar.extractall(self.grcov_dir)
-            os.remove(os.path.join(self.grcov_dir, filename))
+                with tarfile.open(os.path.join(self.grcov_dir, filename), 'r') as tar:
+                    tar.extractall(self.grcov_dir)
+                os.remove(os.path.join(self.grcov_dir, filename))
 
         # Download the gcno archive from the build machine.
         self.download_file(self.url_to_gcno, parent_dir=self.grcov_dir)
 
         # Download the chrome-map.json file from the build machine.
         self.download_file(self.url_to_chrome_map, parent_dir=self.grcov_dir)
 
     @PostScriptAction('download-and-extract')