Skip to content
Open
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ Native knowledge, plan, fix and configuration commands send the selected organiz

In GitHub Actions, `proofline ci review --annotations` prints unresolved findings as workflow annotations at verified cited lines. Findings without a verified head location appear on the job. The review link contains the full result.

In a manually triggered or downstream job, pass the original PR number and its full head commit SHA to read that PR's review:

```sh
proofline ci review --repo owner/name --pr 42 --commit "$PR_HEAD_SHA" --fail-on serious
```

Outside a GitHub pull-request event, `--pr` requires an explicit `--commit`. On a pull-request event, the PR number comes from the event, and any explicit `--pr` must match it.

For a CodePipeline execution or Amplify job, run `proofline ci deploy --commit SHA --aws-run ID` in a later pipeline. Add `--environment-id UUID` to select its Proofline environment. The output names the AWS provider and run ID. Proofline records a CodePipeline deploy only after the execution succeeds, so a reader inside that execution waits until its timeout and exits 2. On a GitHub `workflow_run` event, an explicit `--aws-run` disables the default Actions run and attempt filters.

`proofline ci deploy --until 1h` waits until Proofline has recorded the deploy checks of the job's commit through the hour check, then exits 0 when each recorded `HEALTHY` with no gap, 3 when a deploy failed or regressed, and 2 when the result is not established, including when a deploy reads a state this CLI version does not know. After a read that answered, the wait keeps reading through a read that fails in transport, times out or gets a 5xx answer, and exits 4 after five such failures in a row, naming the last error; the first read and a refusal end it at once. Without `--timeout`, a wait for `--until landing`, `--until 20m` or `--until 1h` lasts until that check is due for the selected deploys, and at least 30 minutes, so a landing check that reads the runtime again, up to 75 minutes after landing, is still read; `--until 1d` needs `--timeout`. `--environment-id` (the Proofline environment's UUID, the `environment_id` that `--json` prints for each deploy), `--environment` (the GitHub Environment name), `--task`, `--deployment` (the ID of the GitHub deployment a pipeline created), `--run` and `--attempt` select the deploy, and on a `workflow_run` event the commit, `--run` and `--attempt` default to the completed run's. When `--run` defaults to a completed run that did not succeed, the command waits at most 5 minutes for a deploy from that run, then exits 2 with a last line that names the run's conclusion and says it recorded no deploy; a deploy the run did record gets the usual wait for its check. `--json` prints the response. Each deploy prints one line per check. A deploy that rolled the environment back to an earlier commit first prints a `rollback` line with the page of the deploy it restores, when Proofline recorded one, and the pages of the deploys it rolled back. A deploy whose newest check found its service serving an earlier deploy again first prints a `rolled back` line, and stops printing it once a later check finds none; with `--json` the response carries it as `rolled_back`. Both lines can appear for one deploy. A rollback's exit code comes from its checks like any other deploy's; neither line changes it or means the rollback fixed anything. A deploy whose deploy checks ended without recording the `--until` check ends the wait at once with exit 2, and the last line names the check and the deploy's page; a check that is overdue while the checks still run keeps the wait going until the timeout.
Expand Down
26 changes: 25 additions & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,31 @@ impl Api {
search: Option<&str>,
cursor: Option<&str>,
) -> Result<ReviewPage, ApiError> {
let mut url = self.url_list_reviews();
self.review_page(self.url_list_reviews(), repository_id, search, cursor)
.await
}

/// Applies the repository UUID filter to the name-based PR history route.
/// The caller matches the head locally while walking that history.
pub(crate) async fn pull_request_review_page(
&self,
repository: &str,
repository_id: Uuid,
number: i64,
cursor: Option<&str>,
) -> Result<ReviewPage, ApiError> {
let url = self.url_list_pull_request_reviews(repository, &number.to_string());
self.review_page(url, Some(repository_id), None, cursor)
.await
}

async fn review_page(
&self,
mut url: Url,
repository_id: Option<Uuid>,
search: Option<&str>,
cursor: Option<&str>,
) -> Result<ReviewPage, ApiError> {
{
let mut query = url.query_pairs_mut();
query.append_pair("limit", "50");
Expand Down
57 changes: 57 additions & 0 deletions src/github_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,63 @@ struct Head {
sha: String,
}

pub(crate) struct PullRequestIdentity {
pub number: i64,
pub repository: Option<String>,
pub head: Option<String>,
}

pub(crate) fn pull_request_identity(event: &str) -> anyhow::Result<Option<PullRequestIdentity>> {
#[derive(Deserialize)]
struct Repository {
full_name: String,
}
#[derive(Deserialize)]
struct Payload {
repository: Option<Repository>,
pull_request: Request,
number: Option<i64>,
}
#[derive(Deserialize)]
struct Request {
number: Option<i64>,
#[serde(default)]
head: serde_json::Value,
}
if !event.starts_with("pull_request") {
return Ok(None);
}
let unreadable =
|| format!("the {event} event payload must name the pull request; check GITHUB_EVENT_PATH");
let path = std::env::var_os(EVENT_PATH).with_context(unreadable)?;
let bytes = std::fs::read(path).with_context(unreadable)?;
let payload: Payload = serde_json::from_slice(&bytes).with_context(unreadable)?;
let number = payload
.pull_request
.number
.or(payload.number)
.with_context(unreadable)?;
if number <= 0
|| payload.number.is_some_and(|outer| outer != number)
|| payload
.repository
.as_ref()
.is_some_and(|repo| repo.full_name.trim().is_empty())
{
bail!("{}", unreadable());
}
Ok(Some(PullRequestIdentity {
number,
repository: payload.repository.map(|repo| repo.full_name),
head: payload
.pull_request
.head
.get("sha")
.and_then(serde_json::Value::as_str)
.map(str::to_owned),
}))
}

/// The commit a GitHub Actions job tests, or `None` outside one. On a
/// `pull_request*` event `GITHUB_SHA` is GitHub's merge commit or the base
/// branch's head, never a commit Proofline reviewed, so the pull request's head
Expand Down
Loading