diff --git a/.github/scripts/apply_torch_pr.py b/.github/scripts/apply_torch_pr.py index dfbf109d60..8a5104141f 100644 --- a/.github/scripts/apply_torch_pr.py +++ b/.github/scripts/apply_torch_pr.py @@ -56,17 +56,12 @@ def check_merged(pr_info): merged = False return merged -def appyly_pr(pull_number, re_apply_msg): - # get the diff - os.system(f"\ - git fetch origin pull/{pull_number}/head:{pull_number} && \ - git checkout -f {pull_number} && \ - git merge ci-tmp-$(hostname) --no-edit --no-ff > /dev/null && \ - git diff ci-tmp-$(hostname) {pull_number} > {pull_number}.diff \ - ") +def appyly_pr(pr_info, repo_info, re_apply_msg): + # get pr diff + pr_file = pr_info["diff_url"].split("/")[-1] + os.system(f"gh --repo {repo_info[-4]}/{repo_info[-3]} pr diff {repo_info[-1]} > {pr_file}") # apply diff - os.system("git checkout ci-test-$(hostname)") - apply_cmd = f"git reset --hard && git apply --3way {pull_number}.diff" + apply_cmd = "git apply --3way " + pr_file apply_info = subprocess.Popen(apply_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) apply_message = apply_info.communicate()[0].decode("utf-8") apply_status = apply_info.returncode @@ -88,9 +83,6 @@ def appyly_pr(pull_number, re_apply_msg): pr_list = args.pr_list + args.extra_pr_list pr_list = set(pr_list) pr_list = sorted(pr_list) -# checkout a base branch -os.system("git checkout -b ci-tmp-$(hostname) && git checkout -b ci-test-$(hostname) && rm -f *.diff") -os.system("git config --global user.email intel.com && git config --global user.name intel") for pr_link in pr_list: repo_info = pr_link.split("/") pr_info = requests.get('https://api.' + repo_info[-5] + '/repos/' + repo_info[-4] + '/' + \ @@ -107,7 +99,7 @@ def appyly_pr(pull_number, re_apply_msg): continue else: re_apply_msg = "is re-opened and reverted," - appyly_pr(repo_info[-1], re_apply_msg) + appyly_pr(pr_info, repo_info, re_apply_msg) elif pr_info["state"].lower() == "closed": merged_id = next((item["id"] for item in pr_info["labels"] if item["name"] == "Merged"), -1) re_apply_msg = "is closed but not merged" @@ -116,8 +108,7 @@ def appyly_pr(pull_number, re_apply_msg): if merged: print("{} is closed and merged, no need to apply".format(pr_info["diff_url"])) continue - appyly_pr(repo_info[-1], re_apply_msg) + appyly_pr(pr_info, repo_info, re_apply_msg) else: print("{} is {}, no need to apply".format(pr_info["diff_url"], pr_info["state"])) sys.exit(1) -os.system("git checkout ci-test-$(hostname) && git reset --hard && git apply --3way *.diff && git status") diff --git a/.github/workflows/_linux_ut.yml b/.github/workflows/_linux_ut.yml index b2abfd1ec2..a94c49d0bd 100644 --- a/.github/workflows/_linux_ut.yml +++ b/.github/workflows/_linux_ut.yml @@ -119,7 +119,7 @@ jobs: cd third_party/torch-xpu-ops git checkout ${TORCH_XPU_OPS_COMMIT} cd ../.. - python third_party/torch-xpu-ops/.github/scripts/apply_torch_pr.py + python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py fi pip install -r .ci/docker/requirements-ci.txt - name: Torch Config @@ -412,7 +412,7 @@ jobs: cd third_party/torch-xpu-ops git checkout ${TORCH_XPU_OPS_COMMIT} cd ../.. - python third_party/torch-xpu-ops/.github/scripts/apply_torch_pr.py + python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py fi pip install -r .ci/docker/requirements-ci.txt - name: Torch Config diff --git a/.github/workflows/nightly_ondemand_whl.yml b/.github/workflows/nightly_ondemand_whl.yml index fbee5dac3d..2bd80b3f88 100644 --- a/.github/workflows/nightly_ondemand_whl.yml +++ b/.github/workflows/nightly_ondemand_whl.yml @@ -116,7 +116,6 @@ jobs: cd pytorch && git checkout ${TORCH_COMMIT_ID} # apply PRs for stock pytorch pip install requests - # python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py git status && git show -s pip install -r requirements.txt TORCH_XPU_OPS_COMMIT=$(