[4/5] ci: Move CIBackend and BuildStatus to separate module
diff mbox series

Message ID 20190201061714.7110-4-andrew.donnellan@au1.ibm.com
State Accepted
Headers show
Series
  • [1/5] Formatting cleanups
Related show

Commit Message

Andrew Donnellan Feb. 1, 2019, 6:17 a.m. UTC
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

Patch
diff mbox series

diff --git a/src/ci.rs b/src/ci.rs
new file mode 100644
index 000000000000..7d21edb7662f
--- /dev/null
+++ b/src/ci.rs
@@ -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>;
+}
diff --git a/src/jenkins.rs b/src/jenkins.rs
index c76561f1fda2..4738fca7a069 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -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();
diff --git a/src/main.rs b/src/main.rs
index 19989c87cb01..b6c756815595 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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};