Skip to content

Commit 9f4f1e5

Browse files
mark-vieiragmjehovich
authored andcommitted
Add CI job for updating and generating transport version definitions (elastic#134334)
1 parent 973ec0a commit 9f4f1e5

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
steps: []
1+
steps:
2+
- label: update-transport-versions
3+
command: '.buildkite/scripts/update-transport-versions.sh'
4+
# New transport versions are always added via the main branch
5+
if: build.env('BUILDKITE_PULL_REQUEST_BASE_BRANCH') == 'main'
6+
agents:
7+
provider: gcp
8+
image: family/elasticsearch-ubuntu-2404
9+
machineType: custom-16-32768
10+
buildDirectory: /dev/shm/bk
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
if [[ -z "${BUILDKITE_PULL_REQUEST:-}" ]]; then
5+
echo "Not a pull request, skipping transport version update"
6+
exit 0
7+
fi
8+
9+
if ! git diff --exit-code; then
10+
echo "Changes are present before updating transport versions, not running"
11+
git status
12+
exit 0
13+
fi
14+
15+
NEW_COMMIT_MESSAGE="[CI] Update transport version definitions"
16+
17+
echo "--- Generating updated transport version definitions"
18+
# Calculate backport branches based on pull request version labels
19+
backport_branches=$(
20+
echo "${GITHUB_PR_LABELS}" \
21+
| tr ',' '\n' \
22+
| grep -E "v[0-9]+\.[0-9]+\.[0-9]+" \
23+
| sed -E 's/^v([0-9]+)\.([0-9]+)\.[0-9]+$/\1.\2/' \
24+
| paste -sd, -
25+
)
26+
27+
if [[ -z "${backport_branches}" ]]; then
28+
echo "Skipping as pull request contains no version labels"
29+
exit 0
30+
fi
31+
32+
.ci/scripts/run-gradle.sh generateTransportVersion --backport-branches="${backport_branches}"
33+
34+
if git diff --exit-code; then
35+
echo "No changes found after updating transport versions. Don't need to auto commit."
36+
exit 0
37+
fi
38+
39+
git config --global user.name elasticsearchmachine
40+
git config --global user.email '[email protected]'
41+
42+
gh pr checkout "${BUILDKITE_PULL_REQUEST}"
43+
git add -A .
44+
git commit -m "$NEW_COMMIT_MESSAGE"
45+
git push
46+
47+
# After the git push, the new commit will trigger a new build within a few seconds and this build should get cancelled
48+
# So, let's just sleep to give the build time to cancel itself without an error
49+
# If it doesn't get cancelled for some reason, then exit with an error, because we don't want this build to be green (we just don't want it to generate an error either)
50+
sleep 300
51+
exit 1

0 commit comments

Comments
 (0)