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

Side by Side 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: Add label 'Automated Chromium Export' to all new PRs Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 from webkitpy.w3c.local_wpt import LocalWPT
7 from webkitpy.w3c.chromium_wpt import ChromiumWPT
8 from webkitpy.w3c.chromium_commit import ChromiumCommit
9
10 _log = logging.getLogger(__name__)
11
12
13 class TestExporter(object):
14
15 def __init__(self, host, wpt_github, dry_run=False):
16 self.host = host
17 self.wpt_github = wpt_github
18 self.dry_run = dry_run
19
20 def run(self):
21 # First, poll for an in-flight pull request and merge if exists
22 pull_requests = self.wpt_github.in_flight_pull_requests()
23
24 if len(pull_requests) == 1:
25 pull_request = pull_requests.pop()
26
27 _log.info('In-flight PR found: #%d', pull_request['number'])
28 _log.info(pull_request['title'])
29
30 # In the future we would check the PR status here.
31 # Because the current bot doesn't use the GitHub status system
foolip 2016/11/29 11:12:20 You mean the stability checker I assume? There are
32 # (it just comments the results), this will be a bit more difficult.
33
34 if self.dry_run:
35 _log.info('[dry_run] Would have attempted to merge PR')
36 else:
37 _log.info('Merging...')
38 self.wpt_github.merge_pull_request(pull_request['number'])
39 _log.info('PR merged!')
40 elif len(pull_requests) > 1:
41 _log.error(pull_requests)
42 raise Exception('More than two in-flight PRs!')
foolip 2016/11/29 11:12:21 Maybe link to them so that a human can close them?
jeffcarp 2016/11/29 19:00:48 👍
43
44 # Second, look for exportable commits in Chromium
45 # At this point, no in-flight PRs should exist
46 # If there was an issue merging, it should have errored out
47 local_wpt = LocalWPT(self.host, use_github=False)
48 chromium_wpt = ChromiumWPT(self.host)
49
50 # TODO(jeffcarp): fetch Chromium origin/master as well
foolip 2016/11/29 11:12:21 I'm thinking this could be done by the system that
jeffcarp 2016/11/29 19:00:48 Good point I'll change the TODO.
51 # TODO(jeffcarp): move WPT fetch out of its constructor to match planned ChromiumWPT pattern
52
53 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit()
54 assert chromium_commit, 'No Chromium commit found, this is impossible'
55
56 wpt_behind_master = local_wpt.commits_behind_master(wpt_commit)
57
58 _log.info('\nLast Chromium export commit in web-platform-tests:')
59 _log.info('web-platform-tests@%s', wpt_commit)
60 _log.info('(%d behind web-platform-tests@origin/master)', wpt_behind_mas ter)
61
62 _log.info('\nThe above WPT commit points to the following Chromium commi t:')
63 _log.info('chromium@%s', chromium_commit.sha)
64 _log.info('(%d behind chromium@origin/master)', chromium_commit.num_behi nd_master())
65
66 # TODO(jeffcarp): Have this function return ChromiumCommits
67 exportable_commits = chromium_wpt.exportable_commits_since(chromium_comm it.sha)
68
69 if not exportable_commits:
70 _log.info('No exportable commits found in Chromium, stopping.')
71 return
72
73 _log.info('Found %d exportable commits in chromium:', len(exportable_com mits))
foolip 2016/11/29 11:12:21 s/chromium/Chromium/, or the other way around abov
74 for commit in exportable_commits:
75 _log.info('- %s %s', commit, chromium_wpt.subject(commit))
76
77 outbound_commit = ChromiumCommit(self.host, sha=exportable_commits[-1])
foolip 2016/11/29 11:12:21 --reverse inside exportable_commits_since would ma
78 _log.info('Picking the earliest commit and creating a PR')
79 _log.info('- %s %s', outbound_commit.sha, outbound_commit.subject())
80
81 if self.dry_run:
82 _log.info('[dry_run] Stopping before creating PR')
83 return
84
85 patch = outbound_commit.format_patch()
86 message = outbound_commit.message()
87
88 local_branch_name = local_wpt.create_branch_with_patch(message, patch)
89
90 self.wpt_github.create_pr(
91 local_branch_name=local_branch_name,
92 desc_title=outbound_commit.subject(),
93 body=outbound_commit.body())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698