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 pub author: Option<String>,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq)]
23pub enum IssueOrigin {
24 Github,
25 Local,
26}
27
28impl IssueOrigin {
29 pub const fn as_str(&self) -> &str {
30 match self {
31 Self::Github => "github",
32 Self::Local => "local",
33 }
34 }
35}
36
37impl std::fmt::Display for IssueOrigin {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 f.write_str(self.as_str())
40 }
41}
42
43#[async_trait]
45pub trait IssueProvider: Send + Sync {
46 async fn get_ready_issues(&self, label: &str) -> Result<Vec<PipelineIssue>>;
48
49 async fn get_issue(&self, number: u32) -> Result<PipelineIssue>;
51
52 async fn transition(&self, number: u32, from: &str, to: &str) -> Result<()>;
54
55 async fn comment(&self, number: u32, body: &str) -> Result<()>;
57
58 async fn close(&self, number: u32, comment: Option<&str>) -> Result<()>;
60}