Skip to content

Add support for uploading run level failure logs#56

Open
hi-rai wants to merge 1 commit intomainfrom
dev/himanshu/run-failure-logs
Open

Add support for uploading run level failure logs#56
hi-rai wants to merge 1 commit intomainfrom
dev/himanshu/run-failure-logs

Conversation

@hi-rai
Copy link
Contributor

@hi-rai hi-rai commented Mar 3, 2026

@hi-rai hi-rai self-assigned this Mar 3, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the QA Sphere CLI's reporting capabilities by enabling the upload of run-level failure logs. Previously, only individual test case results were captured. Now, the system can identify and report broader issues, such as setup or teardown failures, that impact an entire test run rather than a specific test. This provides a more comprehensive view of test execution health by ensuring that critical, non-test-case-specific errors are not overlooked.

Highlights

  • Run-Level Log Upload: Introduced functionality to detect and upload global or suite-level failure logs (e.g., setup/teardown errors) from JUnit XML and Playwright JSON reports to QA Sphere.
  • API Extension: Added a new API endpoint (createRunLog) to facilitate the upload of these run-level failure logs.
  • Parser Enhancements: Modified JUnit XML and Playwright JSON parsers to extract relevant error information as run-level logs, distinguishing them from individual test case results.
  • Upload Workflow Integration: Updated the ResultUploadCommandHandler to collect run-level logs from all parsed files and the ResultUploader to send these logs to the new API endpoint before uploading test case results.
  • Documentation Updates: The README.md and CLAUDE.md files have been updated to reflect the new run-level log feature and its detection mechanisms.
Changelog
  • CLAUDE.md
    • Updated documentation for ResultUploadCommandHandler to reflect ParseResult objects and run-level log collection.
    • Updated documentation for ResultUploader to include uploading run-level logs.
    • Updated documentation for junitXmlParser.ts and playwrightJsonParser.ts to describe run-level error log extraction.
  • README.md
    • Added a new section 'Run-Level Logs' explaining the automatic detection and upload of global/suite-level failures.
    • Detailed how JUnit XML and Playwright JSON reports contribute to run-level logs.
  • src/api/run.ts
    • Added CreateRunLogRequest interface for run log creation.
    • Implemented createRunLog API method to post run-level logs to a specific run.
  • src/tests/fixtures/junit-xml/suite-level-errors.xml
    • Added a new JUnit XML fixture demonstrating suite-level errors and empty-name test cases.
  • src/tests/junit-xml-parsing.spec.ts
    • Modified existing tests to destructure ParseResult objects from parseJUnitXml.
    • Added tests to verify that runFailureLogs are empty when no suite-level errors exist.
    • Added tests to confirm extraction of suite-level <system-err> into runFailureLogs.
    • Added tests to ensure empty-name test case errors are extracted into runFailureLogs and excluded from testCaseResults.
  • src/tests/playwright-json-parsing.spec.ts
    • Modified existing tests to destructure ParseResult objects from parsePlaywrightJson.
    • Added tests to verify that runFailureLogs are empty when no top-level errors exist.
    • Added tests to confirm extraction of top-level Playwright JSON errors into runFailureLogs.
    • Added tests to ensure ANSI codes are stripped from top-level errors when extracted into runFailureLogs.
  • src/tests/result-upload.spec.ts
    • Added a mock API handler for the new createRunLog endpoint.
    • Added countRunLogApiCalls helper to track calls to the run log API.
    • Added tests to verify that run-level logs are uploaded when suite-level errors exist.
    • Added tests to confirm that run-level logs are not uploaded when no suite-level errors are present.
  • src/utils/result-upload/ResultUploadCommandHandler.ts
    • Updated Parser type definition to return ParseResult instead of TestCaseResult[].
    • Modified FileResults interface to include runFailureLogs.
    • Adjusted uploadResults method to accept and pass runFailureLogs to the ResultUploader.
    • Updated parseFiles method to correctly process ParseResult and store runFailureLogs.
    • Modified the check for 'No valid test cases found' to also consider the presence of runFailureLogs.
  • src/utils/result-upload/ResultUploader.ts
    • Modified handle method to accept an optional runFailureLogs string.
    • Implemented logic to call api.runs.createRunLog if runFailureLogs are provided, uploading them before test case results.
  • src/utils/result-upload/junitXmlParser.ts
    • Updated comments regarding JUnit XML schema variants.
    • Introduced systemErrOutSchema for consistent parsing of system error/output elements.
    • Modified parseJUnitXml to return a ParseResult object containing testCaseResults and runFailureLogs.
    • Implemented logic to extract suite-level <system-err> content into runFailureLogParts.
    • Implemented logic to identify and extract errors from empty-name <testcase> elements (e.g., Maven Surefire setup failures) into runFailureLogParts, excluding them from testCaseResults.
    • Enhanced getMessageResult to support optional headers for output sections.
  • src/utils/result-upload/playwrightJsonParser.ts
    • Modified playwrightJsonSchema to include an optional errors array at the top level.
    • Modified parsePlaywrightJson to return a ParseResult object.
    • Implemented logic to extract top-level errors from Playwright JSON into runFailureLogs, stripping ANSI codes.
    • Updated buildMessage to explicitly label stdout and stderr sections with 'Output (stdout):' and 'Output (stderr):' headers.
  • src/utils/result-upload/types.ts
    • Added ParseResult interface to define the structure for parser outputs, including testCaseResults and runFailureLogs.
