Skip to content

[Feature] : API ENDPOINTS PR 5 : Result Data and Baseline Approval#1134

Open
pulk17 wants to merge 6 commits into
CCExtractor:masterfrom
pulk17:api-pr5-results
Open

[Feature] : API ENDPOINTS PR 5 : Result Data and Baseline Approval#1134
pulk17 wants to merge 6 commits into
CCExtractor:masterfrom
pulk17:api-pr5-results

Conversation

@pulk17

@pulk17 pulk17 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

Feature: Results Data and Baseline Approvals (PR 5/6)

Executive Summary

⚠️ Note for Reviewers: This PR is stacked on top of PR 4 (#). Please review PR 4 first.
Because this PR builds upon the foundation from previous PRs, GitHub currently shows the combined file changes. Once PR 4 is merged into master, this PR will automatically update to only show the specific files for Results & Baselines.

This Pull Request is Part 5 of 6 in the initiative to introduce a fully-featured JSON REST API.

This PR implements the most technically demanding portion of the CI lifecycle: Test Results Analysis and Algorithmic Baseline Management. It allows developers to securely query raw algorithmic outputs (standard out/error), visualize computed diffs between their outputs and the expected baselines, and formally approve new algorithmic outputs as the accepted standard going forward.


Architectural Additions & Enhancements

1. Results Endpoints (mod_api/routes/results.py)

Mounted at /api/v1/runs, this router exposes granular test execution data:

  • GET /runs/<run_id>/samples/<sample_id>/results: Fetches the hierarchical result structure for a given sample, including which RegressionTestOutput components failed and why.
  • GET /runs/<run_id>/samples/<sample_id>/results/<result_id>/diff: A specialized endpoint that retrieves the exact textual difference between the CI run's output and the accepted baseline.
  • GET /runs/<run_id>/samples/<sample_id>/results/<result_id>/file: Streams the raw unadulterated output file (e.g., standard error logs, parsed CC data) generated by the algorithm during the run.
  • POST /runs/<run_id>/samples/<sample_id>/baseline-approval: The critical workflow endpoint. Allows users with baselines:write scope to promote a successful output hash to become the new global baseline for a specific regression test. Includes protections to automatically cascade approvals across test variants if requested.

2. Core Diff Service (mod_api/services/diff_service.py)

  • Extracts the heavy computational logic of reading, decoding, and generating unified diffs between storage blobs (via the Storage service) out of the routing layer.
  • Introduces robust decoding fallback mechanisms to gracefully handle corrupted or non-UTF-8 algorithmic outputs.

3. Schemas & Serialization (mod_api/schemas/results.py)

  • Provides nested serialization for TestResult and TestResultFile models.

Testing & Quality Assurance

  • Comprehensive Domain Coverage: The test suite continues to expand, now passing 168 integration tests.
  • Storage Provider Mocking: Extensive mocking of the artifact storage backends within test_services_diff_service.py to ensure diff generation logic is rock solid regardless of whether files are stored locally or in Google Cloud.
  • Strict Permission & Scope Enforcement: The baseline approval endpoint contains rigorous checks to ensure only authorized maintainers can mutate global baselines.
  • Linting & Type Safety: 100% CI compliance verified. isort, pydocstyle, pycodestyle, and mypy pass perfectly on all introduced files.

Next Steps

Following the review and merge of this PR, the final PR 6 (Swagger UI & Documentation) will be submitted to expose the OpenAPI interface for all these completed endpoints!

@sonarqubecloud

Copy link
Copy Markdown

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