-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73220c7
commit 3afc523
Showing
5 changed files
with
153 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: update_chromium_revision | ||
on: | ||
# Trigger everyday at 10 UTC. | ||
schedule: | ||
- cron: 0 10 * * * | ||
workflow_dispatch: | ||
jobs: | ||
update: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: setup python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.10' | ||
cache: 'pip' | ||
- run: pip install requests | ||
- name: execute update_chromium_revision.py | ||
run: python -m tools.wpt.update_chromium_revision | ||
- name: Create pull request | ||
# Use a conditional step instead of a conditional job to work around #20700. | ||
if: github.repository == 'web-platform-tests/wpt' | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
author: wpt-pr-bot <[email protected]> | ||
title: "Update latest available Chromium revisions" | ||
commit-message: "Latest Chromium revision for Linux/Mac/Win" | ||
body: | | ||
This automated pull request updates `tools/wpt/latest_chromium_revisions.json` with the current latest available Chromium revisions for major platforms. | ||
If additional changes are needed, please manually create another PR based on this one. | ||
See the [workflow](https://github.com/web-platform-tests/wpt/blob/master/.github/workflows/update_chromium_revision.yml) for how this pull request was created. | ||
branch: actions/update-chromium-revision |
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 @@ | ||
996554 |
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,88 @@ | ||
import requests | ||
from time import time | ||
|
||
from .utils import get | ||
|
||
|
||
PLATFORM_INFO = [ | ||
("Win_x64", "chrome-win.zip"), | ||
("Win", "chrome-win.zip"), | ||
("Linux_x64", "chrome-linux.zip"), | ||
("Mac", "chrome-mac.zip") | ||
] | ||
SNAPSHOTS_PATH = "https://storage.googleapis.com/chromium-browser-snapshots/" | ||
|
||
|
||
def main(timeout=600.0): | ||
start = time() | ||
|
||
# Load existing pinned revision. | ||
existing_revision = None | ||
with open("tools/wpt/latest_chromium_revision.txt", "r") as f: | ||
existing_revision = int(f.read()) | ||
|
||
# Find the lowest new revision number among latest revisions by platform. | ||
# We need to find a revision number that is available for download for all platforms, | ||
# so we start looking from the smallest of these latest revisions. | ||
smallest_revision = existing_revision | ||
for platform, filename in PLATFORM_INFO: | ||
try: | ||
url = f"{SNAPSHOTS_PATH}{platform}/LAST_CHANGE" | ||
revision = get(url).text.strip() | ||
smallest_revision = max(smallest_revision, int(revision)) | ||
except requests.RequestException as e: | ||
print(f"failed LAST_CHANGE lookup for {platform}: {e}") | ||
continue | ||
|
||
if smallest_revision == existing_revision: | ||
return | ||
|
||
# Step backwards through revision numbers until we find one | ||
# that is available for all platforms. | ||
largest_mutually_available_revision = smallest_revision | ||
available_for_all = False | ||
timed_out = False | ||
while not available_for_all and not timed_out: | ||
available_for_all = True | ||
# For each platform, check if Chromium is available for download from snapshots. | ||
for platform, filename in PLATFORM_INFO: | ||
try: | ||
url = (f"{SNAPSHOTS_PATH}{platform}/" | ||
f"{largest_mutually_available_revision}/{filename}") | ||
# Check the headers of each possible download URL. | ||
r = requests.head(url) | ||
# If the "Accept-Ranges" header is not present, we know the file is not | ||
# available for download. Decrement the revision number and try again. | ||
if "Accept-Ranges" not in r.headers: | ||
largest_mutually_available_revision -= 1 | ||
available_for_all = False | ||
break | ||
except requests.RequestException as e: | ||
print(e) | ||
largest_mutually_available_revision -= 1 | ||
available_for_all = False | ||
break | ||
if time() - start > timeout: | ||
timed_out = True | ||
|
||
if timed_out: | ||
raise TimeoutError(f"Reached timeout {timeout}s while checking revision " | ||
f"{largest_mutually_available_revision}") | ||
|
||
end = time() | ||
if largest_mutually_available_revision == existing_revision: | ||
print(f"No new mutually available revision numbers found after " | ||
f"{'{:.2f}'.format(end - start)} seconds.") | ||
return | ||
|
||
print(f"Found mutually available revision at {largest_mutually_available_revision}.") | ||
print(f"This process started at {smallest_revision} and checked " | ||
f"{smallest_revision - largest_mutually_available_revision} revisions.") | ||
print(f"The whole process took {'{:.2f}'.format(end - start)} seconds.") | ||
|
||
with open("tools/wpt/latest_chromium_revision.txt", "w") as f: | ||
f.write(f"{largest_mutually_available_revision}\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() # type: ignore |