new file mode 100644
@@ -0,0 +1,26 @@
+//
+// snowpatch - continuous integration for patch-based workflows
+//
+// Copyright (C) 2016-2019 IBM Corporation
+// Authors:
+// Russell Currey <ruscur@russell.cc>
+// Andrew Donnellan <andrew.donnellan@au1.ibm.com>
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 of the License, or (at your option)
+// any later version.
+//
+// ci.rs - CI backend interface definitions
+//
+
+#[derive(Eq, PartialEq)]
+pub enum BuildStatus {
+ Running,
+ Done,
+}
+
+pub trait CIBackend {
+ fn start_test(&self, job_name: &str, params: Vec<(&str, &str)>)
+ -> Result<String, &'static str>;
+}
@@ -35,6 +35,8 @@ use reqwest::header::{HeaderMap, AUTHORIZATION, LOCATION};
use reqwest::{Client, IntoUrl, Response};
use serde_json::{self, Value};
+use ci::{BuildStatus, CIBackend};
+
use patchwork::TestState;
// Constants
@@ -42,12 +44,6 @@ const JENKINS_POLLING_INTERVAL: u64 = 5000; // Polling interval in milliseconds
// Jenkins API definitions
-pub trait CIBackend {
- // TODO: Separate out
- fn start_test(&self, job_name: &str, params: Vec<(&str, &str)>)
- -> Result<String, &'static str>;
-}
-
pub struct JenkinsBackend {
pub base_url: String,
pub reqwest_client: Arc<Client>,
@@ -85,12 +81,6 @@ impl CIBackend for JenkinsBackend {
}
}
-#[derive(Eq, PartialEq)]
-pub enum BuildStatus {
- Running,
- Done,
-}
-
impl JenkinsBackend {
fn headers(&self) -> HeaderMap {
let mut headers = HeaderMap::new();
@@ -58,8 +58,11 @@ use std::time::Duration;
mod patchwork;
use patchwork::{PatchworkServer, TestResult, TestState};
+mod ci;
+use ci::CIBackend;
+
mod jenkins;
-use jenkins::{CIBackend, JenkinsBackend};
+use jenkins::JenkinsBackend;
mod settings;
use settings::{Config, Project};
Move CIBackend and BuildStatus to a separate module as we're eventually going to use it for non-Jenkins things. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> --- src/ci.rs | 26 ++++++++++++++++++++++++++ src/jenkins.rs | 14 ++------------ src/main.rs | 5 ++++- 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 src/ci.rs