-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6068c61
commit 9789882
Showing
18 changed files
with
757 additions
and
99 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
34 changes: 34 additions & 0 deletions
34
.github/actions/reportportal-summarize/get-teams-message.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,34 @@ | ||
#!/bin/bash -e | ||
|
||
if [[ -n "$RP_LAUNCH_KEY" ]]; then | ||
|
||
NB=$(echo "$RP_CONTENT" | jq -r '.page.totalElements // "0"') | ||
if [[ "$NB" == "0" || -z "$NB" ]]; then | ||
MSG+="No report found for key "'`'"$RP_LAUNCH_KEY"'`'"." | ||
MSG+="\n\nSee [latest reports]($RP_LAUNCH_URL)." | ||
elif [ "$NB" == "1" ]; then | ||
RP_LAUNCH_ID=$(echo "$RP_CONTENT" | jq -r '.content[0].id // empty') | ||
STATUS=$(echo "$RP_CONTENT" | jq -r '.content[0].status // empty') | ||
[[ "$STATUS" == 'PASSED' ]] && ICON="✅" || ICON="❌" | ||
MSG+="See [report]($RP_LAUNCH_URL/$RP_LAUNCH_ID) $ICON" | ||
else | ||
MSG+="$NB reports found for key "'`'"$RP_LAUNCH_KEY"'`'"." | ||
while read -r id ; do | ||
read -r number | ||
read -r status | ||
case $status in | ||
PASSED) | ||
status_icon="✅" ;; | ||
FAILED) | ||
status_icon="❌" | ||
;; | ||
*) | ||
status_icon="$status" | ||
;; | ||
esac | ||
MSG+="\n\n[Report #$number]($RP_LAUNCH_URL/$id) $status_icon" | ||
done < <(echo "$RP_CONTENT" | jq -r '.content[] | .id, .number, .status') | ||
fi | ||
fi | ||
|
||
echo "message=$MSG" >> $GITHUB_OUTPUT |
92 changes: 92 additions & 0 deletions
92
.github/actions/reportportal-summarize/tests/get-teams-message.bats
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,92 @@ | ||
setup() { | ||
# Runs everywhere | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
PATH="$DIR/..:$PATH" | ||
|
||
export GITHUB_OUTPUT="$BATS_TMPDIR"/test-get-teams-message_ghoutput_"$RANDOM"'.log' | ||
> $GITHUB_OUTPUT | ||
|
||
export RP_LAUNCH_KEY=my-tests-push-3665876492 | ||
export RP_TOKEN=tok | ||
export RP_URL=https://rpserver:8080 | ||
|
||
export RP_CONTENT="" | ||
export RP_LAUNCH_URL=https://rpserver:8080/ui/#my-project/launches/all | ||
|
||
export NO_MESSAGE="message=" | ||
export KEY_NO_REPORT="message=No report found for key \`my-tests-push-3665876492\`.\n\nSee [latest reports](https://rpserver:8080/ui/#my-project/launches/all)." | ||
export SINGLE_REPORT="message=See [report](https://rpserver:8080/ui/#my-project/launches/all/88) ✅" | ||
export MULTIPLE_REPORTS=$(cat << BATS | ||
message=3 reports found for key \`my-tests-push-3665876492\`.\n\n[Report #3](https://rpserver:8080/ui/#my-project/launches/all/91) ❌\n\n[Report #2](https://rpserver:8080/ui/#my-project/launches/all/90) WHATEVER_STATUS\n\n[Report #1](https://rpserver:8080/ui/#my-project/launches/all/89) ✅ | ||
BATS | ||
) | ||
} | ||
|
||
teardown() { | ||
rm -f $GITHUB_OUTPUT | ||
} | ||
|
||
@test "teams message rp disabled" { | ||
export RP_LAUNCH_KEY="" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$NO_MESSAGE" ] | ||
} | ||
|
||
@test "teams message no launch id" { | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$KEY_NO_REPORT" ] | ||
} | ||
|
||
@test "teams message single" { | ||
export RP_CONTENT="$(< $BATS_TEST_DIRNAME/sample-launch.json)" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$SINGLE_REPORT" ] | ||
} | ||
|
||
@test "teams message multiple" { | ||
export RP_CONTENT="$(< $BATS_TEST_DIRNAME/sample-launches.json)" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$MULTIPLE_REPORTS" ] | ||
} | ||
|
||
@test "teams message rp failure no results" { | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$KEY_NO_REPORT" ] | ||
} | ||
|
||
@test "teams message rp failure no results empty json" { | ||
export RP_CONTENT="{}" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$KEY_NO_REPORT" ] | ||
} | ||
|
||
@test "teams message rp success no results" { | ||
export OUTCOME="success" | ||
export RP_CONTENT="$(< $BATS_TEST_DIRNAME/empty-launch.json)" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$KEY_NO_REPORT" ] | ||
} | ||
|
||
@test "teams message rp failure no results empty json no launch key" { | ||
export RP_LAUNCH_KEY="" | ||
export RP_CONTENT="{}" | ||
run get-teams-message.sh | ||
[ "$status" -eq 0 ] | ||
echo "$(< $GITHUB_OUTPUT)" | ||
[ "$(< $GITHUB_OUTPUT)" = "$NO_MESSAGE" ] | ||
|
||
} |
Oops, something went wrong.