Skip to content

Reports JUnit, Android Lint, Detekt and any other CheckStyle compatible XML reports as GitHub Actions annotations. Mostly targeting Gradle builds

License

Notifications You must be signed in to change notification settings

gmazzo/publish-report-annotations

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Latest Build Status codecov Users

publish-report-annotations

Reports JUnit, Android Lint, Detekt and any other CheckStyle compatible XML reports as GitHub Actions annotations. Mostly targeting Gradle builds

JUnit's reports

junit

Checkstyle (and compatibles, like Detekt)s reports

checkstyle/detekt

Android Lint's reports

android lint

Detailed logs

logs

Summaries

PR status check

Test Suites ✅ 93 passed 🟡 1 skipped ❌ 4 failed ⌛ took
✅ org.test.sample.AnotherTestSuite
  • ✅ aTest[maxDuration=100] (⌛ 0.054)
  • ✅ aTest[maxDuration=200] (⌛ 0.107)
  • ✅ aTest[maxDuration=300] (⌛ 0.238)
  • ✅ aTest[maxDuration=400] (⌛ 0.103)
4 0 0 0.506
❌ org.test.sample.FlakyFailingTestSuite
  • ❌ failingTest() (⌛ 0.011)
0 0 1 2.07
❎❗org.test.sample.FlakyTestSuite 1
  • ❎❗1flakyTest() (⌛ 0.005)
1 0 0 1.295
❌ org.test.sample.SampleTestSuite
  • 🟡 a test skipped() (⌛ 0)
  • ❌ a test that fails() (⌛ 0.002)
  • ✅ a test that passes() (⌛ 0.001)
  • ❌ a test that throws an exception() (⌛ 0.001)
1 1 2 0.004
detekt 🛑 0 errors ⚠️ 1 warning 💡 0 others
NewLineAtEndOfFile 0 1 0
Android Lint 🛑 0 errors ⚠️ 1 warning 💡 0 others
Correctness / GradleDependency 0 1 0

Usage

On your workflow file add:

steps:
  - name: Run Gradle build
    run: ./gradlew build # this is an example
  - name: Report build results
    uses: gmazzo/publish-report-annotations@v1 # target latest major
    if: ${{ !cancelled() }}

Configuration

option usage default
token The GitHub token to use to create a check (with checks: write permission).

Only required if checkName is also set
${{ github.token }}
appId and appSecret The GitHub App pairs (ID and prvate key) to use to create a check (with checks: write permission).

The app needs to be installed in the repo and with pull_request: read and checks: write permissions

Only required if checkName is also set and token is not set
None (uses token if set)
checkName The name of the check to create.
If not set, no check will be created and annotations will be reported to the workflow run
None (reports to workflow run)
workflowSummary Whether to report the summary to the running workflow or not.
Force workflowSummary: true in conjunction with checkName to have the summary reported on both, the workflow's run and the check
true if checkName is not set, or false otherwise
reports A multiple line list of globs pattern to look for reports **/build/test-results/**/*.xml
**/build/reports/**/*.xml
**/build/outputs/androidTest-results/**/*.xml
testsSummary The kind of summary to report for tests:
  • full
    Reports all test suites with their test casses
  • suitesOnly
    Reports all test suites aggregating outcome of its tests cases, but without reporting the test cases itself
  • totals
    Reports aggregated totals of all suites
  • off
    Does not report any test to the summary

⚠️ Keep in mind on large builds, it may reach the GitHub's limit (65535 characters) on large builds. Try reducing the level of details if that's the case
full
checksSummary The kind of summary to report into the checks
  • full
    Reports all the checks, one table per check type
  • off
    Does not report any checks to the summary
full
filterPassedTests To reduce verbosity (and summary size), skips tests (suites and cases) that has ✅ passed from reporting into the summary false
filterChecks Reports only check's annotations coming from files that have been changed in the PR (does not affect to tests) false
detectFlakyTests Enables support for flaky tests detection (assumed the ones with the same classname and name are retries of the same test).

If at least once execution of them passes, then the overall outcome will considered passed. The suite will be reported as flaky as well and the last failure will annotated as a warning
false
warningsAsErrors If any warning is reported should count as an error. Mostly used in conjunction with failOnError false
failOnError If the action should fail if any error is reported false

Advanced reporting as a GitHub App (if appId and appSecret are not enough)

When checkName is set, a new check-run will be created by this actions. If you provide appId and appSecret it will be used to resolve an installation token to impersonate the action as a GitHub App.

If this is not enough for your needs, you can rely on the official create-github-app-token:

    steps:
      - uses: actions/create-github-app-token@v1
        id: app-token
        with:
          app-id: ${{ vars.APP_ID }}
          private-key: ${{ secrets.PRIVATE_KEY }}
      - uses: gmazzo/publish-report-annotations@v1
        with:
          token: ${{ steps.app-token.outputs.token }}

For further references about how to acquire a GitHub App installation token, check the former action documentation.

Outputs

The action will output the number of errors and warnings found in the reports, aggregated by tests, checks and totals:

output description example
tests The totals of tests
{ "count": 8, "passed": 4, "errors": 0, "skipped": 2, "failed": 2 }
checks The totals of checks
{ "count": 12, "errors": 6, "warnings": 4, "others": 2 }
total The aggregated totals
{ "errors": 20, "warnings": 8, "others": 12 }

Footnotes

  1. ❎❗flaky test (some executions have passed, others have failed) 2

About

Reports JUnit, Android Lint, Detekt and any other CheckStyle compatible XML reports as GitHub Actions annotations. Mostly targeting Gradle builds

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages