-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of Limit number of tests in CI comment into release/1.13.x (#…
…21970) * backport of commit dc10489 (#21853) * fix multiline * shellcheck, and success message for builds * add full path * cat the summary * fix and faster * fix if condition * base64 in a separate step * echo * check against empty string * add echo * only use matrix ids * only id * echo matrix * remove wrapping array * tojson * try echo again * use jq to get packages * don't quote * only run binary tests once * only run binary tests once * test what's wrong with the binary * separate file * use matrix file * failed test * update comment on success * correct variable name * bae64 fix * output to file * use multiline * fix * fix formatting * fix newline * fix whitespace * correct body, remove comma * small fixes * shellcheck * another shellcheck fix * fix deprecation checker * only run comments for prs * Update .github/workflows/test-go.yml Co-authored-by: Mike Palmiotto <[email protected]> * Update .github/workflows/test-go.yml Co-authored-by: Mike Palmiotto <[email protected]> * fixes --------- Co-authored-by: Mike Palmiotto <[email protected]> * backport of commit 3b00dde (#21936) * limit test comments * remove unecessary tee * fix go test condition * fix * fail test * remove ailways entirely * fix columns * make a bunch of tests fail * separate line * include Failures: * remove test fails * fix whitespace * backport of commit 2454302 (#21973) * only add binary tests if they exist * shellcheck --------- Co-authored-by: miagilepner <[email protected]> Co-authored-by: Mike Palmiotto <[email protected]>
- Loading branch information
1 parent
f5f8c86
commit a420deb
Showing
8 changed files
with
171 additions
and
67 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
|
||
function update_or_create_comment { | ||
REPO=$1 | ||
PR_NUMBER=$2 | ||
SEARCH_KEY=$3 | ||
BODY=$4 | ||
|
||
# We only want for the GH bot to place one comment to report build failures | ||
# and if we rerun a job, that comment needs to be updated. | ||
# Let's try to find if the GH bot has placed a similar comment | ||
comment_id=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
--paginate \ | ||
/repos/hashicorp/"$REPO"/issues/"$PR_NUMBER"/comments | jq -r --arg SEARCH_KEY "$SEARCH_KEY" '.[] | select (.body | contains($SEARCH_KEY)) | .id') | ||
|
||
if [[ "$comment_id" != "" ]]; then | ||
# update the comment with the new body | ||
gh api \ | ||
--method PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/hashicorp/"$REPO"/issues/comments/"$comment_id" \ | ||
-f body="$BODY" | ||
else | ||
# create a comment with the new body | ||
gh api \ | ||
--method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
/repos/hashicorp/"$REPO"/issues/"$PR_NUMBER"/comments \ | ||
-f body="$BODY" | ||
fi | ||
} |
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,42 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
MAX_TESTS=10 | ||
# this script expects the following env vars to be set | ||
# error if these are not set | ||
[ ${GITHUB_TOKEN:?} ] | ||
[ ${RUN_ID:?} ] | ||
[ ${REPO:?} ] | ||
[ ${PR_NUMBER:?} ] | ||
if [ -z "$TABLE_DATA" ]; then | ||
BODY="CI Results: | ||
All Go tests succeeded! :white_check_mark:" | ||
else | ||
# Remove any rows that don't have a test name | ||
# Only keep the test type, test package, test name, and logs column | ||
# Remove the scroll emoji | ||
# Remove "github.com/hashicorp/vault" from the package name | ||
TABLE_DATA=$(echo "$TABLE_DATA" | awk -F\| '{if ($4 != " - ") { print "|" $2 "|" $3 "|" $4 "|" $7 }}' | sed -r 's/ :scroll://' | sed -r 's/github.com\/hashicorp\/vault\///') | ||
NUM_FAILURES=$(wc -l <<< "$TABLE_DATA") | ||
|
||
# Check if the number of failures is greater than the maximum tests to display | ||
# If so, limit the table to MAX_TESTS number of results | ||
if [ "$NUM_FAILURES" -gt "$MAX_TESTS" ]; then | ||
TABLE_DATA=$(echo "$TABLE_DATA" | head -n "$MAX_TESTS") | ||
NUM_OTHER=( $NUM_FAILURES - "$MAX_TESTS" ) | ||
TABLE_DATA="$TABLE_DATA | ||
and $NUM_OTHER other tests" | ||
fi | ||
|
||
# Add the header for the table | ||
BODY="CI Results: | ||
Failures: | ||
| Test Type | Package | Test | Logs | | ||
| --------- | ------- | ---- | ---- | | ||
${TABLE_DATA}" | ||
fi | ||
|
||
source ./.github/scripts/gh_comment.sh | ||
|
||
update_or_create_comment "$REPO" "$PR_NUMBER" "CI Results:" "$BODY" |
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
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