EnricoMi / publish-unit-test-result-action

GitHub Action to publish unit test results on GitHub
Apache License 2.0
601 stars 178 forks source link

Spectral junit report has wrong paths to OpenAPI spec file #590

Open chilcano opened 5 months ago

chilcano commented 5 months ago

Hello, I'm using Spectral CLI from Github Actions to lint OpenAPI spec files. Once triggered, it generates reports in different formats, even JUnit, which I do use from EnricoMi/publish-unit-test-result-action to publish it as Annotations in Github Action Summary.

The EnricoMi/publish-unit-test-result-action publishes successfully the report as annotations in the Summary view and in the Check runs view. However, the paths and links are wrong and if I click on any of them, it is redirected to Github Code showing the diff view.

I would like to publish the Spectral junit report as annotations with the right paths and links where after clicking on these links i can view the current OpenAPI spec file showing the error or warning in the right line. I've tried test_file_prefix without success.

spectral-junit-1 spectral-junit-2-goto-check-runs-view spectral-junit-3-goto-code-view

In this case, what is the expected junit format what should be used to show the OpenAPI spec file in Github Code view with the specific annotation for the corresponding line like EnricoMi/publish-unit-test-result-action shows in its documentation (https://github.com/EnricoMi/publish-unit-test-result-action?tab=readme-ov-file#commit-and-pull-request-annotations)

I appreciate your ideas and support. Kind regards.

EnricoMi commented 4 months ago

I cannot see a file name in your example XML, which is why the links do not work as expected. The <testcase> tags need a file attribute that points to the file that cause the test failure. Ideally, you also have the line attribute. I think those information are currently contained in the <failure> CDATA content. That has to be used to populate file and line.

Here is an example: https://github.com/EnricoMi/publish-unit-test-result-action/blob/master/python/test/files/junit-xml/testsuite-root.xml

EnricoMi commented 4 months ago

Spectral junit report might benefit from this feature..

chilcano commented 4 months ago

Thanks @EnricoMi Let me generate a junit file with the expected format. I'll come back to you with my findings.

Regards.