1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#!/usr/bin/env python3
# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Pulls the latest revisions of the wpt tooling."""
import os
import shutil
import subprocess
import sys
import time
BUG_QUERY_URLS = ["https://bugs.chromium.org/p/chromium/issues/list?"
"q=component%3ABlink%3EInfra%3EEcosystem%20%22WPT%20Tooling%20Roll%22&can=2",
"https://bugs.chromium.org/p/chromium/issues/list?"
"q=component%3ABlink%3EInfra%3EEcosystem%20%22WPT%20JS%20Roll%22&can=2"]
def main():
current_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
current_branch = current_branch.rstrip().decode('utf-8')
print("Roll wpt on branch: %s" % current_branch)
print("Are there outstanding bugs at %s (Y/n)?" % BUG_QUERY_URLS[0],
end='', flush=True)
yesno = sys.stdin.readline().strip()
if yesno not in ['N', 'n']:
return 1
remote_head = subprocess.check_output(['git',
'ls-remote',
'https://github.com/web-platform-tests/wpt',
'refs/heads/master'])
remote_head = remote_head.rstrip().decode('utf-8').split()
remote_head = remote_head[0]
print("Roll to remote head: %s" % remote_head)
pattern = "s/^Version: .*$/Version: %s/g" % remote_head
path_to_wpt_tools_dir = os.path.abspath(os.path.dirname(__file__))
path_to_readme = os.path.join(path_to_wpt_tools_dir, "README.chromium")
# Update Version in //third_party/wpt_tools/README.chromium
# This program only works on linux for now, as sed has slightly
# different format on mac
print("Update commit hash code for %s" % path_to_readme)
subprocess.check_call(["sed", "-i", pattern, path_to_readme])
path_to_checkout = os.path.join(path_to_wpt_tools_dir, "checkout.sh")
print("Call %s\n" % path_to_checkout)
subprocess.check_output([path_to_checkout, remote_head])
change_files = subprocess.check_output(['git',
'diff',
'HEAD',
'--no-renames',
'--name-only'])
change_files = change_files.decode('utf-8').strip()
if change_files == '':
print("No tooling changes to roll!")
return 0
subprocess.check_call(['git', 'add', path_to_wpt_tools_dir])
wpt_try_bots = ["linux-wpt-identity-fyi-rel",
"linux-wpt-input-fyi-rel",
"linux-blink-rel"]
upstream_url = "https://github.com/web-platform-tests/wpt"
message = "Roll wpt tooling\n\nThis rolls wpt to latest commit at\n%s.\n" % upstream_url
message += "REMOTE-WPT-HEAD: %s\n\n" % remote_head
message += "Cq-Include-Trybots: luci.chromium.try:%s\n" % ','.join(wpt_try_bots)
subprocess.check_call(['git', 'commit', '-m', message])
subprocess.check_call(['git',
'cl',
'upload',
'--enable-auto-submit',
'--cq-dry-run',
'--bypass-hooks',
'-f'])
output = subprocess.check_output(['git', 'cl', 'issue']).decode('utf-8')
issue_number = output.strip().split()[2]
print("\nCL uploaded to https://chromium-review.googlesource.com/%s" % issue_number)
print("Please monitor the results on WPT try bots.")
print("One common failure is that some dependency is not satisfied.")
print("Please consider update WPTIncludeList in such case.")
print("\n\nNow roll wpt javascript")
print("Are there outstanding bugs at %s (Y/n)?" % BUG_QUERY_URLS[1],
end='', flush=True)
yesno = sys.stdin.readline().strip()
if yesno not in ['N', 'n']:
return 1
javascript_branch = "%s-%d" % (current_branch, int(time.time()))
print("Roll wpt javascript on branch: %s" % javascript_branch)
subprocess.check_call(['git', 'new-branch', javascript_branch])
files_to_roll = ["testharness.js", "testdriver.js", "testdriver-actions.js", "check-layout-th.js"]
chromium_src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
source_dir = os.path.join(chromium_src_dir,
"third_party",
"blink",
"web_tests",
"external",
"wpt",
"resources")
dst_dir = os.path.join(chromium_src_dir,
"third_party",
"blink",
"web_tests",
"resources")
for f in files_to_roll:
shutil.copy(os.path.join(source_dir, f),
os.path.join(dst_dir, f))
change_files = subprocess.check_output(['git',
'diff',
'HEAD',
'--no-renames',
'--name-only'])
change_files = change_files.decode('utf-8').strip()
if change_files == '':
print("No javascript changes to roll!")
else:
for f in files_to_roll:
subprocess.check_call(['git', 'add', os.path.join(dst_dir, f)])
message = ("Roll wpt javascript\n\nThis rolls wpt javascript to latest commit at\n"
"%s.\n" % upstream_url)
subprocess.check_call(['git', 'commit', '-m', message])
subprocess.check_call(['git',
'cl',
'upload',
'--enable-auto-submit',
'--cq-dry-run',
'--bypass-hooks',
'-f'])
output = subprocess.check_output(['git', 'cl', 'issue']).decode('utf-8')
issue_number = output.strip().split()[2]
print("\nCL uploaded to https://chromium-review.googlesource.com/%s" % issue_number)
print("Deleting branch %s.\nCurrent branch is %s." % (javascript_branch, current_branch))
subprocess.check_call(['git', 'checkout', current_branch])
subprocess.check_call(['git', 'branch', '-D', javascript_branch])
return 0
if __name__ == '__main__':
sys.exit(main())
|