Generate Test Report #269
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# GitHub Actions workflow: Generates a test report (annotations and summary HTML) for a CI run. | |
# | |
# NOTE: We need this separate workflow because the test-reporter step below requires the "checks: write" | |
# permission - which, for security reasons, is not available for pull requests from forks (for details, | |
# see link at the 'permissions' property below). Follow-up workflows (triggered by "on.workflow_run") | |
# have full permissions - and thus we can circumvent this problem. | |
# | |
# However, to prevent attackers from simply using this trick in a pull request, GitHub Actions only | |
# uses the file contents from the default branch for follow-up workflows. This means, you can't experiment | |
# with this file in a pull request but have to do this on the main branch. | |
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run | |
# | |
# IMPORTANT: Due to a GitHub limitation, test reports are associated with the commit sha rather than | |
# a workflow run. This means, if there are multiple runs for the same sha (e.g. from scheduled | |
# workflow when the repo has changed between two runs), the test result will end up in a "random" | |
# workflow run. At least you can see the report's URL in the output of the "Create test report" | |
# step. For more details, see: https://github.com/dorny/test-reporter/issues/67 | |
# | |
# For more details on workflows, see README.md. | |
# | |
name: 'Generate Test Report' | |
# When to run this workflow | |
# | |
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows | |
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on | |
# | |
# TIP: Don't use "schedule" triggers as this will cause the workflow to be disabled after 60 days of inactivity | |
# (and afterward the workflow must be manually reenabled). | |
on: | |
workflow_run: | |
# Runs after CI workflow. | |
# NOTE: The name here is the value of the 'name' property of the | |
# workflow - NOT the name of the file. | |
workflows: ['CI'] | |
types: | |
- completed | |
# Permissions for GITHUB_TOKEN for this workflow. | |
# | |
# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token | |
permissions: | |
contents: read | |
# The test report is uploaded as a "Check" | |
checks: write | |
# NOTE: Jobs run in parallel by default. | |
# https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow | |
jobs: | |
report: | |
# Name of the job | |
name: Test Report | |
# Set the type of machine to run on | |
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
runs-on: ubuntu-latest | |
steps: | |
# See: https://github.com/marketplace/actions/test-reporter | |
- name: Create test report | |
# For pinned versions, see: https://blog.gitguardian.com/github-actions-security-cheat-sheet/#use-specific-action-version-tags | |
uses: dorny/test-reporter@eaa763f6ffc21c7a37837f56cd5f9737f27fc6c8 # version 1.8.0 | |
with: | |
# NOTE: We add the 'github.run_number' to the name so that we can easier identify the | |
# test report if they pile up due to bug https://github.com/dorny/test-reporter/issues/67. | |
# See top of this file for more details. | |
name: 'Test Report #${{ github.run_number }}' | |
# The name of the artifact (minus extension) created by the CI workflow. | |
artifact: /test-results-(.*)/ | |
# Path to test results (inside artifact .zip) | |
path: '**/*.trx' | |
# Format of test results | |
reporter: dotnet-trx | |
# Don't mark the test report generated as failed if there's a failed test. | |
# Only mark it as failed if something with the workflow has actually gone wrong. | |
fail-on-error: false |