Skip to content

dariocurr/pytest-summary

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

Workflow badge

Example summary

This action is just an extension of the test-summary action

Run your pytests and produce an easy-to-read summary as part of your GitHub Actions CI/CD workflow. This helps you understand at-a-glance the impact to the changes in your pull requests, and see which changes are introducing new problems.

Pillars:

  • Integrates tests easily with your existing GitHub Actions workflow
  • Produces summaries from pytest output
  • Customizable to show just a summary, just failed tests, or all test results.

Tutorial

A tutorial to learn how to use this action can be found here.


Getting Started

This action requires a python set up before its usage (e.g setup-python). For example:

- name: Set up Python
  uses: actions/setup-python@main
  with:
    python-version: "3.10"

To set up the pytest summary action, just add the following line of YAML to your GitHub Actions workflow:

-  uses: dariocurr/pytest-summary@main

Options

Options are specified on the with map of the action.

  • extensions: the pytest extensions to install along pytest (optional, by default no extensions are included) For example:

    - uses: dariocurr/pytest-summary@main
      with:
        extensions: pytest-asyncio pytest-cov
  • options: the pytest options (optional, by default no options are include) To specify them correctly, please have a look here. For example:

    - uses: dariocurr/pytest-summary@main
      with:
        options: -vv -s
  • output: the path where to create the output (optional, by default the output will be the workflow summary) The path to the GitHub-flavored Markdown (GFM) output file to populate with the pytest summary markdown data. For example:

    - uses: dariocurr/pytest-summary@main
      with:
        output: test-summary.md
  • paths: the path to the folders or files containing the tests (optional, by default tests) You can specify glob patterns, including ** to match the pattern recursively or specify multiple test paths on multiple lines. For example:

    uses: dariocurr/pytest-summary@main
    with:
      paths: tests/**.py

    or

    uses: dariocurr/pytest-summary@main
    with:
      paths: |
        tests/test_file_1.py \
        tests/test_file_2.py
  • show: which tests have to be shown in the summary (optional, by default fail) This controls whether a test summary table is created or not, as well as what tests are included. It could be all, none, pass, skip, or fail. The default is fail - that is, the summary table will only show the failed tests. For example, if you wanted to show failed and skipped tests:

    uses: dariocurr/pytest-summary@main
    with:
      show: "fail, skip"

Upload the markdown

The pytest-summary step generates a summary in GitHub-flavored Markdown (GFM). Once the markdown is generated, you can upload it as a build artifact, add it to a pull request comment, or add it to an issue. For example, to upload the markdown generated in the prior example as a build artifact:

- name: Upload test summary
  uses: actions/upload-artifact@v3
  with:
    name: test-summary
    path: test-summary.md
  if: always()

Note the if: always() conditional in this workflow step: you should always use this so that the test summary creation step runs even if the previous steps have failed. This allows your test step to fail -- due to failing tests -- but still produce a test summary.

About

Show a helpful summary of pytest results in GitHub Actions CI/CD workflow runs

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages