File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11load ("@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" )
33load ("//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-
155py_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)
Original file line number Diff line number Diff line change 77from pathlib import Path
88
99import urllib3
10- from chrome_version import latest_for_channel
1110from 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+
3146def chromedriver (selected_version , workspace_prefix = "" ):
3247 content = ""
3348
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
33import argparse
4+ import json
45import os
56import re
67import shutil
78from pathlib import Path
89
910import urllib3
10- from chrome_version import latest_for_channel
11+ from packaging . version import parse
1112
1213http = urllib3 .PoolManager ()
1314root_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+
1633def fetch_and_save (url , file_path ):
1734 response = http .request ("GET" , url )
1835 if response .status != 200 :
You can’t perform that action at this time.
0 commit comments