-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browser tests should use the latest Chrome stable release (#8783)
* Browser tests should use the latest Chrome stable release * Add dependencies for chrome binary and added to path * Don't try to add chrome to path * Added script to find chrome dependencies * Correct var name and added missing && * Hard code location of chrome binary * Remove unused import * Removed -j from unzipping of chrome binary * Giving credit to parts of the solution
- Loading branch information
Showing
3 changed files
with
89 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
This solution is largely based on the Playwright's browser dependencies script at | ||
https://github.com/microsoft/playwright/blob/main/utils/linux-browser-dependencies/inside_docker/list_dependencies.js | ||
""" | ||
|
||
import subprocess | ||
|
||
|
||
def find_packages(library_name): | ||
stdout = run_command(["apt-file", "search", library_name]) | ||
if not stdout.strip(): | ||
return [] | ||
libs = [line.split(":")[0] for line in stdout.strip().split("\n")] | ||
return list(set(libs)) | ||
|
||
|
||
def run_command(cmd, cwd=None, env=None): | ||
result = subprocess.run(cmd, cwd=cwd, env=env, capture_output=True, text=True) | ||
return result.stdout | ||
|
||
|
||
def ldd(file_path): | ||
stdout = run_command(["ldd", file_path]) | ||
# For simplicity, I'm assuming if we get an error, the code is non-zero. | ||
try: | ||
result = subprocess.run( | ||
["ldd", file_path], capture_output=True, text=True | ||
) | ||
stdout = result.stdout | ||
code = result.returncode | ||
except subprocess.CalledProcessError: | ||
stdout = "" | ||
code = 1 | ||
return stdout, code | ||
|
||
|
||
raw_deps = ldd("/opt/chrome/chrome") | ||
dependencies = raw_deps[0].splitlines() | ||
|
||
missing_deps = { | ||
r[0].strip() | ||
for d in dependencies | ||
for r in [d.split("=>")] | ||
if len(r) == 2 and r[1].strip() == "not found" | ||
} | ||
|
||
missing_packages = [] | ||
for d in missing_deps: | ||
all_packages = find_packages(d) | ||
packages = [ | ||
p | ||
for p in all_packages | ||
if not any( | ||
p.endswith(suffix) for suffix in ["-dbg", "-test", "tests", "-dev", "-mesa"] | ||
) | ||
] | ||
for p in packages: | ||
missing_packages.append(p) | ||
|
||
print(" ".join(missing_packages)) |