review classifier: re-post a clean verdict on a same-head re-request
A review request for a head whose newest recorded review approved or requested changes now runs nothing: the classifier account posts that verdict and table again, opening "Already reviewed <sha>, verdict unchanged". A head whose newest review had no clean verdict, a failed post, or no record gets a fresh run, as before. An accepted request now keeps its key until its record is written, so a request right after a run finishes reads that run's verdict instead of starting a second run. Part of #5387; the restart-loss half waits on #5219.
This commit is contained in:
parent
f03dcd0f31
commit
eb92e83c95
1 changed files with 374 additions and 10 deletions
|
|
@ -96,7 +96,8 @@ pub(crate) struct RunRecord {
|
|||
pub(super) finished_unix: i64,
|
||||
pub(super) outcome: RunOutcome,
|
||||
/// Why, for every outcome but `approved`, `changes-requested` and
|
||||
/// `done`.
|
||||
/// `done`. A review that re-posts an earlier run's verdict names that
|
||||
/// run here.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(super) detail: Option<String>,
|
||||
/// As the try-out GET returns them, when the classifier answered.
|
||||
|
|
@ -248,6 +249,36 @@ impl Runs {
|
|||
}
|
||||
}
|
||||
|
||||
/// The newest recorded review of `head` on `repo`'s PR `pr`, if any.
|
||||
pub(crate) async fn newest_review(
|
||||
&self,
|
||||
repo: &str,
|
||||
pr: u64,
|
||||
head: &str,
|
||||
) -> anyhow::Result<Option<RunRecord>> {
|
||||
let (runs, _) = match self {
|
||||
Self::Live(client) => {
|
||||
let store = open(client.as_ref()).await.map_err(|Unreachable(e)| {
|
||||
anyhow::anyhow!(e).context(format!("opening the {BUCKET} bucket"))
|
||||
})?;
|
||||
RunDoc::read(&store).await?
|
||||
}
|
||||
#[cfg(test)]
|
||||
Self::Fake(doc) => doc.read().await?,
|
||||
};
|
||||
Ok(runs.into_iter().find_map(|entry| match entry {
|
||||
Stored::Run(run)
|
||||
if run.trigger == Trigger::Review
|
||||
&& run.repo == repo
|
||||
&& run.pr == pr
|
||||
&& run.head_sha.as_deref() == Some(head) =>
|
||||
{
|
||||
Some(run)
|
||||
}
|
||||
_ => None,
|
||||
}))
|
||||
}
|
||||
|
||||
async fn list(&self) -> Result<Vec<RunRecord>, ProblemDetails> {
|
||||
let read = match self {
|
||||
Self::Live(client) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue