Create an issue for failed tests from a pytest-reportlog file or update an existing one if it already exists.
How this works:
pytest-reportlogwrites a complete and machine-readable log of failed tests.- The action extracts the failed tests and creates a report while making sure that it fits into the character limits of github issue forms.
- The action looks for existing open issues with the configured title and label a. if one exists: replace the old description with the report b. if there is none: open a new issue and insert the report
To use the issue-from-pytest-log action in workflows, simply add a new step:
Important
The action won't run properly unless the issues: write permission is requested as
shown below.
permissions: {}jobs:
my-job:
...strategy:
fail-fast: false......
- uses: actions/setup-python@v4with:
python-version: "3.12"cache: pip...
- run: | pip install --upgrade pytest-reportlog...
- run: | pytest --report-log pytest-log.jsonl - uses: actions/upload-artifact@...with:
name: log filepath: pytest-log-jsonlcreate-issue:
needs: my-jobruns-on: ubuntu-latestpermissions:
issues: writesteps:
- uses: actions/download-artifact@...with:
name: log filepath: logs/
- uses: scientific-python/issue-from-pytest-log-action@f94477e45ef40e4403d7585ba639a9a3bcc53d43 # v1.3.0if: | failure() && ...with:
log-path: logs/pytest-log.jsonlTip
In the example above, the action is in a separate job from the test run to avoid giving untrusted code (typically nightly dependencies) access to a token that can modify the repository. This is good practice to reduce the risk of supply-chain attacks.
See this repository for example issues. For more realistic examples, see
xarray(workflow, example issue)dask(workflow, example issue)
required.
Use log-path to specify where the output of pytest-reportlog is.
Note
If the log file is missing (for example, because the workflow failed before pytest was
run), the action will still open / update, but the issue won't contain details about the
exact failure.
optional. Default: ⚠️ Nightly upstream-dev CI failed ⚠️
In case you don't like the default title for new issues, this setting can be used to set a different one:
- uses: scientific-python/issue-from-pytest-log-action@f94477e45ef40e4403d7585ba639a9a3bcc53d43 # v1.3.0with:
log-path: pytest-log.jsonlissue-title: "Nightly CI failed"The title can also be parametrized, in which case a separate issue will be opened for each variation of the title.
optional. Default: CI
The label to set on the new issue.
- uses: scientific-python/issue-from-pytest-log-action@f94477e45ef40e4403d7585ba639a9a3bcc53d43 # v1.3.0with:
log-path: pytest-log.jsonlissue-label: "CI"optional. A comma-separated list of users.
Any assignees to set on the new issue:
- uses: scientific-python/issue-from-pytest-log-action@f94477e45ef40e4403d7585ba639a9a3bcc53d43 # v1.3.0with:
log-path: pytest-log.jsonlassignees: user1,user2Important
Note that assignees must have the commit bit on the repository.