Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.