1pub mod github;
2pub mod local;
3
4use anyhow::Result;
5use async_trait::async_trait;
6
7#[derive(Debug, Clone)]
12pub struct PipelineIssue {
13 pub number: u32,
14 pub title: String,
15 pub body: String,
16 pub source: IssueOrigin,
17 pub target_repo: Option<String>,
18}
19
20#[derive(Debug, Clone, PartialEq, Eq)]
22pub enum IssueOrigin {
23 Github,
24 Local,
25}
26
27impl IssueOrigin {
28 pub const fn as_str(&self) -> &str {
29 match self {
30 Self::Github => "github",
31 Self::Local => "local",
32 }
33 }
34}
35
36impl std::fmt::Display for IssueOrigin {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 f.write_str(self.as_str())
39 }
40}
41
42#[async_trait]
44pub trait IssueProvider: Send + Sync {
45 async fn get_ready_issues(&self, label: &str) -> Result<Vec<PipelineIssue>>;
47
48 async fn get_issue(&self, number: u32) -> Result<PipelineIssue>;
50
51 async fn transition(&self, number: u32, from: &str, to: &str) -> Result<()>;
53
54 async fn comment(&self, number: u32, body: &str) -> Result<()>;
56
57 async fn close(&self, number: u32, comment: Option<&str>) -> Result<()>;
59}