Make attach paths relative and upload the output contents
Attach should be relative to CI_PROJECT_DIR
This commit is contained in:
parent
caf09dc85e
commit
82d4bfac75
|
@ -27,13 +27,13 @@
|
|||
- ctest -R qa_${TEST}
|
||||
# GitLab supports displaying the results in the GUI through JUNIT artifacts
|
||||
# (https://docs.gitlab.com/ee/ci/junit_test_reports.html)
|
||||
# so we upload the JUNIT results. Note that there is a bug with how paths
|
||||
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/issues/23835)
|
||||
# so we can't use a glob and have to list out each hierarchy separately.
|
||||
# so we upload the JUNIT results.
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- build/linux/qa/**/*.log
|
||||
- build/linux/qa/**/output/*
|
||||
- build/linux/qa/**/*.xml
|
||||
reports:
|
||||
junit:
|
||||
- build/linux/qa/**/*.xml
|
|
@ -25,14 +25,25 @@ import os
|
|||
from pathlib import Path
|
||||
|
||||
class KiTestFixture:
|
||||
junit: bool = False
|
||||
_output_path: Path = None
|
||||
_junit_folder: Path = None
|
||||
_ci_project_dir: Path = None
|
||||
|
||||
def __init__( self, config ) -> None:
|
||||
self._junit = False
|
||||
|
||||
env_project_dir = os.getenv( 'CI_PROJECT_DIR' )
|
||||
if env_project_dir is not None:
|
||||
self._ci_project_dir = Path( env_project_dir )
|
||||
|
||||
junitxml = config.getoption("xmlpath")
|
||||
|
||||
if junitxml is not None:
|
||||
p = Path( junitxml )
|
||||
p = Path( p.parent ) # get the directory as junitxml points to a file
|
||||
p = p.resolve() # get absolute path
|
||||
self._junit_folder = p
|
||||
self._junit = True
|
||||
else:
|
||||
p = Path.cwd()
|
||||
|
@ -59,8 +70,19 @@ class KiTestFixture:
|
|||
def add_attachment( self, path: str ) -> None:
|
||||
"""Prints the attachment message line for junit reports"""
|
||||
|
||||
if self._junit:
|
||||
print( "[[ATTACHMENT|{}]]".format( path ) )
|
||||
if not self._junit:
|
||||
return
|
||||
|
||||
# Make the attachment path relative, gitlab in particular wants it
|
||||
# relative tot he CI_PROJECT_DIR variable
|
||||
attach_src_path = Path( path )
|
||||
attach_path: Path = None
|
||||
if self._ci_project_dir is not None:
|
||||
attach_path = attach_src_path.relative_to( self._ci_project_dir )
|
||||
else:
|
||||
attach_path = attach_src_path.relative_to( self._junit_folder )
|
||||
|
||||
print( "[[ATTACHMENT|{}]]".format( str( attach_path ) ) )
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
Loading…
Reference in New Issue