-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exit early when generation fails (#1066)
* introduce pre-commit wrapper * remove echo * Regenerate client from commit 33b7a42c of spec repo Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
- Loading branch information
1 parent
2cbf49b
commit fab745f
Showing
4 changed files
with
35 additions
and
12 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
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,30 @@ | ||
#!/bin/bash | ||
|
||
DEFAULT_ERROR_CODES="0" | ||
|
||
# First arg is the command | ||
# Second arg is the string of acceptable error codes seperated by space. E.g. "0 1" | ||
pre_commit_wrapper () { | ||
echo "running pre-commit run --all-files --hook-stage=manual ${1}" | ||
|
||
exec 5>&1 | ||
acceptable_errors=${2:-$DEFAULT_ERROR_CODES} | ||
out=$(pre-commit run --all-files --hook-stage=manual "${1}" | tee >(cat - >&5)) | ||
exit_code=$( echo "$out" | grep -- "- exit code:" | cut -d":" -f2 | sed 's/[^0-9]*//g' ) | ||
|
||
if [[ -n $exit_code ]]; then | ||
re="([^0-9]|^)$exit_code([^0-9]|$)" | ||
if ! grep -qE "$re" <<< "$acceptable_errors" ; then | ||
echo "pre-commit subcommand failed with error_code: $exit_code. See output above" | ||
exit "$exit_code"; | ||
fi | ||
fi | ||
|
||
echo "command 'pre-commit run --all-files --hook-stage=manual ${1}' success" | ||
} | ||
|
||
rm -rf ./lib/datadog_api_client/v1 ./lib/datadog_api_client/v2 examples/* | ||
pre_commit_wrapper generator | ||
pre_commit_wrapper examples | ||
pre_commit_wrapper format-examples 3 | ||
pre_commit_wrapper docs |