Skip to content

Commit

Permalink
[build] improve automated update task
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jan 23, 2024
1 parent 8957fb5 commit 5614026
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ namespace :java do
file = 'java/version.bzl'
text = File.read(file).gsub(old_version, new_version)
File.open(file, "w") { |f| f.puts text }
Rake::Task['java:changelog'].invoke unless old_version.include?('SNAPSHOT')
Rake::Task['java:changelog'].invoke if old_version.include?('SNAPSHOT')
end
end

Expand Down Expand Up @@ -1043,7 +1043,7 @@ namespace :all do
Bazel.execute('run', args, '//scripts:update_cdp')
Bazel.execute('run', args, '//scripts:pinned_browsers')
Bazel.execute('run', args, '//scripts:selenium_manager')
Rake::Task['java:dependencies'].invoke
Rake::Task['java:update'].invoke
Rake::Task['authors'].invoke
Rake::Task['copyright:update'].invoke
end
Expand Down
26 changes: 13 additions & 13 deletions scripts/update_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,20 @@ def create_new_chrome_files(src_base, chrome_milestone):
target_dir = root_dir / f"{src_base}/v{new_chrome(chrome_milestone)}"
old_dir = root_dir / f"{src_base}/v{old_chrome(chrome_milestone)}"

# New target must not be already present
if not target_dir.is_dir():
if old_dir.is_dir():
shutil.rmtree(old_dir)
if old_dir.is_dir():
shutil.rmtree(old_dir)

if source_dir.is_dir() and any(source_dir.iterdir()):
os.makedirs(target_dir, exist_ok=True)
for item in source_dir.iterdir():
shutil.copy(item, target_dir)
if source_dir.is_dir() and any(source_dir.iterdir()):
os.makedirs(target_dir, exist_ok=True)
for item in source_dir.iterdir():
shutil.copy(item, target_dir)

for file in target_dir.iterdir():
replace_in_file(file, previous_chrome(chrome_milestone), new_chrome(chrome_milestone))
new_filename = file.name.replace(previous_chrome(chrome_milestone), new_chrome(chrome_milestone))
file.rename(target_dir / new_filename)
for file in target_dir.iterdir():
replace_in_file(file, previous_chrome(chrome_milestone), new_chrome(chrome_milestone))
new_filename = file.name.replace(previous_chrome(chrome_milestone), new_chrome(chrome_milestone))
file.rename(target_dir / new_filename)

subprocess.run(["git", "add", str(target_dir / "*")], cwd=root_dir)
subprocess.run(["git", "add", str(target_dir / "*")], cwd=root_dir)


def replace_in_file(file_path, old_string, new_string, is_regex=False):
Expand Down Expand Up @@ -187,3 +185,5 @@ def update_js(chrome_milestone):
update_ruby(chrome_milestone)
update_python(chrome_milestone)
update_js(chrome_milestone)

print(f"adding CDP {new_chrome(chrome_milestone)} and removing {old_chrome(chrome_milestone)}")

0 comments on commit 5614026

Please sign in to comment.