From cdbe45826dbd267e47bfc078dda71cdbc6e0ca79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:32:51 +0000 Subject: [PATCH 1/9] Initial plan From 3f2b9f05f902a680b19e6ce421487499aa05edb4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:38:36 +0000 Subject: [PATCH 2/9] Add postsubmit job to auto-update pd dependency in TiDB Co-authored-by: wuhuizuo <2574558+wuhuizuo@users.noreply.github.com> --- prow-jobs/kustomization.yaml | 1 + prow-jobs/tikv/pd/common-postsubmits.yaml | 94 +++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 prow-jobs/tikv/pd/common-postsubmits.yaml diff --git a/prow-jobs/kustomization.yaml b/prow-jobs/kustomization.yaml index 91c73b9432..2fd96d5d4a 100644 --- a/prow-jobs/kustomization.yaml +++ b/prow-jobs/kustomization.yaml @@ -123,6 +123,7 @@ configMapGenerator: - tikv_community_presubmits.yaml=tikv/community/presubmits.yaml - tikv_copr-test_latest-presubmits.yaml=tikv/copr-test/latest-presubmits.yaml - tikv_migration_latest-presubmits.yaml=tikv/migration/latest-presubmits.yaml + - tikv_pd_common-postsubmits.yaml=tikv/pd/common-postsubmits.yaml - tikv_pd_common-presubmits.yaml=tikv/pd/common-presubmits.yaml - tikv_pd_latest-presubmits-next-gen.yaml=tikv/pd/latest-presubmits-next-gen.yaml - tikv_pd_latest-presubmits.yaml=tikv/pd/latest-presubmits.yaml diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml new file mode 100644 index 0000000000..35724a90b2 --- /dev/null +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -0,0 +1,94 @@ +global_definitions: + branches: &branches + - ^master$ + - ^release-[0-9]+[.][0-9]+$ + skip_if_only_changed: &skip_if_only_changed "(\\.(md|png|jpeg|jpg|gif|svg|pdf)|Dockerfile|OWNERS|OWNERS_ALIASES)$" + +# struct ref: https://pkg.go.dev/sigs.k8s.io/prow/pkg/config#Postsubmit +postsubmits: + tikv/pd: + - name: auto-update-pd-gomod + decorate: true + decorate_config: + skip_cloning: true + skip_if_only_changed: *skip_if_only_changed + branches: *branches + spec: + containers: + - name: build + image: golang:1.23 + command: [bash, -ceo, pipefail] + args: + - | + # clone tidb repo + git clone https://github.com/pingcap/tidb.git --branch "${PULL_BASE_REF}" ../tidb && cd ../tidb + + ###### update mods that comes from pd repo ##### + new_pd="$(go list -m github.com/tikv/pd@${PULL_BASE_REF} | awk '{print $1 "@" $2}')" + echo "new pd: $new_pd" + go mod edit --require "$new_pd" go.mod + + # fast exit if no change on go.mod file + git add go.mod + if git diff --cached --exit-code --name-status go.mod; then + echo "🤷 No changes happened." + exit 0 + fi + + # update go.sum + go mod tidy + git add go.mod go.sum + + # install `gh` tool + type -p curl >/dev/null || ( apt update && apt install curl -y) + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ + && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ + && apt update \ + && apt install gh -y + + # setup git + git config user.email "ti-community-prow-bot@tidb.io" + git config user.name "ti-chi-bot" + gh auth setup-git + + # commit and push the changes. + head_branch="fix/${PULL_BASE_REF}/update-dep-pd" + git checkout -b "$head_branch" + commit_msg="chore(deps): bump go mod github.com/tikv/pd" + git commit -m "$commit_msg" + git push -f --set-upstream origin "$head_branch" + + # create pull request + pr_desc=" + ### What problem does this PR solve? + + Auto generated by bot. + Issue Number: ref #${REF_ISSUE_NUM} + + ### Release note + + \`\`\`release-note + None + \`\`\` + " + gh pr create \ + --base $PULL_BASE_REF \ + --head "$head_branch" \ + --title "$commit_msg" \ + --body "$pr_desc" + env: + - name: REF_ISSUE_NUM + value: "1074" + - name: GH_TOKEN + valueFrom: + secretKeyRef: + key: token + name: github-token + resources: + requests: + memory: 1Gi + cpu: "500m" + limits: + memory: 2Gi + cpu: "1" From 1efe0e0d1d50da165180e6ac3afe4af90f29e604 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:57:18 +0000 Subject: [PATCH 3/9] Update pd module to client submodule and trigger only on client folder changes Co-authored-by: wuhuizuo <2574558+wuhuizuo@users.noreply.github.com> --- prow-jobs/tikv/pd/common-postsubmits.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 35724a90b2..1bfbaa7ec5 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -12,6 +12,7 @@ postsubmits: decorate_config: skip_cloning: true skip_if_only_changed: *skip_if_only_changed + run_if_changed: "^client/.*$" branches: *branches spec: containers: @@ -24,7 +25,7 @@ postsubmits: git clone https://github.com/pingcap/tidb.git --branch "${PULL_BASE_REF}" ../tidb && cd ../tidb ###### update mods that comes from pd repo ##### - new_pd="$(go list -m github.com/tikv/pd@${PULL_BASE_REF} | awk '{print $1 "@" $2}')" + new_pd="$(go list -m github.com/tikv/pd/client@${PULL_BASE_REF} | awk '{print $1 "@" $2}')" echo "new pd: $new_pd" go mod edit --require "$new_pd" go.mod @@ -55,7 +56,7 @@ postsubmits: # commit and push the changes. head_branch="fix/${PULL_BASE_REF}/update-dep-pd" git checkout -b "$head_branch" - commit_msg="chore(deps): bump go mod github.com/tikv/pd" + commit_msg="chore(deps): bump go mod github.com/tikv/pd/client" git commit -m "$commit_msg" git push -f --set-upstream origin "$head_branch" From 2af8bb0677cdbf2330ebe9fc69ca4f933f228593 Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 16 Oct 2025 18:06:42 +0800 Subject: [PATCH 4/9] Apply suggestion from @wuhuizuo --- prow-jobs/tikv/pd/common-postsubmits.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 1bfbaa7ec5..33e3f7f3ce 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -11,7 +11,6 @@ postsubmits: decorate: true decorate_config: skip_cloning: true - skip_if_only_changed: *skip_if_only_changed run_if_changed: "^client/.*$" branches: *branches spec: From 0fa3027cd08c9deea560bbf6bd652a4900ad8850 Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 16 Oct 2025 18:14:32 +0800 Subject: [PATCH 5/9] Apply suggestion from @wuhuizuo --- prow-jobs/tikv/pd/common-postsubmits.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 33e3f7f3ce..69beccc4a4 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -78,7 +78,12 @@ postsubmits: --title "$commit_msg" \ --body "$pr_desc" env: + - name: REVIEWER + value: "rleungx" + - name: ASSIGNEE + value: "rleungx" - name: REF_ISSUE_NUM + value: "63997" value: "1074" - name: GH_TOKEN valueFrom: From b1186a5050a9e5e297b30a598f9b2ed611e685ed Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 16 Oct 2025 18:14:49 +0800 Subject: [PATCH 6/9] Apply suggestion from @wuhuizuo --- prow-jobs/tikv/pd/common-postsubmits.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 69beccc4a4..7620a11449 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -76,7 +76,9 @@ postsubmits: --base $PULL_BASE_REF \ --head "$head_branch" \ --title "$commit_msg" \ - --body "$pr_desc" + --body "$pr_desc" \ + --reviewer "$REVIEWER" \ + --assignee "$ASSIGNEE" env: - name: REVIEWER value: "rleungx" From cc5cf62cd08b6ee0020051456cdb740a3edd32f8 Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 16 Oct 2025 18:18:09 +0800 Subject: [PATCH 7/9] Apply suggestion from @wuhuizuo --- prow-jobs/tikv/pd/common-postsubmits.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 7620a11449..922186696e 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -66,6 +66,17 @@ postsubmits: Auto generated by bot. Issue Number: ref #${REF_ISSUE_NUM} + ### Check List + + Tests + + - [x] Unit test + - [ ] Integration test + - [ ] Manual test (add detailed scripts or steps below) + - [ ] No need to test + > - [ ] I checked and no code files have been changed. + > + ### Release note \`\`\`release-note From 4640b6907e20b13566bd8cc97a3fd239a56a71e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Oct 2025 10:18:29 +0000 Subject: [PATCH 8/9] fix: auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- prow-jobs/tikv/pd/common-postsubmits.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 922186696e..63a314cfbb 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -67,9 +67,9 @@ postsubmits: Issue Number: ref #${REF_ISSUE_NUM} ### Check List - + Tests - + - [x] Unit test - [ ] Integration test - [ ] Manual test (add detailed scripts or steps below) From ae405022852ce7f363be6264305555fa9f15b94a Mon Sep 17 00:00:00 2001 From: wuhuizuo Date: Thu, 16 Oct 2025 18:35:24 +0800 Subject: [PATCH 9/9] Apply suggestion from @wuhuizuo --- prow-jobs/tikv/pd/common-postsubmits.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/prow-jobs/tikv/pd/common-postsubmits.yaml b/prow-jobs/tikv/pd/common-postsubmits.yaml index 63a314cfbb..aef23b4170 100644 --- a/prow-jobs/tikv/pd/common-postsubmits.yaml +++ b/prow-jobs/tikv/pd/common-postsubmits.yaml @@ -97,7 +97,6 @@ postsubmits: value: "rleungx" - name: REF_ISSUE_NUM value: "63997" - value: "1074" - name: GH_TOKEN valueFrom: secretKeyRef: