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

Maintainer: Weekly Update Script #5565

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
4 changes: 2 additions & 2 deletions Tools/Release/updateAMReX.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
print(f"AMReX HEAD commit (development branch): {amrex_HEAD}")
amrex_new_branch = input("Update AMReX commit/branch/sha: ").strip()
if not amrex_new_branch:
amrex_new_branch = amrex_branch
print(f"--> Nothing entered, will keep: {amrex_branch}")
amrex_new_branch = amrex_HEAD
print(f"--> Nothing entered, use: {amrex_HEAD}")
print()

print(
Expand Down
4 changes: 2 additions & 2 deletions Tools/Release/updatePICSAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
print(f"PICSAR HEAD commit (development branch): {PICSAR_HEAD}")
PICSAR_new_branch = input("Update PICSAR commit/branch/sha: ").strip()
if not PICSAR_new_branch:
PICSAR_new_branch = PICSAR_branch
print(f"--> Nothing entered, will keep: {PICSAR_branch}")
PICSAR_new_branch = PICSAR_HEAD
print(f"--> Nothing entered, will use: {PICSAR_HEAD}")
print()

print(
Expand Down
4 changes: 2 additions & 2 deletions Tools/Release/updatepyAMReX.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
print(f"pyAMReX HEAD commit (development branch): {pyamrex_HEAD}")
pyamrex_new_branch = input("Update pyAMReX commit/branch/sha: ").strip()
if not pyamrex_new_branch:
pyamrex_new_branch = pyamrex_branch
print(f"--> Nothing entered, will keep: {pyamrex_branch}")
pyamrex_new_branch = pyamrex_HEAD
print(f"--> Nothing entered, will use: {pyamrex_HEAD}")
print()

print(
Expand Down
185 changes: 185 additions & 0 deletions Tools/Release/weeklyUpdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#!/usr/bin/env python3
#
# Copyright 2025 The WarpX Community
#
# This file is part of WarpX.
#
# Authors: Axel Huebl
#

# This file is a maintainer tool to open a weekly dependency update PR for WarpX.
#
# You also need to have git and the GitHub CLI tool "gh" installed and properly
# configured for it to work:
# https://cli.github.com/
#
import subprocess
import sys
from pathlib import Path

# Maintainer Inputs ###########################################################

print("""Hi there, this is a WarpX maintainer tool to ...\n.
For it to work, you need write access on the source directory and
you should be working in a clean git branch without ongoing
rebase/merge/conflict resolves and without unstaged changes.""")

# check source dir
REPO_DIR = Path(__file__).parent.parent.parent.absolute()
print(f"\nYour current source directory is: {REPO_DIR}")

REPLY = input("Are you sure you want to continue? [y/N] ")
print()
if REPLY not in ["Y", "y"]:
print("You did not confirm with 'y', aborting.")
sys.exit(1)

update_repo = input("What is the name of your git remote? (e.g., ax3l) ")
commit_sign = input("How to sign the commit? (e.g., -sS) ")


# Helpers #####################################################################


def concat_answers(answers):
return "\n".join(answers) + "\n"


# Stash current work ##########################################################

subprocess.run(["git", "stash"], capture_output=True, text=True)


# Git Branch ##################################################################

update_branch = "topic-amrexWeekly"
subprocess.run(["git", "checkout", "development"], capture_output=True, text=True)
subprocess.run(["git", "fetch"], capture_output=True, text=True)
subprocess.run(["git", "pull", "--ff-only"], capture_output=True, text=True)
subprocess.run(["git", "branch", "-D", update_branch], capture_output=True, text=True)
subprocess.run(["git", "checkout", "-b", update_branch], capture_output=True, text=True)


# AMReX New Version ###########################################################

answers = concat_answers(["y", "", "", "y"])

process = subprocess.Popen(
[Path(REPO_DIR).joinpath("Tools/Release/updateAMReX.py")],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)

process.communicate(answers)
del process

# commit
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
amrex_diff = subprocess.run(["git", "diff", "--cached"], capture_output=True, text=True)
print("AMReX Commit...")
subprocess.run(
["git", "commit", commit_sign, "-m", "AMReX: Weekly Update"],
capture_output=True,
text=True,
)


# PICSAR New Version ##########################################################

PICSAR_version = "24.09"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the release script, PICSAR is hard-coded to 24.09 because there is no active development in it.

answers = concat_answers(["y", PICSAR_version, PICSAR_version, "y"])

process = subprocess.Popen(
[Path(REPO_DIR).joinpath("Tools/Release/updatePICSAR.py")],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)

process.communicate(answers)
del process

# commit
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
picsar_diff = subprocess.run(
["git", "diff", "--cached"], capture_output=True, text=True
)
print("PICSAR Commit...")
subprocess.run(
["git", "commit", commit_sign, "-m", "PICSAR: Weekly Update"],
capture_output=True,
text=True,
)


# pyAMReX New Version #########################################################

answers = concat_answers(["y", "", "", "y"])

process = subprocess.Popen(
[Path(REPO_DIR).joinpath("Tools/Release/updatepyAMReX.py")],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)

process.communicate(answers)
del process

# commit
subprocess.run(["git", "add", "-u"], capture_output=True, text=True)
pyamrex_diff = subprocess.run(
["git", "diff", "--cached"], capture_output=True, text=True
)
print("pyAMReX Commit...")
subprocess.run(
["git", "commit", commit_sign, "-m", "pyAMReX: Weekly Update"],
capture_output=True,
text=True,
)

# GitHub PR ###################################################################

subprocess.run(["git", "push", "-f", "-u", update_repo, update_branch], text=True)

amrex_changes = " (no changes)" if amrex_diff.stdout == "" else ""
picsar_changes = " (no changes)" if picsar_diff.stdout == "" else ""
pyamrex_changes = " (no changes)" if pyamrex_diff.stdout == "" else ""

subprocess.run(
[
"gh",
"pr",
"create",
"--title",
"AMReX/pyAMReX/PICSAR: Weekly Update",
"--body",
f"""Weekly update to latest AMReX{amrex_changes}.
Weekly update to latest pyAMReX{pyamrex_changes}.
Weekly update to latest PICSAR{picsar_changes}.

```console
./Tools/Release/updateAMReX.py
./Tools/Release/updatepyAMReX.py
./Tools/Release/updatePICSAR.py
```
""",
"--label",
"component: documentation",
"--label",
"component: third party",
"--web",
],
text=True,
)


# Epilogue ####################################################################

print("""Done. Please check your source, e.g. via
git diff
now and commit the changes if no errors occurred.""")
Loading