summaryrefslogtreecommitdiffstats
path: root/src/usecase/builds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/usecase/builds.rs')
-rw-r--r--src/usecase/builds.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/usecase/builds.rs b/src/usecase/builds.rs
new file mode 100644
index 0000000..c947742
--- /dev/null
+++ b/src/usecase/builds.rs
@@ -0,0 +1,46 @@
+//! Getting a build queued, cancelled, retried, or unpublished.
+
+use crate::config::Config;
+use crate::db::{self, builds, CandidateRow, Db};
+use crate::error::Result;
+use crate::pipeline;
+
+/// Queue a build for an approved candidate.
+pub fn enqueue_candidate(cfg: &Config, db: &Db, c: &CandidateRow) -> Result<String> {
+ pipeline::enqueue_for_candidate(cfg, db, c)
+}
+
+/// Queue a rebuild of what is currently accepted — no new approval, because
+/// nothing about the source is changing.
+pub fn manual_rebuild(cfg: &Config, db: &Db, pkgbase: &str) -> Result<String> {
+ pipeline::enqueue_manual_rebuild(cfg, db, pkgbase)
+}
+
+/// Ask a running build to stop. It stops at the next step boundary; a build
+/// cannot be interrupted mid-step without leaving a half-written package.
+pub fn cancel(db: &Db, build_id: &str) -> Result<()> {
+ builds::request_cancel(db, build_id)
+}
+
+/// Retry a failed build, and record that someone asked.
+///
+/// The audit row is part of the workflow rather than the caller's homework: a
+/// retry changes what a build means, and a retry nobody asked for is exactly
+/// what the audit trail is there to rule out.
+pub fn retry(db: &Db, actor: &str, build_id: &str) -> Result<()> {
+ builds::retry(db, build_id)?;
+ db::audit(
+ &db.writer,
+ actor,
+ actor,
+ "build.retry",
+ "build",
+ build_id,
+ serde_json::json!({}),
+ )
+}
+
+/// Take a package out of the repository index.
+pub fn withdraw_package(cfg: &Config, db: &Db, name: &str) -> Result<()> {
+ pipeline::publish::withdraw_package(cfg, db, name)
+}