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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/sync_wpt.py

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Fix spacing issues 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 argparse
6 import base64
7 import httplib2
8 import json
9 import logging
10 import os
11
12 from webkitpy.common.host import Host
13 from webkitpy.common.system.executive import ScriptError
14 from webkitpy.w3c.chromium_wpt import ChromiumWPT
15 from webkitpy.w3c.local_wpt import LocalWPT
16 from webkitpy.w3c.test_importer import configure_logging
17
18 _log = logging.getLogger(__name__)
19
20
21 def main():
22 configure_logging()
23 parser = argparse.ArgumentParser(description='WPT Sync')
24 parser.add_argument('--no-fetch', action='store_true')
25 options = parser.parse_args()
26
27 host = Host()
28
29 # TODO(jeffcarp): the script does not handle reverted changes right now
30
31 local_wpt = LocalWPT(host, no_fetch=options.no_fetch, use_github=True)
32 chromium_wpt = ChromiumWPT(host)
33 wpt_commit, chromium_commit = local_wpt.most_recent_chromium_commit()
34
35 if chromium_commit:
36 _log.info('Found last exported WPT commit:')
37 _log.info('- web-platform-tests@%s', wpt_commit)
38 _log.info('- chromium@%s', chromium_commit)
39 else:
40 _log.info('No Chromium export commits found in WPT, stopping.')
41 return
42
43 _log.info('Finding exportable commits in Chromium since %s...', chromium_com mit)
44 exportable_commits = chromium_wpt.exportable_commits_since(chromium_commit)
45
46 if exportable_commits:
47 _log.info('Found %s exportable commits in chromium:', len(exportable_com mits))
48 for commit in exportable_commits:
49 _log.info('- %s %s', commit, chromium_wpt.subject(commit))
50 else:
51 _log.info('No exportable commits found in Chromium, stopping.')
52 return
53
54 for commit in exportable_commits:
55 _log.info('Uploading %s', chromium_wpt.subject(commit))
56 patch = chromium_wpt.format_patch(commit)
57 message = chromium_wpt.message(commit)
58 try:
59 commit_position = chromium_wpt.commit_position(commit)
60 except ScriptError as exp:
61 _log.error(exp)
62 _log.error('This could mean you have local commits on your chromium branch '
63 '(That lack a Cr-Commit-Position footer).')
64 # TODO(jeffcarp): include flag that lets you exclude local commits
65 raise
66
67 assert commit_position
68 message += '\n\nCr-Commit-Position: {}'.format(commit_position)
69 branch_name = 'chromium-try-{}'.format(commit)
70 local_wpt.create_branch_with_patch(branch_name, message, patch)
71
72 desc_title = chromium_wpt.subject(commit)
73 user = os.environ.get('GH_USER')
74 assert user
75 pr_branch_name = '{}:{}'.format(user, branch_name)
76 github_create_pr(pr_branch_name, desc_title)
77
78
79 def github_auth_token():
80 user = os.environ.get('GH_USER')
81 token = os.environ.get('GH_TOKEN')
82 if not (user and token):
83 _log.error('GH_USER and/or GH_TOKEN env vars are not set.')
84 assert user and token
85 return base64.encodestring('{}:{}'.format(user, token))
86
87
88 def github_create_pr(branch_name, desc_title):
89 # https://developer.github.com/v3/pulls/#create-a-pull-request
90 conn = httplib2.Http()
91 headers = {
92 "Accept": "application/vnd.github.v3+json",
93 "Authorization": "Basic " + github_auth_token()
94 }
95 body = {
96 "title": desc_title,
97 "body": "Test PR - testing export from Chromium",
98 "head": branch_name,
99 "base": "master"
100 }
101 resp, content = conn.request("https://api.github.com/repos/w3c/web-platform- tests/pulls",
102 "POST", body=json.JSONEncoder().encode(body), h eaders=headers)
103 _log.info("GitHub response: %s", content)
104 if resp["status"] != "201":
105 return None
106 return json.loads(content)
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698