summaryrefslogtreecommitdiffstats
path: root/src/usecase/builds.rs
blob: c9477426541f675e86593747ad1b5062f78ac796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)
}