豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 1289b42

Browse files
Liviu RauDevtools-frontend LUCI CQ
authored andcommitted
Add CfT reference mode for rolling cft+protocol
In CfT mode: - first update the CfT version - checkout Chromium at the position for which we have the new CfT - update files from that position Bug: 462625994 Change-Id: I0f1b8576a0264992c88763ce87e9d7c6a95d3286 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7511843 Commit-Queue: Liviu Rau <liviurau@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
1 parent 4208825 commit 1289b42

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

scripts/deps/roll_deps.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import subprocess
1515
import sys
16-
import shutil
16+
import urllib.request
1717

1818

1919
def node_path(options):
@@ -56,6 +56,7 @@ def node_path(options):
5656
class ReferenceMode(enum.Enum):
5757
Tot = 'tot'
5858
WorkingTree = 'working-tree'
59+
CfT = 'CfT'
5960

6061
def __str__(self):
6162
return self.value
@@ -94,6 +95,26 @@ def update(options):
9495
subprocess.check_call(['gclient', 'sync'], cwd=options.chromium_dir)
9596

9697

98+
def checkout_chromium_commit_position(options, target_position):
99+
target_position = int(target_position)
100+
101+
grep_pattern = f'Cr-Commit-Position: .*@{{#{target_position}}}'
102+
cmd = [
103+
'git', 'log', 'origin/main', f'--grep={grep_pattern}', '-1',
104+
'--format=%H'
105+
]
106+
commit_hash = subprocess.check_output(cmd,
107+
cwd=options.chromium_dir,
108+
text=True).strip()
109+
110+
if not commit_hash:
111+
raise RuntimeError(
112+
f'Could not find commit for position {target_position}')
113+
114+
subprocess.check_call(['git', 'checkout', commit_hash],
115+
cwd=options.chromium_dir)
116+
117+
97118
def sync_node(options):
98119
"""Node is managed as a standard GCS deps so we run gclient sync but without hooks"""
99120
subprocess.check_call(['gclient', 'sync', '--nohooks'],
@@ -222,6 +243,45 @@ def update_deps_revision(options):
222243
}, f)
223244

224245

246+
def get_json(url):
247+
with urllib.request.urlopen(url) as response:
248+
return json.loads(response.read().decode('utf-8'))
249+
250+
251+
def version_tuple(version):
252+
return tuple(map(int, version.split('.')))
253+
254+
255+
def updateCfT(options):
256+
"""
257+
Update the Chrome for testing dependency.
258+
"""
259+
print('Updating Chrome for Testing...')
260+
json_data = get_json(
261+
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json"
262+
)
263+
canary_channel = json_data['channels']['Canary']
264+
new_version = canary_channel['version']
265+
commit_position = canary_channel['revision']
266+
267+
current_version = subprocess.check_output(
268+
['gclient', 'getdep', '--var=chrome'],
269+
cwd=options.devtools_dir,
270+
text=True).strip()
271+
272+
if current_version and (version_tuple(current_version)
273+
< version_tuple(new_version)):
274+
print(
275+
f'Updating Chrome for Testing: {current_version} -> {new_version}')
276+
subprocess.check_call(
277+
['gclient', 'setdep', f'--var=chrome={new_version}'],
278+
cwd=options.devtools_dir)
279+
else:
280+
print(f'Chrome for Testing is up to date: {current_version}')
281+
282+
return commit_position
283+
284+
225285
def update_readme_revision(options):
226286
print('updating README.chromium revision')
227287
readme_path = os.path.join(options.devtools_dir, 'front_end',
@@ -254,6 +314,9 @@ def update_readme_revision(options):
254314
OPTIONS = parse_options(sys.argv[1:])
255315
if OPTIONS.ref == ReferenceMode.Tot:
256316
update(OPTIONS)
317+
if OPTIONS.ref == ReferenceMode.CfT:
318+
commit_position = updateCfT(OPTIONS)
319+
checkout_chromium_commit_position(OPTIONS, commit_position)
257320
elif OPTIONS.update_node:
258321
sync_node(OPTIONS)
259322
copy_files(OPTIONS)

0 commit comments

Comments
 (0)