Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new download to gha #169

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/download_chrome.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Exit on error

$ErrorActionPreference = "Stop"

# Get the platform (like 'win', 'mac', 'linux')
$platform = $args[0]

# Fetch the known good versions with download URLs
$response = Invoke-RestMethod -Uri "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"

# Filter for the appropriate download URL based on the platform
$downloadUrl = $response.versions[-1].downloads.chrome | Where-Object { $_.platform -eq $platform } | Select-Object -ExpandProperty url

# Download the zip file
Invoke-WebRequest -Uri $downloadUrl -OutFile "chrome.zip"

# Unzip the downloaded file
Expand-Archive -Path "chrome.zip" -DestinationPath "."

# Set the browser path
$browserPath = (Get-ChildItem -Directory | Where-Object { $_.Name -like "chrome-*" }).FullName + "\chrome"

# Export the browser path as an environment variable (for the current session)
$env:BROWSER_PATH = $browserPath
[Environment]::SetEnvironmentVariable("BROWSER_PATH", $browserPath, "Machine")

Write-Host "BROWSER_PATH set to $env:BROWSER_PATH"
6 changes: 6 additions & 0 deletions .github/workflows/download_chrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e
wget $(curl -s https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json |
jq -r ".versions | .[-1] | .downloads.chrome | .[] | select(.platform == \"${1}\").url")
unzip chrome*
export BROWSER_PATH="$(realpath "chrome-${1}")/chrome"
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v1 # Would be nice to bump this? Regressions.
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install chromium-browser xvfb
- name: Install Dependencies- Other
run: sudo apt-get update && sudo apt-get install xvfb curl wget jq unzip
timeout-minutes: 4 # because sometimes it dies
#- uses: ./.github/actions/ # it would be nice but it doesn't support timeout-minutes
- name: Install Dependencies- Chrome
run: chmod +x ./.github/workflows/download_chrome.sh && ./.github/workflows/download_chrome.sh "linux64"
- name: Install choreographer
run: pip install .[dev]
- name: DTDoctor
Expand All @@ -37,10 +39,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install Dependencies
run: choco install googlechrome -y --ignore-checksums
timeout-minutes: 4 # because sometimes it dies
#- uses: ./.github/actions/
#- uses: ./.github/actions/ # it would be nice but it doesn't support timeout-minutes
- name: Install Dependencies- Chrome
run: .\.github\workflows\download_chrome.ps1 "win64"
- name: Set Env
run: echo "BROWSER_PATH=$(Resolve-Path .\chrome-win64\chrome.exe)" >> $env:GITHUB_ENV
- name: Install choreographer
run: pip install .[dev]
- name: DTDoctor
Expand Down
5 changes: 4 additions & 1 deletion choreographer/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ def diagnose():
print(platform.version())
print(platform.uname())
print("Looking for browser:".center(50, "*"))
print(which_browser(debug=True))
print(f"which: {which_browser(debug=True)}")
print(f"os.environ: {os.environ.get('BROWSER_PATH')}")
try:
print("Looking for version info:".center(50, "*"))
print(subprocess.check_output([sys.executable, '-m', 'pip', 'freeze']))
Expand All @@ -818,6 +819,7 @@ def diagnose():
try:
print("Sync test headless".center(50, "*"))
browser = Browser(debug=True, debug_browser=True, headless=True)
print(browser.path)
time.sleep(3)
browser.close()
except BaseException as e:
Expand All @@ -826,6 +828,7 @@ def diagnose():
print("Done with sync test headless".center(50, "*"))
async def test_headless():
browser = await Browser(debug=True, debug_browser=True, headless=True)
print(browser.path)
await asyncio.sleep(3)
await browser.close()
try:
Expand Down
2 changes: 1 addition & 1 deletion choreographer/chrome_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def open_browser(to_chromium, from_chromium, stderr=sys.stderr, env=None, loop=N
cli.append("--no-sandbox")

if "HEADLESS" in env:
cli.append("--headless=old") # temporary fix
cli.append("--headless=new")

system_dependent = {}
if system == "Windows":
Expand Down
Loading