forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
communicate breaking changes to the user (GoogleCloudPlatform#6642)
Co-authored-by: Riley Karson <[email protected]>
- Loading branch information
1 parent
b82613a
commit 038434c
Showing
4 changed files
with
157 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FROM alpine/git | ||
from golang:1.18-stretch as resource | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN apk add --no-cache curl | ||
RUN apk add --no-cache curl-dev | ||
RUN apk add --no-cache bash | ||
RUN apk add --no-cache jq | ||
RUN apt-get update | ||
RUN apt-get install -y curl jq | ||
ADD generate_comment.sh /generate_comment.sh | ||
ADD compare_breaking_changes.sh /compare_breaking_changes.sh | ||
ENTRYPOINT ["/generate_comment.sh"] |
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,59 @@ | ||
#!/bin/bash | ||
# input: two environment variables | ||
# TPG_BREAKING - results of runing breaking change detector | ||
# against tpg | ||
# TPGB_BREAKING - results of runing breaking change detector | ||
# against tpgb | ||
# output: echo to console | ||
# message section cotaining: a header, | ||
# tpg's unique messages, and all of tpgb's messages | ||
|
||
tpgUnique="" | ||
newline=$'\n' | ||
|
||
# This while loop itterates over each individual | ||
# line of TPG_BREAKING. The input to the while loop | ||
# is through the <<< at the conclusion of the loop. | ||
while read -r tpgi; do | ||
simpleTPG=$(sed 's/-.*//' <<< "$tpgi") | ||
found="false" | ||
while read -r tpgbi; do | ||
simpleTPGB=$(sed 's/-.*//' <<< "$tpgbi") | ||
if [ "$simpleTPG" == "$simpleTPGB" ]; then | ||
found="true" | ||
fi | ||
done <<< "$TPGB_BREAKING" | ||
if [ "$found" != "true" ]; then | ||
if [ "$tpgUnique" == "" ]; then | ||
tpgUnique="${tpgi}" | ||
else | ||
tpgUnique="${tpgUnique}${newline}${tpgi}" | ||
fi | ||
fi | ||
done <<< "$TPG_BREAKING" | ||
|
||
|
||
breakingchanges="" | ||
if [ "$tpgUnique" != "" ]; then | ||
tpgUnique=$(sed 's/^/\* /' <<< "$tpgUnique") | ||
breakingchanges="${breakingchanges}${tpgUnique}${newline}" | ||
fi | ||
|
||
if [ "$TPGB_BREAKING" != "" ]; then | ||
tpgbBreaking=$(sed 's/^/\* /' <<< "$TPGB_BREAKING") | ||
breakingchanges="${breakingchanges}${tpgbBreaking}${newline}" | ||
fi | ||
|
||
if [ "$breakingchanges" != "" ]; then | ||
message="## Breaking Change(s) Detected | ||
The following breaking change(s) were detected within your pull request. | ||
${breakingchanges} | ||
If you believe this detection to be incorrect please raise the concern with your reviewer. If you intend to make this change you will need to wait for a [major release](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#example-major-number-increments) window. An \`override-breaking-change\` label can be added to allow merging. | ||
" | ||
fi | ||
|
||
echo "$message" | ||
|
||
|
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