Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py

Issue 2518313003: Refactor WPT Export to ensure only one PR in flight at a time (Closed)
Patch Set: Delete two unrelated files Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py
new file mode 100644
index 0000000000000000000000000000000000000000..c673145c1703498109f8c08ce13325eb015cca8a
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter.py
@@ -0,0 +1,92 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+from webkitpy.w3c.local_wpt import LocalWPT
+from webkitpy.w3c.chromium_wpt import ChromiumWPT
+
+_log = logging.getLogger(__name__)
+
+class TestExporter(object):
+
+ def __init__(self, host, wpt_github):
+ self.host = host
+ self.wpt_github = wpt_github
+
+ def run(self):
+ # First, poll for an in-flight pull request and merge if exists
+ pull_requests = self.wpt_github.in_flight_pull_requests()
+
+ if len(pull_requests) == 1:
+ pull_request = pull_requests.pop()
+
+ _log.info('In-flight PR found: #%d' % pull_request['number'])
+ _log.info(pull_request['title'])
+
+ # In the future we would check the PR status here.
+ # Because the current bot doesn't use the GitHub status system
+ # (it just comments the results), this will be a bit more difficult.
+
+ _log.info('Merging...')
+ self.wpt_github.merge_pull_request(pull_request['number'])
+ _log.info('PR merged!')
+ elif len(pull_requests) > 1:
+ _log.error(pull_requests)
+ raise Exception('More than two in-flight PRs!')
+
+ # Second, look for exportable commits in Chromium
+ # At this point, no in-flight PRs should exist
+ # If there was an issue merging, it would have errored out
+ local_wpt = LocalWPT(self.host, use_github=False)
+ chromium_wpt = ChromiumWPT(self.host)
+
+ # TODO: fetch Chromium origin/master as well
+ # TODO: move WPT fetch out of its constructor to match planned ChromiumWPT pattern
+
+ wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit()
+ assert chromium_commit, 'No Chromium commit found, this is impossible'
+
+ wpt_behind_master = local_wpt.commits_behind_master(wpt_commit)
+
+ _log.info('Last Chromium export commit in web-platform-tests:')
+ _log.info('web-platform-tests@%s', wpt_commit)
+ _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_master)
+
+ _log.info('The above WPT commit points to the following Chromium commit:')
+ _log.info('chromium@%s', chromium_commit.sha)
+ _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behind_master())
+
+ # TODO: Have this function return ChromiumCommits
+ exportable_commits = chromium_wpt.exportable_commits_since(chromium_commit.sha)
+
+ if not exportable_commits:
+ _log.info('No exportable commits found in Chromium, stopping.')
+ return
+
+ # TODO: make sure we're starting from the *oldest* Chromium commit (write test)
+
+ # TODO: how do we guard against previously PR'd commits being exported?
+ # That's the whole reason we only have one in flight commit at a time
+ # But even though we're pulling WPT Chromium won't be udated yet
+ # But local_wpt.most_recent_chromium_commit() will change
+ # and the Chromium commit it points to will be the latest
+
+ _log.info('Found %d exportable commits in chromium:', len(exportable_commits))
+ for commit in exportable_commits:
+ _log.info('- %s %s', commit, chromium_wpt.subject(commit))
+
+ outbound_commit = ChromiumCommit(host, sha=exportable_commits[0])
+ _log.info('Picking the earliest commit and creating a PR', len(exportable_commits))
+ _log.info('(%s %s)', outbout_commit.sha, outbout_commit.subject())
+
+ # TODO: turn into methods on ChromiumCommit
+ patch = chromium_wpt.format_patch(commit)
+ message = outbound_commit.message()
+
+ local_wpt.create_branch_with_patch(branch_name, message, patch)
+
+ github.create_pr(
+ local_branch_name='chromium-try-{}'.format(commit),
+ desc_title=chromium_commit.subject(),
+ body=chromium_commit.body())

Powered by Google App Engine
This is Rietveld 408576698