-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve 'Please run' messages in the CI (#48365)
* Improve 'Please run error' * add missing file * fix script * Apply suggestions from code review Co-authored-by: Alan Parra <alan.parra@goteleport.com> * address alan's feedback * Update Makefile Co-authored-by: Alan Parra <alan.parra@goteleport.com> * Update build.assets/please-run.sh Co-authored-by: Alan Parra <alan.parra@goteleport.com> --------- Co-authored-by: Alan Parra <alan.parra@goteleport.com>
- Loading branch information
1 parent
994d314
commit d2fbb80
Showing
3 changed files
with
54 additions
and
7 deletions.
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
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,40 @@ | ||
#!/bin/sh | ||
|
||
# This script is a helper that tells developers what generated content is out of date | ||
# and which command to run. | ||
# When running on GitHub actions, the script will also create an error in the PR and | ||
# collapse the diff to improve readability. | ||
|
||
set -eu | ||
|
||
# only echoes the string if we are in GitHub Actions | ||
echo_gha() { | ||
[ -n "${GITHUB_ACTIONS+x}" ] && echo "$@" | ||
} | ||
|
||
main() { | ||
if [ $# -ne 2 ]; then | ||
echo "Usage: $0 <kind> <generate command>" >&2 | ||
exit 1 | ||
fi | ||
|
||
KIND="$1" | ||
GENERATE_COMMAND="$2" | ||
|
||
TITLE="$KIND are out-of-date" | ||
MESSAGE="Please run the command \`$GENERATE_COMMAND\`" | ||
|
||
# Create a GitHub error | ||
echo_gha "::error file=Makefile,title=$TITLE::$MESSAGE" | ||
|
||
echo "=============" | ||
echo "$TITLE" | ||
echo "$MESSAGE" | ||
echo "=============" | ||
|
||
echo_gha "::group::Diff output" | ||
git diff || true | ||
echo_gha "::endgroup::" | ||
} | ||
|
||
main "$@" |
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