Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pmeier/pytest-results-action
Summarize `pytest` test results in GitHub Actions
https://github.com/pmeier/pytest-results-action
Last synced: 6 days ago
JSON representation
Summarize `pytest` test results in GitHub Actions
- Host: GitHub
- URL: https://github.com/pmeier/pytest-results-action
- Owner: pmeier
- License: bsd-3-clause
- Created: 2022-05-20T22:00:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T06:39:10.000Z (3 months ago)
- Last Synced: 2024-10-14T14:05:19.544Z (23 days ago)
- Language: JavaScript
- Size: 169 KB
- Stars: 13
- Watchers: 3
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `pytest-results-action`
[![BSD-3-Clause License](https://img.shields.io/github/license/pmeier/light-the-torch)](https://opensource.org/licenses/BSD-3-Clause)
[![Project Status: WIP](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)`pytest-results-action` is a Javascript action for [GitHub Actions](https://github.com/features/actions) to surface failing [`pytest`](https://docs.pytest.org) tests without crawling through logs.
## Why do I need it?
For all the awesomeness GitHub Actions brings, compared to other CI providers, logs above a few thousands lines load painfully slow. This can happen quite fast in larger test suites and is almost a given if one runs `pytest` in verbose mode, i.e. with `-v` set.
In addition to loading faster, other CI providers have an option to surface failing tests so there is no need to look at the logs in most cases. For example, on CircleCI using the builtin step [store_test_results](https://circleci.com/docs/collect-test-data/) is sufficient.
`pytest-results-action` aims to bring the same UX to GitHub Actions.
## How do I use it?
To be able to surface failing tests, `pytest-results-action` parses a JUnit XML file generated by `pytest`. For this the `--junit-xml` option needs to be set. The same value needs to be passed to the `path` input of `pytest-results-action`.
Since failing tests mean a non-zero exit code of `pytest`, `if: always()` needs to be set for `pytest-results-action` to run regardless.
```yaml
- name: Run tests
run: pytest --junit-xml=test-results.xml- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: test-results.xml# (Optional) Add a summary of the results at the top of the report
summary: true# (Optional) Select which results should be included in the report.
# Follows the same syntax as `pytest -r`
display-options: fEX# (Optional) Fail the workflow if no JUnit XML was found.
fail-on-empty: true# (Optional) Title of the test results section in the workflow summary
title: Test results
```The report will be posted to the workflow summary.