actions icon indicating copy to clipboard operation
actions copied to clipboard

Extract test results when there are failures

Open LouisCAD opened this issue 2 years ago • 5 comments

Hello,

When tests fail in CI, here's what I get:

* What went wrong:
Execution failed for task ':module:allTests'.
> There were failing tests. See the report at: file:///home/runner/work/user/project/module/build/reports/tests/allTests/index.html

This is so unhelpful as the runner deletes everything on exit, and you won't find the test failure report in the Gradle scan…

Can you extract the containing directory as a downloadable GitHub Action run artifact if it has files, so that we can actually find out why the tests failed in CI?

I find it hard to believe that I'd be the first one encountering this issue, but I'll accept the truth.

Thank you and have a great day!

Louis CAD

LouisCAD avatar Mar 02 '23 23:03 LouisCAD

I use something similar to the following in my workflows:

      - name: Store reports
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: reports
          path: |
            **/build/reports/
            **/build/test-results/

See https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

Note that the name is important if you have more than one Gradle invocation in the whole workflow (e.g. in a matrix build). Also, what if you setup Gradle using the action, then run Gradle twice, e.g., with different project properties, in the same job; how should the gradle-build-action archive those? Under which names? Should it archive only on failure? It's sometimes useful to check successful reports to see which tests were ignored and which were run.

To me, that's not the role of the gradle-build-action to do that, or that'll require it to be much more complex, if only in configurability.

tbroyer avatar Mar 03 '23 09:03 tbroyer

Related to gradle/gradle-build-action#98

bigdaz avatar Mar 30 '23 15:03 bigdaz

Is this Kotlin MPP specific? Build scans contain JUnit test results.

hfhbd avatar May 15 '23 14:05 hfhbd

PS: There are other OSS actions available already, maybe it's sufficient to provide references?

  • https://github.com/marketplace/actions/junit-report-action
  • https://github.com/marketplace/actions/test-reporter

(there may be others...)

hartmut-co-uk avatar Sep 18 '23 13:09 hartmut-co-uk

I think it would be nice to at least document the solution

oleg-nenashev avatar Mar 11 '24 12:03 oleg-nenashev