-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into unused-vmcs-import
- Loading branch information
Showing
10 changed files
with
474 additions
and
5 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,30 @@ | ||
whiz-vmm-vmc | ||
whiz-vmm-initramfs | ||
whiz-vmm-intr_injection | ||
whiz-vmm-io | ||
whiz-vmm-cr | ||
whiz-vmm-msr | ||
whiz-vmm-cpuid | ||
whiz-vmm-ept | ||
whiz-vmm-linux_boot | ||
whiz-vmm-vmentry_vmexit | ||
whiz-vmm-vmcs | ||
whiz-vmm-vmlaunch | ||
whiz-vmm-vmx_root | ||
whiz-ymir-general_allocator | ||
whiz-ymir-pic | ||
whiz-ymir-page_allocator | ||
whiz-ymir-paging | ||
whiz-ymir-panic | ||
whiz-ymir-interrupt | ||
whiz-ymir-gdt | ||
whiz-ymir-serial_logsystem | ||
whiz-ymir-bit_and_test | ||
whiz-ymir-serial_output | ||
whiz-surtr-jump_to_ymir | ||
whiz-surtr-cleanup_memmap | ||
whiz-surtr-load_kernel | ||
whiz-surtr-simple_pg | ||
whiz-surtr-parse_kernel | ||
whiz-surtr-uefi_log | ||
whiz-surtr-hello_uefi |
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,113 @@ | ||
import os | ||
import subprocess | ||
from github import Github | ||
|
||
|
||
def read_branch_order(filename=".github/scripts/branch-order.txt"): | ||
with open(filename, "r") as f: | ||
return [ | ||
line.strip() | ||
for line in f | ||
if (line.strip() and not line.strip().startswith("#")) | ||
] | ||
|
||
|
||
def get_current_branch(pr_number): | ||
g = Github(os.environ["GITHUB_TOKEN"]) | ||
repo = g.get_repo(os.environ["REPO"]) | ||
pr = repo.get_pull(int(pr_number)) | ||
return pr.base.ref | ||
|
||
|
||
def get_child_branches(current_branch, branches): | ||
try: | ||
current_index = branches.index(current_branch) | ||
return branches[:current_index] | ||
except ValueError: | ||
return [] | ||
|
||
|
||
def cherry_pick_to_branch(commit_sha, target_branch): | ||
try: | ||
# Fetch and checkout target branch | ||
subprocess.run(["git", "fetch", "origin", target_branch], check=True) | ||
subprocess.run(["git", "checkout", target_branch], check=True) | ||
|
||
# Cherry-pick the commit | ||
result = subprocess.run( | ||
["git", "cherry-pick", "-m", "1", commit_sha], | ||
capture_output=True, | ||
text=True, | ||
) | ||
print(result.stderr) | ||
|
||
if result.returncode == 0: | ||
# Push the changes | ||
subprocess.run( | ||
["git", "push", "origin", target_branch], | ||
check=True | ||
) | ||
return True | ||
else: | ||
# If there's a conflict, abort the cherry-pick | ||
subprocess.run(["git", "cherry-pick", "--abort"]) | ||
return False | ||
except subprocess.CalledProcessError: | ||
return False | ||
|
||
|
||
def main(): | ||
# Get PR number from environment | ||
pr_number = os.environ["PR_NUMBER"] | ||
|
||
# Initialize GitHub client | ||
g = Github(os.environ["GITHUB_TOKEN"]) | ||
repo = g.get_repo(os.environ["REPO"]) | ||
pr = repo.get_pull(int(pr_number)) | ||
|
||
# Check if the PR is merged | ||
if not pr.merged: | ||
print("❌ PR is not yet merged.") | ||
return | ||
|
||
# Get the merge commit SHA | ||
merge_commit_sha = pr.merge_commit_sha | ||
if not merge_commit_sha: | ||
print("No merge commit found") | ||
return | ||
print(f"merge_commit_sha: {merge_commit_sha}") | ||
|
||
# Read branch order | ||
branches = read_branch_order() | ||
|
||
# Get current branch and find children | ||
current_branch = get_current_branch(pr_number) | ||
child_branches = get_child_branches(current_branch, branches) | ||
|
||
if len(child_branches) == 0: | ||
pr.create_issue_comment( | ||
"💤 No target branches found. Cherry-pick skipped." | ||
) | ||
return | ||
|
||
# Cherry-pick to each child branch | ||
failed_branches = [] | ||
for branch in child_branches: | ||
success = cherry_pick_to_branch(merge_commit_sha, branch) | ||
if not success: | ||
failed_branches.append(branch) | ||
|
||
if len(failed_branches) == 0: | ||
pr.create_issue_comment( | ||
f"✅ Successfully cherry-picked to {len(child_branches)} branches." | ||
) | ||
else: | ||
pr.create_issue_comment( | ||
"❌ Cherry-pick failed for the following branches " | ||
"(manual intervention required):\n" + | ||
"\n".join([f"- {branch}" for branch in failed_branches]) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,40 @@ | ||
name: Cherry Pick Bot | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
cherry-pick: | ||
if: contains(github.event.comment.body, '@.ymir cherry-pick') && github.event.comment.user.login == 'smallkirby' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Generate a token | ||
id: generate-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app_id: ${{ vars.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
|
||
- name: Setup uv | ||
uses: astral-sh/setup-uv@v5 | ||
|
||
- name: Setup Python | ||
run: | | ||
uv python install | ||
uv sync --all-extras | ||
- name: Setup Git | ||
run: | | ||
git config --global user.name 'smallkirby-ymir[bot]' | ||
git config --global user.email '195134948+smallkirby-ymir[bot]@users.noreply.github.com' | ||
git fetch --all | ||
- name: Run Cherry Pick Script | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
PR_NUMBER: ${{ github.event.issue.number }} | ||
REPO: ${{ github.repository }} | ||
run: uv run .github/scripts/cherry-picker.py |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/docs | ||
|
||
.gdb_history | ||
.venv |
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 @@ | ||
3.12 |
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,7 @@ | ||
[project] | ||
name = "ymir-cherry-pick-bot" | ||
version = "0.0.0" | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
"pygithub>=2.5.0", | ||
] |
Oops, something went wrong.