Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ is installed by rustup. Run `cargo fmt --check`, `cargo clippy --locked --all-ta
`openapi.public.json` is the public API contract pinned for this revision.
Server compatibility is checked in the Proofline control plane.

## Coverage uploads

Upload reports your CI produced for an exact commit:

```sh
proofline --org "$PROOFLINE_ORGANIZATION_ID" coverage upload \
--repository-id "$PROOFLINE_REPOSITORY_ID" \
--commit "$TESTED_COMMIT_SHA" --report coverage/lcov.info --json
```

Set `PROOFLINE_TOKEN` to a repository-restricted token with `coverage:write`.
The token holder needs current GitHub write access to the repository. Uploads
accept LCOV, Cobertura XML, JaCoCo XML and Go cover profiles. Repeat `--report`
for up to 50 UTF-8 files with distinct report names. Relative paths retain their
directories, so `packages/a/lcov.info` and `packages/b/lcov.info` are distinct.
Leading `./` is removed; relative paths cannot contain `..`. Absolute paths use
only the file name. The JSON body cannot exceed 64 MiB. The command sends the exact
40-character lowercase SHA supplied by CI and does not resolve a branch or run tests.
An identical upload returns the recorded report. Upload success records evidence;
the server evaluates the coverage check separately.

Licensed under Apache-2.0.

## Publishing
Expand Down
200 changes: 200 additions & 0 deletions openapi.public.json
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,100 @@
],
"type": "object"
},
"CoverageRefused": {
"description": "An upload refused for its content: a symbolic or unknown commit, or a\n report that cannot be read. Nothing is stored.",
"properties": {
"detail": {
"description": "One sentence naming what was refused and why.",
"type": "string"
},
"status": {
"description": "Always 422.",
"format": "uint16",
"maximum": 65535,
"minimum": 0,
"type": "integer"
},
"title": {
"description": "Always `unprocessable coverage upload`.",
"type": "string"
}
},
"required": [
"title",
"status",
"detail"
],
"type": "object"
},
"CoverageUploadRequest": {
"additionalProperties": false,
"description": "The coverage reports a CI run produced for one commit.",
"properties": {
"reports": {
"description": "One to 50 reports, each LCOV, Cobertura XML, `JaCoCo` XML or a Go\n cover profile, in a JSON body of at most 64 MiB.",
"items": {
"$ref": "#/components/schemas/UploadedReport"
},
"type": "array"
},
"tested_sha": {
"description": "The full 40-character commit the tests ran on. GitHub must have it in\n this repository. A merge commit counts for a pull request head that is\n one of its two parents.",
"type": "string"
}
},
"required": [
"tested_sha",
"reports"
],
"type": "object"
},
"CoverageUploadResponse": {
"description": "The report the upload recorded, or the one an identical upload recorded.",
"properties": {
"covered_lines": {
"description": "Covered lines among those instrumented lines.",
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"created": {
"description": "False when the same reports for this commit were already recorded.",
"type": "boolean"
},
"formats": {
"description": "The format of each report, in upload order.",
"items": {
"type": "string"
},
"type": "array"
},
"instrumented_lines": {
"description": "Instrumented lines across the reports, a file two reports name under\n one path counted once.",
"format": "uint64",
"minimum": 0,
"type": "integer"
},
"report_id": {
"description": "The recorded report.",
"format": "uuid",
"type": "string"
},
"tested_sha": {
"description": "The commit the reports tested, as the upload named it.",
"type": "string"
}
},
"required": [
"report_id",
"tested_sha",
"created",
"formats",
"instrumented_lines",
"covered_lines"
],
"type": "object"
},
"CustomerAssessment": {
"properties": {
"checks": {
Expand Down Expand Up @@ -6217,6 +6311,24 @@
],
"type": "object"
},
"UploadedReport": {
"additionalProperties": false,
"properties": {
"content": {
"description": "The report text, exactly as the coverage tool wrote it.",
"type": "string"
},
"name": {
"description": "A relative name for the report, such as `web/lcov.info`, unique in\n the upload.",
"type": "string"
}
},
"required": [
"name",
"content"
],
"type": "object"
},
"WalkthroughFileView": {
"properties": {
"additions": {
Expand Down Expand Up @@ -6882,6 +6994,94 @@
"x-proofline-token-scope": "reviews:request"
}
},
"/api/v1/organizations/{org_id}/repositories/{repo_id}/coverage-reports": {
"post": {
"description": "Records the LCOV, Cobertura, JaCoCo or Go coverage reports a CI run produced for one exact commit GitHub has in the repository, for COVERAGE checks that accept uploads. A branch, tag or abbreviated SHA, or a report that cannot be read, gets 422 and stores nothing. Requires a repository-restricted token and live GitHub write access; the same reports for the same commit return the report already recorded.",
"operationId": "upload_coverage_reports",
"parameters": [
{
"in": "path",
"name": "org_id",
"required": true,
"schema": {
"format": "uuid",
"type": "string"
},
"style": "simple"
},
{
"in": "path",
"name": "repo_id",
"required": true,
"schema": {
"format": "uuid",
"type": "string"
},
"style": "simple"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CoverageUploadRequest"
}
}
},
"description": "The coverage reports a CI run produced for one commit.",
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CoverageUploadResponse"
}
}
},
"description": "The report the upload recorded, or the one an identical upload recorded."
},
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CoverageUploadResponse"
}
}
},
"description": "The report the upload recorded, or the one an identical upload recorded."
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CoverageRefused"
}
}
},
"description": "An upload refused for its content: a symbolic or unknown commit, or a\n report that cannot be read. Nothing is stored."
},
"default": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "An RFC 9457 problem; the HTTP status remains authoritative."
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Upload coverage reports",
"x-proofline-token-scope": "coverage:write"
}
},
"/api/v1/organizations/{org_id}/repositories/{repo_id}/file-reviews": {
"post": {
"description": "Reviews up to twenty exact file paths at one pushed commit. Requires live GitHub read access and verifies every path at that commit. The retained selection is immutable; a repeat by the same person returns its review. Results remain in Proofline and are never posted to GitHub.",
Expand Down
26 changes: 23 additions & 3 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ use url::Url;
use uuid::Uuid;

use crate::model::{
CommitReviewRequest, CommitReviewResponse, FileReviewRequest, FileReviewResponse,
PatchReviewRequest, PatchReviewResponse, RepositoryNames, ReviewDetail, ReviewPage, RunNowMode,
RunNowRequest, RunNowResponse, StopResponse,
CommitReviewRequest, CommitReviewResponse, CoverageUploadRequest, CoverageUploadResponse,
FileReviewRequest, FileReviewResponse, PatchReviewRequest, PatchReviewResponse,
RepositoryNames, ReviewDetail, ReviewPage, RunNowMode, RunNowRequest, RunNowResponse,
StopResponse,
};
use crate::origin::Origin;
use crate::text::terminal_safe;
Expand Down Expand Up @@ -535,6 +536,25 @@ impl Api {
Err(self.http.problem(&reply))
}

/// Uploads reports for one exact tested commit. Both a new report and an
/// identical upload return the recorded report. One HTTP attempt.
pub async fn upload_coverage_reports(
&self,
repository_id: Uuid,
request: &CoverageUploadRequest,
) -> Result<CoverageUploadResponse, ApiError> {
let repository = repository_id.to_string();
let url = self.url(&["repositories", &repository, "coverage-reports"]);
let (reply, _) = self
.http
.send(self.request(Method::POST, url).json(request))
.await?;
if matches!(reply.status, StatusCode::OK | StatusCode::CREATED) {
return self.decode(&reply.body);
}
Err(self.http.problem(&reply))
}

/// Requests whole-file review of a selection at one pushed commit.
pub async fn request_file_review(
&self,
Expand Down
Loading
Loading