Skip to content
Draft
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
1 change: 1 addition & 0 deletions prow-jobs/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
111 changes: 111 additions & 0 deletions prow-jobs/tikv/pd/common-postsubmits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
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
run_if_changed: "^client/.*$"
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/client@${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 "[email protected]"
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/client"
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}

### Check List

Tests <!-- At least one of them must be included. -->

- [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.
> <!-- Or your custom "No need to test" reasons -->

### Release note

\`\`\`release-note
None
\`\`\`
"
gh pr create \
--base $PULL_BASE_REF \
--head "$head_branch" \
--title "$commit_msg" \
--body "$pr_desc" \
--reviewer "$REVIEWER" \
--assignee "$ASSIGNEE"
env:
- name: REVIEWER
value: "rleungx"
- name: ASSIGNEE
value: "rleungx"
- name: REF_ISSUE_NUM
value: "63997"
- name: GH_TOKEN
valueFrom:
secretKeyRef:
key: token
name: github-token
resources:
requests:
memory: 1Gi
cpu: "500m"
limits:
memory: 2Gi
cpu: "1"