Activity
  • The pull request addresses issue #2340, indicating a targeted feature enhancement.
  • Extensive changes were made across multiple core files, including API definitions, parsing logic, and command handling, to support the new run-level log feature.
  • New test fixtures and updated test cases were added for both JUnit XML and Playwright JSON parsing, demonstrating thorough validation of the new log extraction and upload mechanisms.
  • The documentation was updated in README.md and CLAUDE.md to inform users and contributors about the new functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for uploading run-level failure logs from JUnit XML and Playwright JSON reports. The changes are comprehensive, including updates to the API client, parsers, upload logic, tests, and documentation. The implementation correctly identifies suite-level errors and handles them separately from test case results. I've found one area for improvement in the JUnit XML parser to avoid duplicate headers in the generated failure log, which would improve the readability of the output.

Comment on lines 109 to +137
for (const suite of validated.testsuites.testsuite) {
const suiteName = suite.$?.name ?? ''

// Extract suite-level system-err into runFailureLogParts
for (const err of suite['system-err'] ?? []) {
const content = (typeof err === 'string' ? err : (err._ ?? '')).trim()
if (content) {
if (suiteName) runFailureLogParts.push(`<h4>${escapeHtml(suiteName)}</h4>`)
runFailureLogParts.push(`<pre><code>${escapeHtml(content)}</code></pre>`)
}
}

for (const tcase of suite.testcase ?? []) {
const tcaseName = tcase.$.name ?? ''

// Empty-name testcases with error/failure can be synthetic entries from
// setup/teardown failures (e.g., Maven Surefire). Extract into runFailureLogParts
// and exclude from testCaseResults.
if (!tcaseName && (tcase.error || tcase.failure)) {
const elements = tcase.error ?? tcase.failure ?? []
for (const element of elements) {
const content = (typeof element === 'string' ? element : (element._ ?? '')).trim()
if (content) {
if (suiteName) runFailureLogParts.push(`<h4>${escapeHtml(suiteName)}</h4>`)
runFailureLogParts.push(`<pre><code>${escapeHtml(content)}</code></pre>`)
}
}
continue
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic for collecting run-level failure logs may produce duplicate suite name headers (e.g., <h4>MySuite</h4>) if a test suite contains both a suite-level <system-err> and an empty-name <testcase> with an error. This can make the final log appear redundant.

To improve this, I suggest refactoring to collect all run-level errors for a given suite into a temporary array first. After processing the entire suite, you can then add the suite header once (if needed), followed by all the collected error parts. This ensures each suite name is displayed only once as a header for all its associated run-level errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant