testing: add autorefresh/watchman support for --refresh-reviewboard (bug 1264203) r?gps draft
authorbyron jones <glob@mozilla.com>
Thu, 28 Apr 2016 23:53:25 +0800
changeset 8102 53b7e5710ee70d48f46a6fa3aa24c41019e5f869
parent 8101 d9646f12176702bed78922f6a822ca560fd19131
child 8103 1dfff85dab1335600512515180dca9fa6b913c3e
push id821
push userbjones@mozilla.com
push dateThu, 12 May 2016 05:13:51 +0000
reviewersgps
bugs1264203
testing: add autorefresh/watchman support for --refresh-reviewboard (bug 1264203) r?gps Adds a wrapper around |mozreview refresh| which is triggered by watchman. The wrapper calls refresh with the --refresh-reviewboard parameter if any files within reviewboard-fork/ are changed. MozReview-Commit-ID: 62xK8lelyz4
scripts/watchman-refresh-wrapper
testing/vcttesting/docker.py
testing/vcttesting/mozreview.py
new file mode 100755
--- /dev/null
+++ b/scripts/watchman-refresh-wrapper
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# This script is called by watchman (when using |mozreview autorefresh|).
+# It wraps around |mozreview refresh|, adding --refresh-reviewboard if
+# any files inside the reviewboard-fork/ directory were modified.
+
+import os
+import sys
+
+root = sys.argv[1]
+path = sys.argv[2]
+command = '%s/mozreview' % root
+args = [command, 'refresh', path]
+if os.getenv('WATCHMAN_FILES_OVERFLOW') or any(
+        file.startswith('reviewboard-fork/') for file in sys.argv[3:]):
+    args.append('--refresh-reviewboard')
+os.execv(command, args)
--- a/testing/vcttesting/docker.py
+++ b/testing/vcttesting/docker.py
@@ -1030,17 +1030,18 @@ class Docker(object):
                     labels=['hgrb'])
 
             if start_hgweb:
                 f_hgweb_create = e.submit(
                     self.client.create_container,
                     hgweb_image,
                     ports=[80],
                     entrypoint=['/entrypoint-solo'],
-                    command=['/usr/bin/supervisord', '-n'])
+                    command=['/usr/bin/supervisord', '-n'],
+                    labels=['hgweb'])
 
             if start_autoland:
                 f_autolanddb_create = e.submit(
                     self.client.create_container,
                     autolanddb_image,
                     labels=['autolanddb'])
 
                 f_autoland_create = e.submit(
--- a/testing/vcttesting/mozreview.py
+++ b/testing/vcttesting/mozreview.py
@@ -396,26 +396,33 @@ class MozReview(object):
         When enabled, this removes overhead from developers having to manually
         refresh state during development.
         """
         if not WATCHMAN:
             raise Exception('watchman binary not found')
         subprocess.check_call([WATCHMAN, 'watch-project', ROOT])
         name = 'mozreview-%s' % os.path.basename(self._path)
 
+        expression = [
+            'anyof',
+            ['dirname', 'hgext/reviewboard'],
+            ['dirname', 'pylib/mozreview'],
+            ['dirname', 'pylib/rbbz'],
+            ['dirname', 'pylib/reviewboardmods'],
+            ['dirname', 'reviewboard-fork/djblets'],
+            ['dirname', 'reviewboard-fork/reviewboard'],
+        ]
+        command = ['%s/scripts/watchman-refresh-wrapper' % ROOT, ROOT,
+                   self._path]
         data = json.dumps(['trigger', ROOT, {
             'name': name,
             'chdir': ROOT,
-            'expression': ['anyof',
-                ['dirname', 'hgext/reviewboard'],
-                ['dirname', 'pylib/mozreview'],
-                ['dirname', 'pylib/rbbz'],
-                ['dirname', 'reviewboardmods'],
-            ],
-            'command': ['%s/mozreview' % ROOT, 'refresh', self._path],
+            'expression': expression,
+            'command': command,
+            'append_files': True,
         }])
         p = subprocess.Popen([WATCHMAN, '-j'], stdin=subprocess.PIPE)
         p.communicate(data)
         res = p.wait()
         if res != 0:
             raise Exception('error creating watchman trigger')
 
     def repo_urls(self, name):