Skip to content

Commit

Permalink
Show integration test results on the Action Summary (#13072)
Browse files Browse the repository at this point in the history
* Show summary on action results for failed test

* Write title and steps to log

* Log test

* Remove debugging

* Support python and java output

* Extra line break
  • Loading branch information
bleonard committed May 23, 2022
1 parent e56922f commit e82e6fc
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
body: |
> :white_check_mark: ${{github.event.inputs.connector}} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
${{env.PYTHON_UNITTEST_COVERAGE_REPORT}}
> ${{env.PYTHON_SHORT_TEST_SUMMARY_INFO}}
> ${{env.TEST_SUMMARY_INFO}}
- name: Add Failure Comment
if: github.event.inputs.comment-id && failure()
uses: peter-evans/create-or-update-comment@v1
Expand All @@ -168,7 +168,7 @@ jobs:
body: |
> :x: ${{github.event.inputs.connector}} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
> :bug: ${{env.GRADLE_SCAN_LINK}}
> ${{env.PYTHON_SHORT_TEST_SUMMARY_INFO}}
> ${{env.TEST_SUMMARY_INFO}}
# In case of self-hosted EC2 errors, remove this block.
stop-test-runner:
name: Stop Build EC2 Runner
Expand Down
100 changes: 86 additions & 14 deletions tools/bin/ci_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,93 @@ else
fi
}

show_skipped_failed_info() {
skipped_failed_info=`sed -n '/^=* short test summary info =*/,/^=* [0-9]/p' build.out`
if ! test -z "$skipped_failed_info"
then
echo "PYTHON_SHORT_TEST_SUMMARY_INFO<<EOF" >> $GITHUB_ENV
echo "Python short test summary info:" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$skipped_failed_info" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
else
echo "PYTHON_SHORT_TEST_SUMMARY_INFO=No skipped/failed tests"
show_python_run_details() {
run_info=`sed -n "/=* $1 =*/,/========/p" build.out`
if ! test -z "$run_info"
then
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$run_info" | sed '$d' >> $GITHUB_STEP_SUMMARY # $d removes last line
echo '```' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi
}

show_java_run_details() {
# show few lines after stack trace
run_info=`awk '/] FAILED/{x=NR+8}(NR<=x){print}' build.out`
if ! test -z "$run_info"
then
echo '```' >> $GITHUB_STEP_SUMMARY
echo "$run_info" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi
}

write_results_summary() {
echo "write_results_summary"
success="$1"
python_info=`sed -n '/=* short test summary info =*/,/========/p' build.out`
java_info=`sed -n '/tests completed,/p' build.out`

echo "success: $success"
echo "python_info: $python_info"
echo "java_info: $java_info"

info='Could not find result details'
result='Unknown result'

if [ "$success" = true ]
then
result="Build Passed"
info='All Passed'
echo '### Build Passed' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
else
result="Build Failed"
echo '### Build Failed' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi

if ! test -z "$java_info"
then
info="$java_info"

echo '```' >> $GITHUB_STEP_SUMMARY
echo "$java_info" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi
if ! test -z "$python_info"
then
info="$python_info"

echo '```' >> $GITHUB_STEP_SUMMARY
echo "$python_info" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
fi

echo "TEST_SUMMARY_INFO<<EOF" >> $GITHUB_ENV
echo "$result" >> $GITHUB_ENV
echo '' >> $GITHUB_ENV
echo "Test summary info:" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$info" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
}

write_logs() {
write_results_summary $1
show_python_run_details 'FAILURES'
show_python_run_details 'ERRORS'
show_java_run_details
}

echo "# $connector" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

# Copy command output to extract gradle scan link.
run | tee build.out
# return status of "run" command, not "tee"
Expand All @@ -70,11 +142,11 @@ test $run_status == "0" || {
# Save gradle scan link to github GRADLE_SCAN_LINK variable for next job.
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "GRADLE_SCAN_LINK=$link" >> $GITHUB_ENV
show_skipped_failed_info
write_logs false
exit $run_status
}

show_skipped_failed_info
write_logs true

# Build successed
coverage_report=`sed -n '/.*Name.*Stmts.*Miss.*Cover/,/TOTAL /p' build.out`
Expand Down

0 comments on commit e82e6fc

Please sign in to comment.