Repository navigation
Add review_junit: render a review outcome as JUnit XML for CI - #153
Open
nzt108-dev wants to merge 1 commit into
Open
nzt108-dev wants to merge 1 commit into
nzt108-dev wants to merge 1 commit into
Conversation
GitLab merge request test reports, Jenkins, Azure DevOps, CircleCI and Buildkite read JUnit XML. review_junit renders the outcome wait_for_review returns: one suite per assessment, one test case per finding. Open findings at or above fail_on fail, lower ones are skipped, resolved ones pass. File and line come only from verified reads at the review's head commit, the same rule as the CLI's SARIF output. Every assessment gap and any outcome other than COMPLETED is an error, so an unfinished review never looks green.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Who this helps
Teams whose CI is not GitHub code scanning. GitLab merge request test reports, Jenkins, Azure DevOps, CircleCI and Buildkite all read JUnit XML natively, and the SDK already resolves GitLab repositories, but today a GitLab team has to print
wait_for_reviewresults to the job log and nobody reads them there.review_junit(outcome)turns the outcome into a JUnit report, so findings show up in the merge request's test widget next to the team's own failing tests, with no extra API request. SARIF covers GitHub code scanning; this covers everything else that reads test reports.Decisions
<testsuite>per assessment (Code, or the environment's display name), one<testcase>per finding,classnameisproofline.<risk_domain>, the name is the one-line claim. A topProofline reviewsuite holds aReview completedcase, so the report always has at least one test.COMPLETEDis an<error>on that case, and everyAssessmentGapbecomes an<error>in its assessment's suite with the reason codes, incompleteness kind, release evidence gap and unresolved checks. A JUnit report with zero failures is what most CI systems treat as "safe to merge", so partial evidence must not render that way.<error>rather than<failure>keeps "Proofline found a problem" apart from "Proofline could not finish".fail_on(defaultWARNING) mirrors the CLI's SARIF levels:CRITICAL/SERIOUS/WARNINGfail by default,NOTEis<skipped>so it stays visible without blocking.RESOLVEDfindings pass and keep their details in<system-out>. An unknown severity raisesProoflineError, as the CLI's SARIF export refuses it; an invalidfail_onis a caller error and raisesValueErrorbefore anything is rendered.file/lineare set only for arepository_filereference withVERIFIED_REPOSITORY_READprovenance at the review's head commit, with a safe relative path (no./.., controls, bidi overrides,\or:) and a valid line range. Every valid location is also listed in the failure body. A location the reviewer did not verify at this commit would point a developer at the wrong line.xml.etree.ElementTree(escaping), XML 1.0-illegal control characters replaced with U+FFFD, names capped at 200 characters, and duplicate case names within a suite get a#2suffix because several CI viewers merge cases with the same name.ReviewOutcome, so it works with both the sync and async clients and needs no new request or contract change. Nothing underproofline/_generated/changed.How I verified it
python3 scripts/check.pypasses: generation check, contracts, ruff, ruff format, mypy, 249 tests, wheel and sdist builds and installed smoke tests.tests/test_junit.pycovers: failures with head locations and deduplicated evidence; eight ways a location must be dropped (other commit, unverified provenance,..path, bidi override, line 0, end before start, non-file evidence, companion repository); the threshold (NOTE/WARNING/SERIOUS,RESOLVEDpassing); anINCOMPLETEenvironment assessment with an unresolved gating check producing errors; a completed review with no findings producing a clean report; aTIMED_OUTwait with no review; markup and control characters staying well-formed; refusal of unknown severities and thresholds.junitparser) to confirm suite and case counts,Failure/Skippedresults andfile/lineread back as intended.