File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,8 @@ jobs:
101101 - name : Archive logs
102102 uses : actions/upload-artifact@v4
103103 with :
104- name : logs.zip
104+ name : logs-${{ matrix.name }} .zip
105105 path : .tox/**/log/
106- # https://github.com/actions/upload-artifact/issues/123
107- continue-on-error : true
108106
109107 - name : Report failure if git reports dirty status
110108 run : |
Original file line number Diff line number Diff line change @@ -47,6 +47,21 @@ You can disable regex check by defining `PYTEST_CHECK_TEST_ID_REGEX=0`.
4747
4848You can disable the length check by defining ` PYTEST_MAX_TEST_ID_LENGTH=0 ` .
4949
50+ ## Prepare pytest log files for collection on CI
51+
52+ As pytest log files are created on temp directory and some CI systems refuse
53+ to collect files from outside the current project, we do copy these files inside
54+ ` $VIRTUAL_ENV/log ` , same directory used by tox itself. To collect the logs on
55+ Github Actions, you only need a step like:
56+
57+ ``` yaml
58+ - name : Archive logs
59+ uses : actions/upload-artifact@v4
60+ with :
61+ name : logs-${{ matrix.name }}.zip
62+ path : .tox/**/log/
63+ ` ` `
64+
5065## Release process
5166
5267Releases are triggered from [GitHub Releases](https://github.com/pytest-dev/pytest-plus/releases)
Original file line number Diff line number Diff line change 33
44import os
55import re
6+ import shutil
67
78import pytest
89from _pytest .terminal import TerminalReporter
@@ -45,6 +46,16 @@ def pytest_sessionfinish(session: pytest.Session) -> None:
4546 )
4647 session .exitstatus = 1
4748
49+ # If running under CI (Github Actions included) and inside a venv, do
50+ # copy all pytest own logs inside $VIRTUAL_ENV/log, for collection.
51+ venv = os .environ .get ("VIRTUAL_ENV" , "" )
52+ if os .environ .get ("CI" , "0" ) != "0" and venv :
53+ shutil .copytree (
54+ src = session .config ._tmp_path_factory .getbasetemp (), # type: ignore[attr-defined] # noqa: SLF001
55+ dst = venv + "/log" ,
56+ dirs_exist_ok = True ,
57+ )
58+
4859
4960@pytest .hookimpl (tryfirst = True ) # type: ignore[misc,unused-ignore]
5061def pytest_collection_modifyitems (items : list [pytest .Item ]) -> None :
You can’t perform that action at this time.
0 commit comments