Changeset 231925 in webkit
- Timestamp:
- May 17, 2018 3:17:18 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r231919 r231925 1 2018-05-17 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r231912. 4 https://bugs.webkit.org/show_bug.cgi?id=185750 5 6 It is prompting the user when there is no WPT changes 7 (Requested by bmac on #webkit). 8 9 Reverted changeset: 10 11 "Export changes to web-platform-test as part of the webkit- 12 patch upload workflow" 13 https://bugs.webkit.org/show_bug.cgi?id=184914 14 https://trac.webkit.org/changeset/231912 15 1 16 2018-05-17 Valerie R Young <valerie@bocoup.com> 2 17 -
trunk/Tools/Scripts/webkitpy/tool/commands/upload.py
r231912 r231925 287 287 steps.PostDiff, 288 288 steps.SubmitToEWS, 289 steps.WPTChangeExport,290 289 ] 291 290 long_help = """upload uploads the current diff to bugs.webkit.org. … … 533 532 else: 534 533 self.create_bug_from_patch(options, args, tool) 535 536 537 class WPTChangeExport(AbstractPatchUploadingCommand):538 name = "wpt-change-export"539 help_text = "Opens a pull request to synchronize any changes in the LayoutTests/imported/w3c/web-platform-tests directory"540 argument_names = "[BUGID]"541 steps = [542 steps.WPTChangeExport,543 ]544 545 long_help = """Opens a pull request to the w3c/web-platform-tests546 github repo for any changes in the547 LayoutTests/imported/w3c/web-platform-tests directory. This step548 will noop if there are no changes in the web-platform-tests directory.549 The user will be prompted to provide a github username and OAuth token550 the first time this is run.551 """552 553 def _prepare_state(self, options, args, tool):554 state = {}555 state["bug_id"] = self._bug_id(options, args, tool, state)556 return state -
trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py
r231912 r231925 67 67 from webkitpy.tool.steps.validatechangelogs import ValidateChangeLogs 68 68 from webkitpy.tool.steps.validatereviewer import ValidateReviewer 69 from webkitpy.tool.steps.wptchangeexport import WPTChangeExport -
trunk/Tools/Scripts/webkitpy/w3c/common.py
r231912 r231925 31 31 import json 32 32 import logging 33 import os34 33 35 34 36 WPT_GH_ORG = os.environ.get('WPT_GH_ORG', 'w3c')37 WPT_GH_REPO_NAME = os.environ.get('WPT_GH_REPO_NAME', 'web-platform-tests')35 WPT_GH_ORG = 'w3c' 36 WPT_GH_REPO_NAME = 'web-platform-tests' 38 37 WPT_GH_URL = 'https://github.com/%s/%s/' % (WPT_GH_ORG, WPT_GH_REPO_NAME) 39 38 WPT_MIRROR_URL = 'https://chromium.googlesource.com/external/w3c/web-platform-tests.git' -
trunk/Tools/Scripts/webkitpy/w3c/test_exporter.py
r231912 r231925 29 29 import os 30 30 import time 31 import json32 from urllib2 import HTTPError33 31 34 32 from webkitpy.common.checkout.scm.git import Git … … 38 36 from webkitpy.w3c.wpt_github import WPTGitHub 39 37 from webkitpy.w3c.wpt_linter import WPTLinter 40 from webkitpy.w3c.common import WPT_GH_ORG41 from webkitpy.common.memoized import memoized42 38 43 39 _log = logging.getLogger(__name__) 44 40 45 41 WEBKIT_WPT_DIR = 'LayoutTests/imported/w3c/web-platform-tests' 46 WPT_PR_URL = "https://github.com/ %s/web-platform-tests/pull/" % WPT_GH_ORG42 WPT_PR_URL = "https://github.com/w3c/web-platform-tests/pull/" 47 43 WEBKIT_EXPORT_PR_LABEL = 'webkit-export' 48 44 49 45 50 class WebPlatformTestExporter(object): 46 class TestExporter(object): 47 51 48 def __init__(self, host, options, gitClass=Git, bugzillaClass=Bugzilla, WPTGitHubClass=WPTGitHub, WPTLinterClass=WPTLinter): 52 49 self._host = host … … 56 53 self._host.initialize_scm() 57 54 58 self._WPTGitHubClass = WPTGitHubClass59 self._gitClass = gitClass60 55 self._bugzilla = bugzillaClass() 61 56 self._bug_id = options.bug_id … … 70 65 self._options.repository_directory = webkit_finder.path_from_webkit_base('WebKitBuild', 'w3c-tests', 'web-platform-tests') 71 66 67 self._git = self._ensure_wpt_repository("https://github.com/w3c/web-platform-tests.git", self._options.repository_directory, gitClass) 72 68 self._linter = WPTLinterClass(self._options.repository_directory, host.filesystem) 73 69 74 self._bugzilla_url = "https://bugs.webkit.org/show_bug.cgi?id=" + str(self._bug_id)75 self._commit_message = options.message76 if not self._commit_message:77 self._commit_message = 'WebKit export of ' + self._bugzilla_url if self._bug_id else 'Export made from a WebKit repository'78 79 @property80 def username(self):81 if hasattr(self, '_username'):82 return self._username83 84 self._ensure_username_and_token(self._options)85 return self._username86 87 @property88 def token(self):89 if hasattr(self, '_token'):90 return self._token91 92 self._ensure_username_and_token(self._options)93 return self._token94 95 @property96 @memoized97 def _github(self):98 return self._WPTGitHubClass(self._host, self.username, self.token) if self.username and self.token else None99 100 @property101 @memoized102 def _wpt_fork_branch_github_url(self):103 return "https://github.com/" + self.username + "/web-platform-tests/tree/" + self._public_branch_name104 105 @property106 @memoized107 def _wpt_fork_remote(self):108 wpt_fork_remote = self._options.repository_remote109 if not wpt_fork_remote:110 wpt_fork_remote = self.username111 112 return wpt_fork_remote113 114 @property115 @memoized116 def _wpt_fork_push_url(self):117 wpt_fork_push_url = self._options.repository_remote_url118 if not wpt_fork_push_url:119 wpt_fork_push_url = "https://" + self.username + "@github.com/" + self.username + "/web-platform-tests.git"120 121 return wpt_fork_push_url122 123 @property124 @memoized125 def _git(self):126 return self._ensure_wpt_repository("https://github.com/w3c/web-platform-tests.git", self._options.repository_directory, self._gitClass)127 128 @property129 @memoized130 def _branch_name(self):131 return self._ensure_new_branch_name()132 133 @property134 @memoized135 def _public_branch_name(self):136 options = self._options137 return options.public_branch_name if options.public_branch_name else self._branch_name138 139 @property140 @memoized141 def _wpt_patch(self):142 patch_data = self._host.scm().create_patch(self._options.git_commit, [WEBKIT_WPT_DIR])143 if not patch_data or not 'diff' in patch_data:144 return ''145 return patch_data146 147 def has_wpt_changes(self):148 return bool(self._wpt_patch)149 150 def write_git_patch_file(self):151 _, patch_file = self._filesystem.open_binary_tempfile('wpt_export_patch')152 patch_data = self._wpt_patch153 if not 'diff' in patch_data:154 _log.info('No changes to upstream, patch data is: "%s"' % (patch_data))155 return ''156 # FIXME: We can probably try to use --relative git parameter to not do that replacement.157 patch_data = patch_data.replace(WEBKIT_WPT_DIR + '/', '')158 self._filesystem.write_text_file(patch_file, patch_data)159 return patch_file160 161 def _prompt_for_token(self, options):162 if options.non_interactive:163 return None164 return self._host.user.prompt_password('Enter GitHub OAuth token (or empty string to skip creating a pull request): ')165 166 def _prompt_for_username(self, options):167 if options.non_interactive:168 return None169 return self._host.user.prompt('Enter your GitHub username: ')170 171 def _ensure_username_and_token(self, options):172 70 self._username = options.username 173 71 if not self._username: 174 # FIXME: Use the keychain to store username and oauth token instead of .git/config175 72 self._username = self._git.local_config('github.username').rstrip() 176 73 if not self._username: 177 74 self._username = os.environ.get('GITHUB_USERNAME') 178 75 if not self._username: 179 self._username = self._prompt_for_username(options)180 if not self._username:181 76 raise ValueError("Missing GitHub username, please provide it as a command argument (see help for the command).") 77 elif not self._git.local_config('github.username'): 78 self._git.set_local_config('github.username', self._username) 182 79 183 80 self._token = options.token … … 187 84 self._token = os.environ.get('GITHUB_TOKEN') 188 85 if not self._token: 189 self._token = self._prompt_for_token(options)190 if not self._token:191 86 _log.info("Missing GitHub token, the script will not be able to create a pull request to W3C web-platform-tests repository.") 192 193 if self._token: 194 self._validate_and_save_token(self._username, self._token) 195 196 def _validate_and_save_token(self, username, token): 197 url = 'https://api.github.com/user?access_token=%s' % (token,) 198 try: 199 response = self._host.web.request(method='GET', url=url, data=None) 200 except HTTPError as e: 201 raise Exception("OAuth token is not valid") 202 data = json.load(response) 203 login = data.get('login', None) 204 if login != username: 205 raise Exception("OAuth token does not match the provided username. Provided user: %s, github login: %s" % (username, login)) 206 else: 207 # Username and token are valid. Save them in the git config so we 208 # do not need to ask for them again 209 if not self._git.local_config('github.token'): 210 self._git.set_local_config('github.token', token) 211 if not self._git.local_config('github.username'): 212 self._git.set_local_config('github.username', username) 87 elif not self._git.local_config('github.token'): 88 self._git.set_local_config('github.token', self._token) 89 90 self._github = WPTGitHubClass(self._host, self._username, self._token) if self._username and self._token else None 91 92 self._branch_name = self._ensure_new_branch_name() 93 self._public_branch_name = options.public_branch_name if options.public_branch_name else self._branch_name 94 self._bugzilla_url = "https://bugs.webkit.org/show_bug.cgi?id=" + str(self._bug_id) 95 self._commit_message = options.message 96 if not self._commit_message: 97 self._commit_message = 'WebKit export of ' + self._bugzilla_url if self._bug_id else 'Export made from a WebKit repository' 98 99 self._wpt_fork_remote = options.repository_remote 100 if not self._wpt_fork_remote: 101 self._wpt_fork_remote = self._username 102 103 self._wpt_fork_push_url = options.repository_remote_url 104 if not self._wpt_fork_push_url: 105 self._wpt_fork_push_url = "https://" + self._username + "@github.com/" + self._username + "/web-platform-tests.git" 213 106 214 107 def _ensure_wpt_repository(self, url, wpt_repository_directory, gitClass): … … 274 167 def push_to_wpt_fork(self): 275 168 self.create_upload_remote_if_needed() 169 wpt_fork_branch_github_url = "https://github.com/" + self._username + "/web-platform-tests/tree/" + self._public_branch_name 276 170 _log.info('Pushing branch ' + self._branch_name + " to " + self._git.remote(["get-url", self._wpt_fork_remote]).rstrip()) 277 171 _log.info('This may take some time') 278 172 self._git.push([self._wpt_fork_remote, self._branch_name + ":" + self._public_branch_name, '-f']) 279 _log.info('Branch available at ' + self._wpt_fork_branch_github_url)173 _log.info('Branch available at ' + wpt_fork_branch_github_url) 280 174 return True 281 175 282 176 def make_pull_request(self): 283 177 if not self._github: 284 _log.info(' Skipping pull request because OAuth token was not provided. You can open the pull request manually using the branch ' + self._wpt_fork_branch_github_url)178 _log.info('Missing information to create a pull request') 285 179 return 286 180 … … 293 187 except Exception as e: 294 188 _log.warning(e) 295 _log.info('Could not add label "%s" to pr #%s. User "%s" may not have permission to update labels in the w3c/web-platform-test repo.' % (WEBKIT_EXPORT_PR_LABEL, pr_number, self. username))189 _log.info('Could not add label "%s" to pr #%s. User "%s" may not have permission to update labels in the w3c/web-platform-test repo.' % (WEBKIT_EXPORT_PR_LABEL, pr_number, self._username)) 296 190 if self._bug_id and pr_number: 297 191 self._bugzilla.post_comment_to_bug(self._bug_id, "Submitted web-platform-tests pull request: " + WPT_PR_URL + str(pr_number)) … … 310 204 311 205 def delete_local_branch(self): 312 _log.info('Removing localbranch ' + self._branch_name)206 _log.info('Removing branch ' + self._branch_name) 313 207 self._git.checkout('master') 314 208 self._git.delete_branch(self._branch_name) 209 210 def create_git_patch(self): 211 patch_file = './patch.temp.' + str(time.clock()) 212 git_commit = "HEAD...." if not self._options.git_commit else self._options.git_commit + "~1.." + self._options.git_commit 213 patch_data = self._host.scm().create_patch(git_commit, [WEBKIT_WPT_DIR]) 214 if not patch_data or not 'diff' in patch_data: 215 _log.info('No changes to upstream, patch data is: "%s"' % (patch_data)) 216 return '' 217 # FIXME: We can probably try to use --relative git parameter to not do that replacement. 218 patch_data = patch_data.replace(WEBKIT_WPT_DIR + '/', '') 219 patch_file = self._filesystem.abspath(patch_file) 220 self._filesystem.write_text_file(patch_file, patch_data) 221 return patch_file 315 222 316 223 def create_upload_remote_if_needed(self): … … 319 226 320 227 def do_export(self): 321 git_patch_file = self. write_git_patch_file()228 git_patch_file = self.create_git_patch() 322 229 323 230 if not git_patch_file: … … 384 291 parser.add_argument('-d', '--repository', dest='repository_directory', default=None, help='repository directory') 385 292 parser.add_argument('-c', '--create-pr', dest='create_pull_request', action='store_true', default=False, help='create pull request to w3c web-platform-tests') 386 parser.add_argument('--non-interactive', action='store_true', dest='non_interactive', default=False, help='Never prompt the user, fail as fast as possible.')387 293 388 294 options, args = parser.parse_known_args(args) … … 400 306 401 307 logger = logging.getLogger('webkitpy.w3c.test_exporter') 402 logger.propagate = False403 308 logger.setLevel(logging.INFO) 404 309 handler = LogHandler() … … 412 317 413 318 configure_logging() 414 test_exporter = WebPlatformTestExporter(Host(), options) 415 416 if not test_exporter.has_wpt_changes(): 417 _log.info('No changes to upstream. Exiting...') 418 return 319 320 test_exporter = TestExporter(Host(), options) 419 321 420 322 test_exporter.do_export() -
trunk/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
r231912 r231925 26 26 from webkitpy.common.system.filesystem_mock import MockFileSystem 27 27 from webkitpy.common.system.executive_mock import MockExecutive2 28 from webkitpy.w3c.test_exporter import WebPlatformTestExporter, parse_args28 from webkitpy.w3c.test_exporter import TestExporter, parse_args 29 29 from webkitpy.w3c.wpt_github_mock import MockWPTGitHub 30 30 … … 123 123 def test_export(self): 124 124 host = TestExporterTest.MyMockHost() 125 host.web.responses.append({'status_code': 200, 'body': '{"login": "USER"}'})126 125 options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN']) 127 exporter = WebPlatformTestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)126 exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter) 128 127 exporter.do_export() 129 128 self.assertEquals(exporter._github.calls, ['create_pr', 'add_label "webkit-export"']) … … 152 151 def test_export_with_specific_branch(self): 153 152 host = TestExporterTest.MyMockHost() 154 host.web.responses.append({'status_code': 200, 'body': '{"login": "USER"}'})155 153 options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN', '-bn', 'wpt-export-branch']) 156 exporter = WebPlatformTestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)154 exporter = TestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter) 157 155 exporter.do_export() 158 156 self.assertEquals(exporter._git.calls, [ … … 172 170 'checkout master', 173 171 'reset hard origin/master']) 174 175 def test_export_interactive_mode(self):176 host = TestExporterTest.MyMockHost()177 host.web.responses.append({'status_code': 200, 'body': '{"login": "USER"}'})178 options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN', '--interactive'])179 exporter = WebPlatformTestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)180 exporter.do_export()181 182 def test_export_invalid_token(self):183 host = TestExporterTest.MyMockHost()184 host.web.responses.append({'status_code': 401})185 options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN'])186 exporter = WebPlatformTestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)187 with self.assertRaises(Exception) as context:188 exporter.do_export()189 self.assertIn('OAuth token is not valid', str(context.exception))190 191 def test_export_wrong_token(self):192 host = TestExporterTest.MyMockHost()193 host.web.responses.append({'status_code': 200, 'body': '{"login": "DIFF_USER"}'})194 options = parse_args(['test_exporter.py', '-g', 'HEAD', '-b', '1234', '-c', '-n', 'USER', '-t', 'TOKEN'])195 exporter = WebPlatformTestExporter(host, options, TestExporterTest.MockGit, TestExporterTest.MockBugzilla, MockWPTGitHub, TestExporterTest.MockWPTLinter)196 with self.assertRaises(Exception) as context:197 exporter.do_export()198 self.assertIn('OAuth token does not match the provided username', str(context.exception))
Note: See TracChangeset
for help on using the changeset viewer.