improve some logging
This commit is contained in:
parent
47c46468f8
commit
9c78ec2db5
|
@ -162,7 +162,7 @@ function try_eval($ghclient, $owner, $name, $sha, $eval_name, $cmd, $args) {
|
||||||
$status->success("Finished running $cmd");
|
$status->success("Finished running $cmd");
|
||||||
} catch (GHE\ExecException $e) {
|
} catch (GHE\ExecException $e) {
|
||||||
echo "Failed to run $eval_name on $sha\n";
|
echo "Failed to run $eval_name on $sha\n";
|
||||||
$status->pending("Failed to run $cmd");
|
$status->failure("Failed to run $cmd");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
ofborg/Cargo.lock
generated
1
ofborg/Cargo.lock
generated
|
@ -5,6 +5,7 @@ dependencies = [
|
||||||
"amqp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"amqp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"md5 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"md5 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
authors = ["Graham Christensen <graham@grahamc.com>"]
|
authors = ["Graham Christensen <graham@grahamc.com>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
log = "0.3.8"
|
||||||
env_logger = "0.4.3"
|
env_logger = "0.4.3"
|
||||||
amqp = "0.1.0"
|
amqp = "0.1.0"
|
||||||
md5 = "0.3.5"
|
md5 = "0.3.5"
|
||||||
|
|
|
@ -23,21 +23,48 @@ pub trait GitClonable {
|
||||||
fn lock_path(&self) -> PathBuf;
|
fn lock_path(&self) -> PathBuf;
|
||||||
|
|
||||||
fn lock(&self) -> Result<Lock, Error> {
|
fn lock(&self) -> Result<Lock, Error> {
|
||||||
println!("Locking {:?}", self.lock_path());
|
info!("Locking {:?}", self.lock_path());
|
||||||
let lock = fs::File::create(self.lock_path())?;
|
|
||||||
lock.lock_exclusive()?;
|
match fs::File::create(self.lock_path()) {
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Failed to create lock file {:?}: {}",
|
||||||
|
self.lock_path(), e
|
||||||
|
);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
Ok(lock) => {
|
||||||
|
match lock.lock_exclusive() {
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Failed to get exclusive lock on file {:?}: {}",
|
||||||
|
self.lock_path(), e
|
||||||
|
);
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
Ok(_) => {
|
||||||
|
debug!("Got lock on {:?}", self.lock_path());
|
||||||
return Ok(Lock{
|
return Ok(Lock{
|
||||||
lock: Some(lock)
|
lock: Some(lock)
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_repo(&self) -> Result<(), Error> {
|
fn clone_repo(&self) -> Result<(), Error> {
|
||||||
let mut lock = self.lock()?;
|
let mut lock = self.lock()?;
|
||||||
|
|
||||||
if self.clone_to().is_dir() {
|
if self.clone_to().is_dir() {
|
||||||
|
debug!("Found dir at {:?}, initial clone is done",
|
||||||
|
self.clone_to());
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info!("Initial cloning of {} to {:?}",
|
||||||
|
self.clone_from(),
|
||||||
|
self.clone_to());
|
||||||
|
|
||||||
let result = Command::new("git")
|
let result = Command::new("git")
|
||||||
.arg("clone")
|
.arg("clone")
|
||||||
.args(self.extra_clone_args())
|
.args(self.extra_clone_args())
|
||||||
|
@ -57,6 +84,7 @@ pub trait GitClonable {
|
||||||
fn fetch_repo(&self) -> Result<(), Error> {
|
fn fetch_repo(&self) -> Result<(), Error> {
|
||||||
let mut lock = self.lock()?;
|
let mut lock = self.lock()?;
|
||||||
|
|
||||||
|
info!("Fetching from origin in {:?}", self.clone_to());
|
||||||
let result = Command::new("git")
|
let result = Command::new("git")
|
||||||
.arg("fetch")
|
.arg("fetch")
|
||||||
.arg("origin")
|
.arg("origin")
|
||||||
|
@ -75,18 +103,21 @@ pub trait GitClonable {
|
||||||
fn clean(&self) -> Result<(), Error> {
|
fn clean(&self) -> Result<(), Error> {
|
||||||
let mut lock = self.lock()?;
|
let mut lock = self.lock()?;
|
||||||
|
|
||||||
|
info!("git am --abort");
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.arg("am")
|
.arg("am")
|
||||||
.arg("--abort")
|
.arg("--abort")
|
||||||
.current_dir(self.clone_to())
|
.current_dir(self.clone_to())
|
||||||
.status()?;
|
.status()?;
|
||||||
|
|
||||||
|
info!("git merge --abort");
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.arg("merge")
|
.arg("merge")
|
||||||
.arg("--abort")
|
.arg("--abort")
|
||||||
.current_dir(self.clone_to())
|
.current_dir(self.clone_to())
|
||||||
.status()?;
|
.status()?;
|
||||||
|
|
||||||
|
info!("git reset --hard");
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.arg("reset")
|
.arg("reset")
|
||||||
.arg("--hard")
|
.arg("--hard")
|
||||||
|
@ -101,6 +132,7 @@ pub trait GitClonable {
|
||||||
fn checkout(&self, git_ref: &OsStr) -> Result<(), Error> {
|
fn checkout(&self, git_ref: &OsStr) -> Result<(), Error> {
|
||||||
let mut lock = self.lock()?;
|
let mut lock = self.lock()?;
|
||||||
|
|
||||||
|
|
||||||
let result = Command::new("git")
|
let result = Command::new("git")
|
||||||
.arg("checkout")
|
.arg("checkout")
|
||||||
.arg(git_ref)
|
.arg(git_ref)
|
||||||
|
|
|
@ -3,6 +3,9 @@ extern crate serde_derive;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
|
||||||
extern crate tempfile;
|
extern crate tempfile;
|
||||||
extern crate amqp;
|
extern crate amqp;
|
||||||
extern crate fs2;
|
extern crate fs2;
|
||||||
|
|
Loading…
Reference in a new issue