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.
A tutorial to learn how to use this action can be found here.
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.12"
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 are specified on the with
map of the action.
-
extensions: the
pytest
extensions to install alongpytest
(optional, by default no extensions are included) For example:- uses: dariocurr/pytest-summary@main with: extensions: pytest-asyncio pytest-cov
-
options
: thepytest
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 thepytest
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 defaulttests
) 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 defaultfail
) 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"
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.