Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config:
skip-target-branches: "main"
steps:
- label: validate-transport-version-backport
command: .buildkite/scripts/validate-transport-version-backport.sh
25 changes: 25 additions & 0 deletions .buildkite/scripts/validate-transport-version-backport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

echo "--- Looking for transport version changes"

# Get any changes in this pull request to transport definitions
git fetch origin "${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" --quiet
changed_files=$(git diff --name-only "origin/${BUILDKITE_PULL_REQUEST_BASE_BRANCH}" | grep -E "server/src/main/resources/transport/definitions/.*\.csv" || true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the "or true" do? Won't that make changed_files a boolean instead of a string list of changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the || true just ensures we always return a 0 exit code from that command since we have set pipefail. Otherwise if grep doesn't return any matches, we'll exit with a non-zero exit code, failing the job, which isn't what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To further clarify, the true utility doesn't produce any output. It simply always returns a 0 exit code. So in that scenario changed_files is still an empty string if there are no matches.


if [[ -z "${changed_files}" ]]; then
echo "No transport version changes detected."
exit 0
fi

# Compare those files against the main branch to ensure they are the same
git fetch origin main --quiet
while IFS= read -r file; do
if ! git diff --quiet origin/main -- "${file}"; then
echo "Changes to transport definition [${file}] missing from main branch."
echo "Transport changes must first be merged to main before being backported."
exit 1
fi
done <<< "${changed_files}"

echo "All transport changes exist in main branch."