From c1a8d1d4e4c60c9e76a43afe833d71fc62baab55 Mon Sep 17 00:00:00 2001 From: Laurents Meyer Date: Thu, 26 Oct 2023 20:55:03 +0200 Subject: [PATCH] Publish test results as GitHub Checks. --- .github/workflows/test_results.yml | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/test_results.yml diff --git a/.github/workflows/test_results.yml b/.github/workflows/test_results.yml new file mode 100644 index 0000000..846c3c5 --- /dev/null +++ b/.github/workflows/test_results.yml @@ -0,0 +1,43 @@ +name: ReportTestResults +on: + workflow_run: + workflows: + - PullRequest + types: + - completed +permissions: + contents: read + actions: read + checks: write +jobs: + Report: + runs-on: ubuntu-latest + steps: + - name: 'Check Artifact' + id: CheckArtifact + uses: actions/github-script@v6 + with: + script: | + var allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + + var testResultsArtifacts = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "test-results" + }); + + if (testResultsArtifacts.length > 0) { + core.setOutput('testResultsArtifactAvailable', 'true'); + console.log('Test results artifact found.') + } + - name: 'Publish Test Report' + if: steps.CheckArtifact.outputs.testResultsArtifactAvailable == 'true' + uses: dorny/test-reporter@v1 + with: + name: 'All Tests' + artifact: test-results + path: '**/*.trx' + reporter: dotnet-trx + fail-on-error: false