Skip to content
Permalink
Browse files

write a global comment report

  • Loading branch information
3nids authored and nyalldawson committed Feb 8, 2021
1 parent fa807e3 commit 5bcab8853877c79f28c1b558f18b7e950b34fec1
Showing with 49 additions and 10 deletions.
  1. +6 −2 .ci/config.ctest
  2. +43 −8 .github/workflows/run-tests.yml
@@ -66,7 +66,8 @@ IF(NOT IGNORE_BUILD_FAILURES)
MESSAGE("")
MESSAGE(" ${Yellow}Test results submitted to${ColorReset}")
MESSAGE(" ${BoldYellow}${SHORTURL}${ColorReset}")
# Github workflow output
# Github step output
MESSAGE("::set-output name=TESTS_PASS::false")
MESSAGE("::set-output name=CDASH_URL::${SHORTURL}")
MESSAGE("")
MESSAGE( FATAL_ERROR " ${Red}Build failed. Not running tests.${ColorReset}" )
@@ -79,7 +80,8 @@ IF(NOT ${NUMWARN} EQUAL 0 OR NOT ${TESTRES} EQUAL 0)
MESSAGE("")
MESSAGE(" ${Yellow}Test results submitted to${ColorReset}")
MESSAGE(" ${BoldYellow}${SHORTURL}${ColorReset}" )
# Github workflow output
# Github step output
MESSAGE("::set-output name=TESTS_PASS::false")
MESSAGE("::set-output name=CDASH_URL::${SHORTURL}")
MESSAGE("")
SET(LEVEL "")
@@ -101,4 +103,6 @@ IF(NOT ${TESTRES} EQUAL 0)
MESSAGE(" ${BoldGreen}Success${ColorReset}")
MESSAGE(" ${Green}All tests passed successfully.${ColorReset}")
MESSAGE("")
MESSAGE("::set-output name=TESTS_PASS::true")
MESSAGE("")
ENDIF(NOT ${TESTRES} EQUAL 0)
@@ -36,6 +36,7 @@ jobs:

outputs:
cdash_url: ${{ steps.unit-tests.outputs.CDASH_URL }}
tests_pass: ${{ steps.unit-tests.outputs.TESTS_PASS }}

steps:
- name: Checkout
@@ -156,19 +157,53 @@ jobs:
set -e # switch back
docker stop qgis-testing-environment
cdash-link:
name: Publish link to CDASH
tests-report-comment:
name: Write tests report in a comment
needs: build
runs-on: ubuntu-latest
if: failure() && github.event_name == 'pull_request'
if: ( needs.build.result == 'failure' || needs.build.result == 'success' ) && github.event_name == 'pull_request'
steps:
- run: echo "${{ needs.build.outputs.cdash_url }}"
- name: Find Comment
uses: peter-evans/find-comment@v1
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Tests report

- name: Create comment
uses: peter-evans/create-or-update-comment@v1.4.4
if: ${{ steps.find-comment.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v1
id: create-comment
with:
reactions: confused
issue-number: ${{ github.event.pull_request.number }}
body: |
Some tests are failing.
Tests results: ${{ needs.build.outputs.cdash_url }}
** Tests report **
- name: Process
id: process-vars
env:
- COMMENT_FOUND: ${{ steps.find-comment.outputs.comment-id }}
- COMMENT_CREATED: ${{ steps.create-comment.outputs.comment-id }}
- COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
- CDASH_URL: ${{ needs.build.outputs.cdash_url }}
- JOB_RESULT: ${{ needs.build.result }}
- TESTS_PASS: ${{ needs.build.outputs.tests_pass }}
run: |
echo "::set-output name=COMMENT_ID::"$([[ "${COMMENT_FOUND}" -eq "0" ]] && echo ${COMMENT_CREATED} || echo ${COMMENT_FOUND})
if [[ ${JOB_RESULT} -eq "success" ]]; then
echo "::set-output name=COMMENT_BODY::${COMMIT_SHA} unit-tests pass"
elif [[ ${TESTS_PASS} -eq "true" ]]; then
echo "::set-output name=COMMENT_BODY::${COMMIT_SHA} unit-tests pass but job failed!"
else
echo "::set-output name=COMMENT_BODY::${COMMIT_SHA} tests are failing: ${CDASH_URL}"
fi
- name: Update comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.process-vars.outputs.COMMENT_ID }}
edit-mode: append
body: ${{ steps.process-vars.outputs.COMMENT_BODY }}

0 comments on commit 5bcab88

Please sign in to comment.