2021-12-15 10:07:11 -06:00
#!/usr/bin/env bash
2022-01-03 05:48:12 -06:00
# Find existing packages using Lerna
2021-12-15 10:07:11 -06:00
PACKAGES = $( lerna list -p -l)
EXIT_CODE = 0
GITHUB_MESSAGE = ""
2022-01-03 05:48:12 -06:00
# Loop through the packages
2021-12-15 10:07:11 -06:00
while IFS = read -r line; do
# Read package info
IFS = ':' read -ra ADDR <<< " $line "
PACKAGE_PATH = " ${ ADDR [0] } "
PACKAGE_NAME = " ${ ADDR [1] } "
# Calculate current and previous package paths / names
PREV = " $PACKAGE_NAME @canary "
CURRENT = " $PACKAGE_PATH /dist/ "
# Temporarily skipping @grafana/toolkit, as it doesn't have any exposed static typing
if [ [ " $PACKAGE_NAME " = = '@grafana/toolkit' ] ] ; then
continue
fi
# Run the comparison and record the exit code
echo ""
echo ""
echo " ${ PACKAGE_NAME } "
echo "================================================="
npm exec -- @grafana/levitate compare --prev " $PREV " --current " $CURRENT "
# Check if the comparison returned with a non-zero exit code
# Record the output, maybe with some additional information
STATUS = $?
# Final exit code
# (non-zero if any of the packages failed the checks)
if [ $STATUS -gt 0 ]
then
EXIT_CODE = 1
2022-01-06 05:02:45 -06:00
GITHUB_MESSAGE = " ${ GITHUB_MESSAGE } **\\\` ${ PACKAGE_NAME } \\\`** has possible breaking changes ([more info]( ${ GITHUB_JOB_LINK } #step: ${ GITHUB_STEP_NUMBER } :1))<br /> "
2021-12-15 10:07:11 -06:00
fi
done <<< " $PACKAGES "
# "Export" the message to an environment variable that can be used across Github Actions steps
echo " ::set-output name=is_breaking:: $EXIT_CODE "
echo " ::set-output name=message:: $GITHUB_MESSAGE "
# We will exit the workflow accordingly at another step
exit 0