File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
pytest_github_actions_annotate_failures Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
name : test
2
2
3
3
on :
4
+ workflow_dispatch :
4
5
push :
5
6
branches :
6
7
- master
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ def test_fail():
86
86
'''
87
87
)
88
88
testdir .monkeypatch .setenv ('GITHUB_ACTIONS' , 'true' )
89
+ testdir .monkeypatch .setenv ('GITHUB_WORKSPACE' , os .path .dirname (str (testdir .tmpdir )))
89
90
testdir .mkdir ('foo' )
90
91
testdir .makefile ('.ini' , pytest = '[pytest]\n testpaths=..' )
91
92
result = testdir .runpytest_subprocess ('--rootdir=foo' )
Original file line number Diff line number Diff line change @@ -11,8 +11,15 @@ def pytest_runtest_logreport(report):
11
11
return
12
12
13
13
# collect information to be annotated
14
- filesystem_relativepath , lineno , _ = report .location
15
- filesystempath = filesystem_relativepath .replace ('../' , '' )
14
+ filesystempath , lineno , _ = report .location
15
+
16
+ # try to convert to absolute path in GitHub Actions
17
+ workspace = os .environ .get ('GITHUB_WORKSPACE' )
18
+ if workspace :
19
+ full_path = os .path .abspath (filesystempath )
20
+ rel_path = os .path .relpath (full_path , workspace )
21
+ if not rel_path .startswith ('..' ):
22
+ filesystempath = rel_path
16
23
17
24
# 0-index to 1-index
18
25
lineno += 1
You can’t perform that action at this time.
0 commit comments