-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3934 from gousteris/backport-pre-command-v21.11.x
backport v21.11.x: bk: run multiple repetitions of steps
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
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,43 @@ | ||
#!/bin/bash | ||
|
||
# This file should be kept in sync with vtools's pre-command file. | ||
# https://github.com/redpanda-data/vtools/.buildkite/hooks/pre-command | ||
|
||
set -uo pipefail | ||
set +e | ||
|
||
disable_hook="${DISABLE_PRE_COMMAND_HOOK:-0}" | ||
|
||
if [[ ${disable_hook} == 0 ]]; then | ||
PARALLEL_STEPS=1 | ||
|
||
repo=$(echo $BUILDKITE_REPO | awk -F/ '{print $NF}' | awk -F. '{print $1}') | ||
|
||
if [[ ${BUILDKITE_PULL_REQUEST} != false ]]; then | ||
labels=$(curl \ | ||
--retry 3 --retry-connrefused --fail \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${GITHUB_API_TOKEN}" \ | ||
"https://api.github.com/repos/redpanda-data/${repo}/issues/${BUILDKITE_PULL_REQUEST}/labels") | ||
|
||
if [[ $? == "0" ]]; then | ||
set -e | ||
parallel=$(echo "${labels}" | jq -r '.[].name|select(startswith("ci-repeat-"))|ltrimstr("ci-repeat-")' | head -1) | ||
curl \ | ||
-X "DELETE" \ | ||
--retry 3 --retry-connrefused --silent \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${GITHUB_API_TOKEN}" \ | ||
"https://api.github.com/repos/redpanda-data/${repo}/issues/${BUILDKITE_PULL_REQUEST}/labels/ci-repeat-$parallel" | ||
|
||
if ((parallel > 1 && parallel < 20)); then | ||
PARALLEL_STEPS=$parallel | ||
else | ||
echo >&2 "Provided parallel number is out of range(2-19). Changing to 1." | ||
PARALLEL_STEPS=1 | ||
fi | ||
fi | ||
fi | ||
|
||
export PARALLEL_STEPS | ||
fi |
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