mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [Add custom Buildkite pipeline for @kbn/handlebars (#146964)](https://github.com/elastic/kibana/pull/146964) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Thomas Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2022-12-08T17:28:33Z","message":"Add custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses #146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.7.0"],"number":146964,"url":"https://github.com/elastic/kibana/pull/146964","mergeCommit":{"message":"Add custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses #146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146964","number":146964,"mergeCommit":{"message":"Add custom Buildkite pipeline for @kbn/handlebars (#146964)\n\nCloses #146963","sha":"39d27bb868ba5e0d544a0fa17afb19abf650c7bf"}}]}] BACKPORT--> Co-authored-by: Thomas Watson <watson@elastic.co>
88 lines
2.6 KiB
Bash
Executable file
88 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
TMP=.tmp-handlebars
|
|
|
|
# Try to detect Windows environment (I've not tested this!)
|
|
if [[ "$OSTYPE" == "msys" ]]; then
|
|
# Windows environment
|
|
DEVNULL=NUL
|
|
else
|
|
# Everything else (including Cygwin on Windows)
|
|
DEVNULL=/dev/null
|
|
fi
|
|
|
|
function cleanup {
|
|
rm -fr $TMP
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
rm -fr $TMP
|
|
mkdir $TMP
|
|
|
|
echo "Cloning handlebars repo..."
|
|
git clone -q --depth 1 https://github.com/handlebars-lang/handlebars.js.git -b 4.x $TMP/handlebars
|
|
|
|
files=(packages/kbn-handlebars/src/upstream/index.*.test.ts)
|
|
|
|
for file in "${files[@]}"
|
|
do
|
|
tmp=${file#*.} # remove anything before first period
|
|
file=${tmp%.test.ts} # remove trailing .test.ts
|
|
|
|
echo "Checking for changes to spec/$file.js..."
|
|
|
|
set +e
|
|
diff -d --strip-trailing-cr $TMP/handlebars/spec/$file.js packages/kbn-handlebars/src/upstream/index.$file.test.ts > $TMP/$file.patch
|
|
error=$?
|
|
set -e
|
|
if [ $error -gt 1 ]
|
|
then
|
|
echo "The diff command encountered an unexpected error!"
|
|
exit $error
|
|
fi
|
|
|
|
set +e
|
|
diff -d --strip-trailing-cr $TMP/$file.patch packages/kbn-handlebars/.patches/$file.patch > $DEVNULL
|
|
error=$?
|
|
set -e
|
|
if [ $error -gt 1 ]
|
|
then
|
|
echo "The diff command encountered an unexpected error!"
|
|
exit $error
|
|
elif [ $error -gt 0 ]
|
|
then
|
|
echo
|
|
echo "The following files contain unexpected differences:"
|
|
echo
|
|
echo " Upstream: spec/$file.js"
|
|
echo " Downstream: packages/kbn-handlebars/src/upstream/index.$file.test.ts"
|
|
echo
|
|
echo "This can happen if either the upstream or the downstream version has been"
|
|
echo "updated without our patch files being kept up to date."
|
|
echo
|
|
echo "To resolve this issue, do the following:"
|
|
echo
|
|
echo " 1. Check the '4.x' branch of the upstream git repository to see if the file"
|
|
echo " has been updated. If so, please ensure that our copy of the file is kept in"
|
|
echo " sync. You can view the recent upstream commits to this file here:"
|
|
echo
|
|
echo " https://github.com/handlebars-lang/handlebars.js/commits/4.x/spec/$file.js"
|
|
echo
|
|
echo " 2. Update our patch files by running the following script. This is also"
|
|
echo " necessary even if it's only the downstream file that has been updated:"
|
|
echo
|
|
echo " ./packages/kbn-handlebars/scripts/update_test_patches.sh $file"
|
|
echo
|
|
echo " 3. Commit the changes to the updated patch file and execute this script again"
|
|
echo " until everything passes:"
|
|
echo
|
|
echo " ./packages/kbn-handlebars/scripts/check_for_test_changes.sh"
|
|
echo
|
|
exit $error
|
|
fi
|
|
done
|
|
|
|
echo "No changes found :)"
|