Extract test results when there are failures
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
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.
Related to gradle/gradle-build-action#98
Is this Kotlin MPP specific? Build scans contain JUnit test results.
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...)
I think it would be nice to at least document the solution