Skip to content

Commit 8b85e9a

Browse files
titusfortnerdiemol
andauthored
[build] Resolve Chrome milestone from Chrome-for-Testing channel version (#17747)
* [build] Resolve Chrome milestone from Chrome-for-Testing channel version * [build] Release download connection and restrict --chrome_channel to valid channels * [build] Revert --chrome_channel choices constraint * [build] Remove release_conn, chromedriver guard, and metadata status checks * [build] Rename version-entry variable and wrap long request lines for ruff * [build] Revert chrome_release rename, keep line wrapping * [build] Reduce to minimal resolver swap and silent-fetch guards --------- Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
1 parent 9f6ccde commit 8b85e9a

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

scripts/pinned_browsers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def calculate_hash(url):
2020
print(f"Calculate hash for {url}", file=sys.stderr)
2121
h = hashlib.sha256()
2222
r = http.request("GET", url, preload_content=False)
23+
if r.status != 200:
24+
raise ValueError(f"Download unavailable (HTTP {r.status}): {url}")
2325
for b in iter(lambda: r.read(4096), b""):
2426
h.update(b)
2527
return h.hexdigest()
@@ -28,14 +30,9 @@ def calculate_hash(url):
2830
def get_chrome_info_for_channel(channel):
2931
r = http.request(
3032
"GET",
31-
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
33+
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
3234
)
33-
all_versions = json.loads(r.data)
34-
# use the same milestone for all chrome releases, so pick the lowest
35-
milestones = [version["milestone"] for version in all_versions if version["milestone"]]
36-
if not milestones:
37-
raise ValueError(f"No Chrome versions with milestones found for channel '{channel}'")
38-
milestone = min(milestones)
35+
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
3936
r = http.request(
4037
"GET",
4138
"https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json",

scripts/update_cdp.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ def get_chrome_milestone():
2727

2828
r = http.request(
2929
"GET",
30-
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
30+
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
3131
)
32-
all_versions = json.loads(r.data)
33-
# use the same milestone for all Chrome releases, so pick the lowest
34-
milestones = [version["milestone"] for version in all_versions if version["milestone"]]
35-
if not milestones:
36-
raise ValueError(f"No Chrome versions with milestones found for channel '{channel}'")
37-
milestone = min(milestones)
32+
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
3833
r = http.request(
3934
"GET",
4035
"https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json",
@@ -49,6 +44,8 @@ def get_chrome_milestone():
4944

5045
def fetch_and_save(url, file_path):
5146
response = http.request("GET", url)
47+
if response.status != 200:
48+
raise ValueError(f"Fetch failed (HTTP {response.status}): {url}")
5249
with open(file_path, "wb") as file:
5350
file.write(response.data)
5451

@@ -79,6 +76,8 @@ def flatten_browser_pdl(file_path, chrome_version):
7976
for domain_file in includes:
8077
url = base_url + domain_file
8178
response = http.request("GET", url)
79+
if response.status != 200:
80+
raise ValueError(f"Fetch failed (HTTP {response.status}): {url}")
8281
concatenated += response.data.decode("utf-8") + "\n"
8382
# Overwrite the file with version block + concatenated domains
8483
with open(file_path, "w") as file:

0 commit comments

Comments
 (0)