Navigation Menu

Skip to content

Commit

Permalink
write a global comment report
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and nyalldawson committed Feb 8, 2021
1 parent fa807e3 commit 5bcab88
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
8 changes: 6 additions & 2 deletions .ci/config.ctest
Expand Up @@ -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}" )
Expand All @@ -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 "")
Expand All @@ -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)
51 changes: 43 additions & 8 deletions .github/workflows/run-tests.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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.