8000 GitHub - pmeier/pytest-results-action: Summarize pytest test results in GitHub Actions
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pmeier/pytest-results-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

pytest-results-action

BSD-3-Clause License Project Status: WIP

pytest-results-action is a Javascript action for GitHub Actions to surface failing pytest 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 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.

- 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:

Example of report posted to the workflow summary by pytest-results-action. Under the title is a table that details the absolute and relative number of passed, skipped, xfailed, failed, xpassed, and errored tests. Below the table is a section for failed, errored, and xpassed tests. Each section includes the names of the respective test as well as the corresponding message. Only the details of the failed tests are visible.

About

Summarize pytest test results in GitHub Actions

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  
0