Skip to content

Commit 0cbabf1

Browse files
committed
[build] Use inlined resolver and drop shared module wiring
1 parent 169a962 commit 0cbabf1

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

scripts/BUILD.bazel

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
load("@py_dev_requirements//:requirements.bzl", "requirement")
2-
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
2+
load("@rules_python//python:defs.bzl", "py_binary")
33
load("//java:defs.bzl", "artifact", "java_binary")
44

5-
py_library(
6-
name = "chrome_version",
7-
srcs = ["chrome_version.py"],
8-
imports = ["."],
9-
deps = [
10-
requirement("packaging"),
11-
requirement("urllib3"),
12-
],
13-
)
14-
155
py_binary(
166
name = "pinned_browsers",
177
srcs = ["pinned_browsers.py"],
188
deps = [
19-
":chrome_version",
209
requirement("packaging"),
2110
requirement("urllib3"),
2211
],
@@ -34,7 +23,7 @@ py_binary(
3423
name = "update_cdp",
3524
srcs = ["update_cdp.py"],
3625
deps = [
37-
":chrome_version",
26+
requirement("packaging"),
3827
requirement("urllib3"),
3928
],
4029
)

scripts/pinned_browsers.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pathlib import Path
88

99
import urllib3
10-
from chrome_version import latest_for_channel
1110
from packaging.version import parse
1211

1312
# Find the current stable versions of each browser we
@@ -28,6 +27,22 @@ def calculate_hash(url):
2827
return h.hexdigest()
2928

3029

30+
def latest_for_channel(channel):
31+
"""Newest Chrome-for-Testing version entry (version + downloads) for a channel.
32+
33+
Uses Chrome-for-Testing's channel designation, which tracks the latest milestone and is
34+
unaffected by N-1 security respins.
35+
"""
36+
r = http.request("GET", "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
37+
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
38+
r = http.request("GET", "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
39+
versions = json.loads(r.data)["versions"]
40+
return sorted(
41+
filter(lambda v: v["version"].split(".")[0] == str(milestone), versions),
42+
key=lambda v: parse(v["version"]),
43+
)[-1]
44+
45+
3146
def chromedriver(selected_version, workspace_prefix=""):
3247
content = ""
3348

scripts/update_cdp.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
#!/usr/bin/env python
22

33
import argparse
4+
import json
45
import os
56
import re
67
import shutil
78
from pathlib import Path
89

910
import urllib3
10-
from chrome_version import latest_for_channel
11+
from packaging.version import parse
1112

1213
http = urllib3.PoolManager()
1314
root_dir = Path(os.path.realpath(__file__)).parent.parent
1415

1516

17+
def latest_for_channel(channel):
18+
"""Newest Chrome-for-Testing version entry for a channel.
19+
20+
Uses Chrome-for-Testing's channel designation, which tracks the latest milestone and is
21+
unaffected by N-1 security respins.
22+
"""
23+
r = http.request("GET", "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
24+
milestone = json.loads(r.data)["channels"][channel]["version"].split(".")[0]
25+
r = http.request("GET", "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
26+
versions = json.loads(r.data)["versions"]
27+
return sorted(
28+
filter(lambda v: v["version"].split(".")[0] == str(milestone), versions),
29+
key=lambda v: parse(v["version"]),
30+
)[-1]
31+
32+
1633
def fetch_and_save(url, file_path):
1734
response = http.request("GET", url)
1835
if response.status != 200:

0 commit comments

Comments
 (0)