cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.8k stars 3.17k forks source link

GitHub Actions Cypress formatter for better output #29786

Open Splines opened 3 months ago

Splines commented 3 months ago

What would you like?

GitHub Actions are widely adopted. They offer so-called workflow commands (a special log syntax) to show warning/error messages directly in the GitHub UI. This is awesome as you will see the warnings/errors in the summary of your last run and directly in the Files changed tab in pull requests. As an example, consider this image:

The preferred way to specify this formatter would be:

cypress run --format github

Why is this needed?

This feature would be great to ease seeing which Cypress tests failed in a GitHub Actions pipeline. It would be really nice to have the failing tests marked as "failing" directly in the Files changed tab (you may also mark files there that weren't changed in a pull request). But even more advantageous, the Summary tab in your GitHub Action runs will give you a summary of which tests failed, without you having to drill down to the specific GitHub Action task that executed cypress run.

Other

Note that other libraries have a GitHub formatter available:

MikeMcC399 commented 3 months ago

@Splines

Reading your enhancement request, I was uncertain whether you were familiar with the existing JavaScript Action from Cypress.io. The Cypress solution for GitHub Actions is described in https://docs.cypress.io/guides/continuous-integration/github-actions with repo https://github.com/cypress-io/github-action.

Splines commented 3 months ago

Thanks for pointing me to that documentation. I've already seen the action, however, we wanted to use Docker Buildx with GitHub container registry as seen in our workflow file. The cypress run command is finally issued in the entrypoint here. We do make use of your pre-built Docker images though (FROM cypress/included:13.11.0).

Having seen that your GitHub action even provides nice job summaries, we might rethink our Dockerfile and try to switch to your GitHub action. From the documentation, it's not clear to me whether you generate annotations for failed jobs that are shown on the same level as the job summary and also in the Files changed tab right next to the line that made a Cypress test fail.

MikeMcC399 commented 3 months ago

@Splines

cypress-io/github-action does not provide any annotations apart from the statistical summary of job outcome.

Cypress Cloud with Test Replay is the tool of choice for tracking down and resolving individual test failures. See also Using Cypress Cloud with GitHub Actions.