Skip to content

Commit 4cae611

Browse files
authored
Maintainer: Weekly Update Script (#5565)
A weekly update script to simplify PRs like #5564 for @EZoni, me and other maintainers.
1 parent 040447c commit 4cae611

File tree

4 files changed

+191
-6
lines changed

4 files changed

+191
-6
lines changed

Tools/Release/updateAMReX.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
print(f"AMReX HEAD commit (development branch): {amrex_HEAD}")
7676
amrex_new_branch = input("Update AMReX commit/branch/sha: ").strip()
7777
if not amrex_new_branch:
78-
amrex_new_branch = amrex_branch
79-
print(f"--> Nothing entered, will keep: {amrex_branch}")
78+
amrex_new_branch = amrex_HEAD
79+
print(f"--> Nothing entered, use: {amrex_HEAD}")
8080
print()
8181

8282
print(

Tools/Release/updatePICSAR.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
print(f"PICSAR HEAD commit (development branch): {PICSAR_HEAD}")
7676
PICSAR_new_branch = input("Update PICSAR commit/branch/sha: ").strip()
7777
if not PICSAR_new_branch:
78-
PICSAR_new_branch = PICSAR_branch
79-
print(f"--> Nothing entered, will keep: {PICSAR_branch}")
78+
PICSAR_new_branch = PICSAR_HEAD
79+
print(f"--> Nothing entered, will use: {PICSAR_HEAD}")
8080
print()
8181

8282
print(

Tools/Release/updatepyAMReX.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
print(f"pyAMReX HEAD commit (development branch): {pyamrex_HEAD}")
7878
pyamrex_new_branch = input("Update pyAMReX commit/branch/sha: ").strip()
7979
if not pyamrex_new_branch:
80-
pyamrex_new_branch = pyamrex_branch
81-
print(f"--> Nothing entered, will keep: {pyamrex_branch}")
80+
pyamrex_new_branch = pyamrex_HEAD
81+
print(f"--> Nothing entered, will use: {pyamrex_HEAD}")
8282
print()
8383

8484
print(

Tools/Release/weeklyUpdate.py

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2025 The WarpX Community
4+
#
5+
# This file is part of WarpX.
6+
#
7+
# Authors: Axel Huebl
8+
#
9+
10+
# This file is a maintainer tool to open a weekly dependency update PR for WarpX.
11+
#
12+
# You also need to have git and the GitHub CLI tool "gh" installed and properly
13+
# configured for it to work:
14+
# https://cli.github.com/
15+
#
16+
import subprocess
17+
import sys
18+
from pathlib import Path
19+
20+
# Maintainer Inputs ###########################################################
21+
22+
print("""Hi there, this is a WarpX maintainer tool to ...\n.
23+
For it to work, you need write access on the source directory and
24+
you should be working in a clean git branch without ongoing
25+
rebase/merge/conflict resolves and without unstaged changes.""")
26+
27+
# check source dir
28+
REPO_DIR = Path(__file__).parent.parent.parent.absolute()
29+
print(f"\nYour current source directory is: {REPO_DIR}")
30+
31+
REPLY = input("Are you sure you want to continue? [y/N] ")
32+
print()
33+
if REPLY not in ["Y", "y"]:
34+
print("You did not confirm with 'y', aborting.")
35+
sys.exit(1)
36+
37+
update_repo = input("What is the name of your git remote? (e.g., ax3l) ")
38+
commit_sign = input("How to sign the commit? (e.g., -sS) ")
39+
40+
41+
# Helpers #####################################################################
42+
43+
44+
def concat_answers(answers):
45+
return "\n".join(answers) + "\n"
46+
47+
48+
# Stash current work ##########################################################
49+
50+
subprocess.run(["git", "stash"], capture_output=True, text=True)
51+
52+
53+
# Git Branch ##################################################################
54+
55+
update_branch = "topic-amrexWeekly"
56+
subprocess.run(["git", "checkout", "development"], capture_output=True, text=True)
57+
subprocess.run(["git", "fetch"], capture_output=True, text=True)
58+
subprocess.run(["git", "pull", "--ff-only"], capture_output=True, text=True)
59+
subprocess.run(["git", "branch", "-D", update_branch], capture_output=True, text=True)
60+
subprocess.run(["git", "checkout", "-b", update_branch], capture_output=True, text=True)
61+
62+
63+
# AMReX New Version ###########################################################
64+
65+
answers = concat_answers(["y", "", "", "y"])
66+
67+
process = subprocess.Popen(
68+
[Path(REPO_DIR).joinpath("Tools/Release/updateAMReX.py")],
69+
stdin=subprocess.PIPE,
70+
stdout=subprocess.PIPE,
71+
stderr=subprocess.PIPE,
72+
text=True,
73+
)
74+
75+
process.communicate(answers)
76+
del process
77+
78+
# commit
79+
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
80+
amrex_diff = subprocess.run(["git", "diff", "--cached"], capture_output=True, text=True)
81+
print("AMReX Commit...")
82+
subprocess.run(
83+
["git", "commit", commit_sign, "-m", "AMReX: Weekly Update"],
84+
capture_output=True,
85+
text=True,
86+
)
87+
88+
89+
# PICSAR New Version ##########################################################
90+
91+
PICSAR_version = "24.09"
92+
answers = concat_answers(["y", PICSAR_version, PICSAR_version, "y"])
93+
94+
process = subprocess.Popen(
95+
[Path(REPO_DIR).joinpath("Tools/Release/updatePICSAR.py")],
96+
stdin=subprocess.PIPE,
97+
stdout=subprocess.PIPE,
98+
stderr=subprocess.PIPE,
99+
text=True,
100+
)
101+
102+
process.communicate(answers)
103+
del process
104+
105+
# commit
106+
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
107+
picsar_diff = subprocess.run(
108+
["git", "diff", "--cached"], capture_output=True, text=True
109+
)
110+
print("PICSAR Commit...")
111+
subprocess.run(
112+
["git", "commit", commit_sign, "-m", "PICSAR: Weekly Update"],
113+
capture_output=True,
114+
text=True,
115+
)
116+
117+
118+
# pyAMReX New Version #########################################################
119+
120+
answers = concat_answers(["y", "", "", "y"])
121+
122+
process = subprocess.Popen(
123+
[Path(REPO_DIR).joinpath("Tools/Release/updatepyAMReX.py")],
124+
stdin=subprocess.PIPE,
125+
stdout=subprocess.PIPE,
126+
stderr=subprocess.PIPE,
127+
text=True,
128+
)
129+
130+
process.communicate(answers)
131+
del process
132+
133+
# commit
134+
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
135+
pyamrex_diff = subprocess.run(
136+
["git", "diff", "--cached"], capture_output=True, text=True
137+
)
138+
print("pyAMReX Commit...")
139+
subprocess.run(
140+
["git", "commit", commit_sign, "-m", "pyAMReX: Weekly Update"],
141+
capture_output=True,
142+
text=True,
143+
)
144+
145+
# GitHub PR ###################################################################
146+
147+
subprocess.run(["git", "push", "-f", "-u", update_repo, update_branch], text=True)
148+
149+
amrex_changes = " (no changes)" if amrex_diff.stdout == "" else ""
150+
picsar_changes = " (no changes)" if picsar_diff.stdout == "" else ""
151+
pyamrex_changes = " (no changes)" if pyamrex_diff.stdout == "" else ""
152+
153+
subprocess.run(
154+
[
155+
"gh",
156+
"pr",
157+
"create",
158+
"--title",
159+
"AMReX/pyAMReX/PICSAR: Weekly Update",
160+
"--body",
161+
f"""Weekly update to latest AMReX{amrex_changes}.
162+
Weekly update to latest pyAMReX{pyamrex_changes}.
163+
Weekly update to latest PICSAR{picsar_changes}.
164+
165+
```console
166+
./Tools/Release/updateAMReX.py
167+
./Tools/Release/updatepyAMReX.py
168+
./Tools/Release/updatePICSAR.py
169+
```
170+
""",
171+
"--label",
172+
"component: documentation",
173+
"--label",
174+
"component: third party",
175+
"--web",
176+
],
177+
text=True,
178+
)
179+
180+
181+
# Epilogue ####################################################################
182+
183+
print("""Done. Please check your source, e.g. via
184+
git diff
185+
now and commit the changes if no errors occurred.""")

0 commit comments

Comments
 (0)