mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 08:20:12 +00:00
* feat: run the git sync pull request diff check from auto-pull polling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: retry failed pr check claims and never overwrite a newer claim Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: retry pr check claims whose check never started and start checks detached Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: re-run the pr diff check on reopen and retarget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump ee ref for the claim helper caller contract Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: update ee-repo-ref to 5a9f39d1188f94599c5cee24b9fe4e36a578ef80 This commit updates the EE repository reference after PR #977 was merged in windmill-ee-private. Previous ee-repo-ref: 95463c1ab277c80efc16cd0c2322bf32bbaceb7c New ee-repo-ref: 5a9f39d1188f94599c5cee24b9fe4e36a578ef80 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
51 lines
2.0 KiB
Rust
51 lines
2.0 KiB
Rust
//! Who checks a pull request head: the webhook receiver and the auto-pull poller
|
|
//! both claim it, and each head is checked once whichever sees it first.
|
|
#![cfg(all(feature = "enterprise", feature = "private"))]
|
|
|
|
use sqlx::{Pool, Postgres};
|
|
use windmill_api::git_sync_ee::{claim_pr_check_head, mark_pr_check_started};
|
|
|
|
const REPO: &str = "$res:u/admin/repo";
|
|
|
|
#[sqlx::test]
|
|
async fn a_head_is_claimed_once(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
sqlx::query("INSERT INTO workspace (id, name, owner) VALUES ('ws', 'ws', 'test-user')")
|
|
.execute(&db)
|
|
.await?;
|
|
let claim = |sha: &'static str, listed_at| {
|
|
let db = db.clone();
|
|
async move { claim_pr_check_head(&db, "ws", REPO, 7, sha, listed_at, false).await }
|
|
};
|
|
|
|
let listed_at = Some(chrono::Utc::now() - chrono::Duration::minutes(1));
|
|
assert!(claim("a", None).await?, "a new head is claimed");
|
|
mark_pr_check_started(&db, "ws", REPO, 7, "a").await?;
|
|
assert!(
|
|
!claim("a", None).await?,
|
|
"the same head is not checked twice"
|
|
);
|
|
|
|
assert!(
|
|
!claim("b", listed_at).await?,
|
|
"a listing older than the claim cannot replace it with the head it saw"
|
|
);
|
|
assert!(claim("b", None).await?, "a new head is claimed");
|
|
|
|
// Its check never started: a crash between claim and start, or an error.
|
|
assert!(!claim("b", None).await?, "not retried right away");
|
|
sqlx::query("UPDATE git_sync_pr_check_head SET checked_at = now() - interval '11 minutes'")
|
|
.execute(&db)
|
|
.await?;
|
|
assert!(claim("b", None).await?, "retried once the delay passed");
|
|
mark_pr_check_started(&db, "ws", REPO, 7, "b").await?;
|
|
sqlx::query("UPDATE git_sync_pr_check_head SET checked_at = now() - interval '11 minutes'")
|
|
.execute(&db)
|
|
.await?;
|
|
assert!(!claim("b", None).await?, "a started check is never retried");
|
|
assert!(
|
|
claim_pr_check_head(&db, "ws", REPO, 7, "b", None, true).await?,
|
|
"a reopen or retarget re-runs it"
|
|
);
|
|
Ok(())
|
|
}
|