deskflow/.github/actions/run-tests/action.yml
Nick Bolton 13bf2dace4
Only add PR comments for internal PR (#7448)
* Add write permission for issues

* Add write permission to PRs

* Update ChangeLog

* Fixed ChangeLog version

* Correct ChangeLog

* Remove GITHUB_TOKEN input

* Revert "Remove GITHUB_TOKEN input"

This reverts commit e868a8d3f4.

* Use COMMENT_PAT for GITHUB_TOKEN

* Use default permissions

* Only use `sticky-pull-request-comment` for internal PRs

* Update ChangeLog
2024-08-23 10:38:17 +01:00

63 lines
1.7 KiB
YAML

name: "Run tests"
description: "Runs both unit tests and integration tests and appends to a PR comment"
inputs:
job:
description: "The job name to append to the PR comment"
default: "unknown"
runs:
using: "composite"
steps:
- name: Unit tests
id: unittests
env:
QT_QPA_PLATFORM: offscreen
run: ./build/bin/unittests
shell: bash
continue-on-error: true
- name: Integration tests
id: integtests
env:
QT_QPA_PLATFORM: offscreen
run: |
./build/bin/integtests
result=$?
if [ $result -ne 0 ]; then
echo "::warning ::Integration tests failed with code: $result"
fi
shell: bash
continue-on-error: true
- name: Get test results
id: results
run: |
pass="✅ Pass"
fail="❌ Fail"
unittests_outcome="${{ steps.unittests.outcome }}"
integtests_outcome="${{ steps.integtests.outcome }}"
unittests=$( [ "$unittests_outcome" = "success" ] && echo $pass || echo $fail )
integtests=$( [ "$integtests_outcome" = "success" ] && echo $pass || echo $fail )
echo "unittests=$unittests" >> $GITHUB_OUTPUT
echo "integtests=$integtests" >> $GITHUB_OUTPUT
shell: bash
- name: Append to PR comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event.pull_request.head.repo.full_name == github.repository
with:
header: tests
append: true
message: |
| ${{ inputs.job }} | ${{ steps.results.outputs.unittests }} | ${{ steps.results.outputs.integtests }} |
- name: Check test outcome
if: steps.unittests.outcome == 'failure'
run: |
echo "Unit tests failed"
exit 1
shell: bash