Skip to content

Commit

Permalink
ci: add dut_log_url column to failed testcases report
Browse files Browse the repository at this point in the history
Introduced changes:
- add xml attribute "dut_log_url" to pytest report
- add column "dut_log_url" to failed testcases table of dynamic pipeline report
- make the table header sticky
- add permalinks to the Table Titles
- split target test report by testcase type for better clarity
- fix the logic of finding the testcases failed on cur branch / other branches
  • Loading branch information
alekseiapa committed Jul 17, 2024
1 parent 7d3ac1a commit cd59d96
Show file tree
Hide file tree
Showing 12 changed files with 531 additions and 202 deletions.
1 change: 1 addition & 0 deletions .gitlab/ci/post_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ generate_failed_jobs_report:
tags: [build, shiny]
image: $ESP_ENV_IMAGE
when: always
dependencies: [] # Do not download artifacts from the previous stages
artifacts:
expire_in: 1 week
when: always
Expand Down
28 changes: 28 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,34 @@ def set_test_case_name(request: FixtureRequest, test_case_name: str) -> None:
request.node.funcargs['test_case_name'] = test_case_name


@pytest.fixture(autouse=True)
def set_dut_log_url(record_xml_attribute: t.Callable[[str, object], None], _pexpect_logfile: str) -> t.Generator:
# Record the "dut_log_url" attribute in the XML report once test execution finished
yield

if not isinstance(_pexpect_logfile, str):
record_xml_attribute('dut_log_url', 'No log URL found')
return

ci_pages_url = os.getenv('CI_PAGES_URL')
logdir_pattern = re.compile(rf'({DEFAULT_LOGDIR}/.*)')
match = logdir_pattern.search(_pexpect_logfile)

if not match:
record_xml_attribute('dut_log_url', 'No log URL found')
return

if not ci_pages_url:
record_xml_attribute('dut_log_url', _pexpect_logfile)
return

job_id = os.getenv('CI_JOB_ID', '0')
modified_ci_pages_url = ci_pages_url.replace('esp-idf', '-/esp-idf')
log_url = f'{modified_ci_pages_url}/-/jobs/{job_id}/artifacts/{match.group(1)}'

record_xml_attribute('dut_log_url', log_url)


######################
# Log Util Functions #
######################
Expand Down
1 change: 1 addition & 0 deletions tools/ci/dynamic_pipelines/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def from_test_case_node(cls, node: Element) -> t.Optional['TestCase']:
'time': float(node.attrib.get('time') or 0),
'ci_job_url': node.attrib.get('ci_job_url') or '',
'ci_dashboard_url': f'{grafana_base_url}?{encoded_params}',
'dut_log_url': node.attrib.get('dut_log_url') or 'Not found',
}

failure_node = node.find('failure')
Expand Down
Loading

0 comments on commit cd59d96

Please sign in to comment.