-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
Automate v8 source upgrade #181
Merged
dylanahsmith
merged 13 commits into
rogchap:master
from
GustavoCaso:automate-v8-build-for-macosx-and-linux
Oct 22, 2021
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9cdead1
Create v8 upgrade workflow
GustavoCaso c84d90c
Work related to https://github.com/rogchap/v8go/issues/165
GustavoCaso 63d18ad
Remove custom worflow for building macos and linux builds and use Git…
GustavoCaso 945bd17
Use custom pythin script to update the deps/include folder during the…
GustavoCaso 355c618
Change workflow to run everyday and check the current v8 version with…
GustavoCaso 7db1d65
move all the logic to the upgrade.py script
GustavoCaso a3dc326
set python version in the GH action
GustavoCaso 1a48c8f
Merge branch 'master' into automate-v8-build-for-macosx-and-linux
GustavoCaso 496ee27
do not modify cgo.go file
GustavoCaso 5da1857
Merge branch 'master' into automate-v8-build-for-macosx-and-linux
5e0efdb
Trigger upgrade and build workflow using dispatch
GustavoCaso b48997f
Update README
GustavoCaso 256a7c7
Apply feedback on README and script function names
GustavoCaso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: V8 Upgrade | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 0 * * *' # Run every day | ||
|
||
jobs: | ||
upgrade: | ||
name: Upgrade V8 | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
- name: Update depot_tools fetch config | ||
run: cd deps/depot_tools && git config --unset-all remote.origin.fetch; git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* | ||
shell: bash | ||
- name: Add depot_tools to PATH | ||
run: echo "$PWD/deps/depot_tools" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Run upgrade script | ||
run: cd deps && python upgrade_v8.py | ||
- name: Create PR metadata | ||
id: pr_metadata | ||
run: | | ||
echo ::set-output name=pr_branch::"v8_$(cat deps/v8_version)_upgrade" | ||
- name: Create PR | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: Upgrade V8 binaries | ||
branch: ${{steps.pr_metadata.outputs.pr_branch}} | ||
delete-branch: true | ||
title: Upgrade V8 binary | ||
body: Auto-generated pull request to upgarde V8 binary | ||
|
||
|
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,110 @@ | ||
#!/usr/bin/env python | ||
|
||
import urllib.request | ||
import sys | ||
import json | ||
import subprocess | ||
import os | ||
import fnmatch | ||
import pathlib | ||
import shutil | ||
|
||
vendor_file_template = """// Generated by deps/upgrade_v8.py, DO NOT REMOVE/EDIT MANUALLY. | ||
// Package %s is required to provide support for vendoring modules | ||
package %s | ||
""" | ||
|
||
include_vendor_file_template = """// Generated by deps/upgrade_v8.py, DO NOT REMOVE/EDIT MANUALLY. | ||
// Package include is required to provide support for vendoring modules | ||
package include | ||
|
||
import ( | ||
%s | ||
) | ||
""" | ||
|
||
CHROME_VERSIONS_URL = "https://omahaproxy.appspot.com/all.json?os=linux&channel=stable" | ||
V8_VERSION_FILE = "v8_version" | ||
|
||
deps_path = os.path.dirname(os.path.realpath(__file__)) | ||
v8go_path = os.path.abspath(os.path.join(deps_path, os.pardir)) | ||
env = os.environ.copy() | ||
v8_path = os.path.join(deps_path, "v8") | ||
v8_include_path = os.path.join(v8_path, "include") | ||
deps_include_path = os.path.join(deps_path, "include") | ||
|
||
def get_directories_names(path): | ||
flist = [] | ||
for p in pathlib.Path(path).iterdir(): | ||
if p.is_dir(): | ||
flist.append(p.name) | ||
return sorted(flist) | ||
|
||
def package_name(package, index, total): | ||
name = f'_ "rogchap.com/v8go/deps/include/{package}"' | ||
if (index + 1 == total): | ||
return name | ||
else: | ||
return name + '\n' | ||
|
||
def create_include_vendor_file(src_path, directories): | ||
package_names = [] | ||
total_directories = len(directories) | ||
|
||
for index, directory_name in enumerate(directories): | ||
package_names.append(package_name(directory_name, index, total_directories)) | ||
|
||
with open(os.path.join(src_path, 'vendor.go'), 'w') as temp_file: | ||
temp_file.write(include_vendor_file_template % (' '.join(package_names))) | ||
|
||
def create_vendor_files(src_path): | ||
directories = get_directories_names(src_path) | ||
|
||
create_include_vendor_file(src_path, directories) | ||
|
||
for directory in directories: | ||
directory_path = os.path.join(src_path, directory) | ||
|
||
vendor_go_file_path = os.path.join(directory_path, 'vendor.go') | ||
|
||
if os.path.isfile(vendor_go_file_path): | ||
continue | ||
|
||
with open(os.path.join(directory_path, 'vendor.go'), 'w') as temp_file: | ||
temp_file.write(vendor_file_template % (directory, directory)) | ||
|
||
def update_v8_version_file(src_path, version): | ||
with open(os.path.join(src_path, V8_VERSION_FILE), "w") as v8_file: | ||
v8_file.write(version) | ||
|
||
def read_v8_version_file(src_path): | ||
v8_version_file = open(os.path.join(src_path, V8_VERSION_FILE), "r") | ||
return v8_version_file.read().strip() | ||
|
||
def get_latest_v8_info(): | ||
with urllib.request.urlopen(CHROME_VERSIONS_URL) as response: | ||
json_response = response.read() | ||
|
||
return json.loads(json_response) | ||
|
||
# Current version | ||
current_v8_version_installed = read_v8_version_file(deps_path) | ||
|
||
# Get latest version | ||
latest_v8_info = get_latest_v8_info() | ||
|
||
latest_stable_v8_version = latest_v8_info[0]["versions"][0]["v8_version"] | ||
|
||
if current_v8_version_installed != latest_stable_v8_version: | ||
subprocess.check_call(["git", "fetch", "origin", latest_stable_v8_version], | ||
cwd=v8_path, | ||
env=env) | ||
# checkout latest stable commit | ||
subprocess.check_call(["git", "checkout", latest_stable_v8_version], | ||
cwd=v8_path, | ||
env=env) | ||
|
||
shutil.rmtree(deps_include_path) | ||
shutil.copytree(v8_include_path, deps_include_path, dirs_exist_ok=True) | ||
create_vendor_files(deps_include_path) | ||
update_v8_version_file(deps_path, latest_stable_v8_version) |
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 @@ | ||
9.0.257.18 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stable releases are on average every 4 weeks. Running every day seems excessive, but I guess most of the time it will just be a version check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Source: https://v8.dev/docs/release-process#stable-releases)
Emphasis on "major" was mine, they more frequently release patch version bumps.
Currently, https://omahaproxy.appspot.com shows the most recent version bump was only about a week apart:
If we tracked the branch head for the stable channel (currently branch-heads/9.4) then that would make the changes even more frequent. Releasing fixes that frequently might be overkill, but automating the preparation work for getting a security fix out would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can start with every day and if it gets noisy (which it shouldn't if it's largely version checks and silent exiting if releases are more like once a week), we can reduce the frequency.