summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2024-01-15 12:07:35 +0200
committerLars Wirzenius <liw@liw.fi>2024-01-15 14:38:58 +0200
commit3a20cb66e627478ed42d6c4c181b81c522b6a35f (patch)
tree82e1c7c4c0be7429887c1fb693996f13454f429d
parent9225ef0d3119967a042ac147243739ea130f0c19 (diff)
downloadradicle-native-ci-3a20cb66e627478ed42d6c4c181b81c522b6a35f.tar.gz
feat! drop the env logging
We have a run log, aimed at the developer for whose project CI is run, and the node admin log, aimed at the node admin. We don't need a third log aimed at the developer of the native CI engine itself. Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/bin/radicle-native-ci.rs17
-rw-r--r--src/config.rs2
-rw-r--r--src/msg.rs3
-rw-r--r--src/runcmd.rs7
-rw-r--r--src/runinfo.rs2
-rw-r--r--src/runspec.rs3
8 files changed, 3 insertions, 35 deletions
diff --git a/Cargo.lock b/Cargo.lock
index aafc17c..52aa1eb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1090,8 +1090,6 @@ name = "radicle-native-ci"
version = "0.1.0"
dependencies = [
"html-page",
- "log",
- "pretty_env_logger",
"radicle",
"radicle-ci-broker",
"radicle-git-ext",
diff --git a/Cargo.toml b/Cargo.toml
index a6a1001..10b024e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,8 +6,6 @@ default-run = "radicle-native-ci"
[dependencies]
html-page = "0.1.0"
-log = "0.4.20"
-pretty_env_logger = "0.5.0"
radicle-git-ext = "0.7.0"
serde = { version = "1.0.193", features = ["derive"] }
serde_yaml = "0.9.27"
diff --git a/src/bin/radicle-native-ci.rs b/src/bin/radicle-native-ci.rs
index 1975912..43027dc 100644
--- a/src/bin/radicle-native-ci.rs
+++ b/src/bin/radicle-native-ci.rs
@@ -17,7 +17,6 @@ use std::{
path::{Path, PathBuf},
};
-use log::{debug, error, info};
use uuid::Uuid;
use radicle::prelude::Profile;
@@ -52,9 +51,6 @@ fn main() {
}
fn fallible_main() -> Result<(), NativeError> {
- pretty_env_logger::init_custom_env("RADICLE_NATIVE_CI_LOG");
- info!("radicle-native-ci starts");
-
let config = Config::load_via_env()?;
let mut logfile = config.open_log()?;
@@ -99,8 +95,9 @@ fn fallible_main_inner(
builder.log(&config.state, run_log.clone());
builder.run_info(run_info_file.clone());
+ let run_log = RunLog::new(&run_log);
+
if let Request::Trigger { repo, commit } = req {
- info!("Request to trigger CI on {}, {}", repo, commit);
builder.repo(repo);
builder.commit(commit);
let mut runner = RunnerBuilder::default()
@@ -110,13 +107,12 @@ fn fallible_main_inner(
.commit(commit)
.src(&src)
.log(logfile)
- .run_log(&run_log)
+ .run_log(run_log)
.timeout(config.timeout)
.builder(builder)
.build()?;
let result = runner.run();
if let Err(e) = result {
- error!("CI run failed: {}", e);
logfile.writeln(&format!("CI failed: {:?}", e))?;
builder.result(RunResult::Failure);
return Err(e);
@@ -128,7 +124,6 @@ fn fallible_main_inner(
};
logfile.writeln("radicle-native-ci ends successfully")?;
- info!("radicle-native-ci ends");
Ok(())
}
@@ -136,13 +131,11 @@ fn fallible_main_inner(
fn mkdir_run(config: &Config) -> Result<(Uuid, PathBuf), NativeError> {
let state = &config.state;
if !state.exists() {
- debug!("creating state directory {}", state.display());
std::fs::create_dir_all(state).map_err(|e| NativeError::CreateState(state.into(), e))?;
}
let run_id = Uuid::new_v4();
let run_dir = state.join(run_id.to_string());
- debug!("directory for this run: {}", run_dir.display());
std::fs::create_dir(&run_dir).map_err(|e| NativeError::CreateRunDir(run_dir.clone(), e))?;
Ok((run_id, run_dir))
}
@@ -162,7 +155,6 @@ struct Runner<'a> {
impl<'a> Runner<'a> {
fn git_clone(&mut self, repo_path: &Path) -> Result<(), NativeError> {
- debug!("cloning repository to {}", self.src.display());
self.log.writeln("clone repository")?;
runcmd(
&mut self.run_log,
@@ -178,7 +170,6 @@ impl<'a> Runner<'a> {
}
fn git_checkout(&mut self) -> Result<(), NativeError> {
- debug!("checking out commit {}", self.commit);
self.log.writeln("check out commit")?;
runcmd(
&mut self.run_log,
@@ -200,7 +191,6 @@ impl<'a> Runner<'a> {
write_triggered(&self.run_id)?;
let repo_path = self.storage.join(self.repo.canonical());
- debug!("repo path: {}", repo_path.display());
self.git_clone(&repo_path)?;
self.git_checkout()?;
@@ -208,7 +198,6 @@ impl<'a> Runner<'a> {
let runspec = RunSpec::from_file(&self.src.join(RUNSPEC_PATH))?;
self.log.writeln(&format!("CI run spec: {:#?}", runspec))?;
- debug!("running CI in cloned repository");
self.log.writeln("run shell snippet in repository")?;
let snippet = format!("set -xeuo pipefail\n{}", &runspec.shell);
if let Some(timeout) = self.timeout {
diff --git a/src/config.rs b/src/config.rs
index 68401c7..621ce20 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,6 +1,5 @@
use std::path::{Path, PathBuf};
-use log::{debug, error};
use serde::Deserialize;
use crate::logfile::{LogError, LogFile};
@@ -28,7 +27,6 @@ impl Config {
let filename = std::env::var(ENV).map_err(|e| ConfigError::GetEnv(ENV, e))?;
let filename = Path::new(&filename);
let config = Config::read(filename)?;
- debug!("configuration from {}: {:#?}", filename.display(), config);
Ok(config)
}
diff --git a/src/msg.rs b/src/msg.rs
index 5732bbd..be8336d 100644
--- a/src/msg.rs
+++ b/src/msg.rs
@@ -1,7 +1,5 @@
use std::path::PathBuf;
-use log::{debug, error};
-
use radicle_ci_broker::msg::{MessageError, Request, Response, RunId};
use crate::{
@@ -12,7 +10,6 @@ use crate::{
/// Read a request from stdin.
pub fn read_request() -> Result<Request, NativeMessageError> {
let req = Request::from_reader(std::io::stdin()).map_err(NativeMessageError::ReadRequest)?;
- debug!("request: {:#?}", req);
Ok(req)
}
diff --git a/src/runcmd.rs b/src/runcmd.rs
index 6010259..da99058 100644
--- a/src/runcmd.rs
+++ b/src/runcmd.rs
@@ -1,16 +1,11 @@
use std::{path::Path, process::Command};
-use log::{debug, error};
-
use radicle_ci_broker::msg::{MessageError, Response};
use crate::runlog::{RunLog, RunLogError};
/// Run a command in a directory.
pub fn runcmd(run_log: &mut RunLog, argv: &[&str], cwd: &Path) -> Result<(), RunCmdError> {
- debug!("runcmd: argv={:?}", argv);
- debug!("runcmd: cwd={:?}", cwd);
-
assert!(!argv.is_empty());
let argv0 = argv[0];
let output = Command::new(argv0)
@@ -18,10 +13,8 @@ pub fn runcmd(run_log: &mut RunLog, argv: &[&str], cwd: &Path) -> Result<(), Run
.current_dir(cwd)
.output()
.map_err(|e| RunCmdError::Command(argv.iter().map(|s| s.to_string()).collect(), e))?;
- debug!("{:#?}", output);
let exit = output.status;
- debug!("exit: {:?}", exit);
run_log.runcmd(
argv,
diff --git a/src/runinfo.rs b/src/runinfo.rs
index 9d83227..b5cf709 100644
--- a/src/runinfo.rs
+++ b/src/runinfo.rs
@@ -1,6 +1,5 @@
use std::path::{Path, PathBuf};
-use log::{error, info};
use serde::{Deserialize, Serialize};
use time::{macros::format_description, OffsetDateTime};
@@ -42,7 +41,6 @@ impl RunInfo {
pub fn write(&self) -> Result<(), RunInfoError> {
if let Some(filename) = &self.run_info {
- info!("Writing run info to {}", filename.display());
let yaml = serde_yaml::to_string(&self).map_err(RunInfoError::SerializeRunInfo)?;
std::fs::write(filename, yaml.as_bytes())
.map_err(|e| RunInfoError::WriteRunInfo(filename.into(), e))?;
diff --git a/src/runspec.rs b/src/runspec.rs
index 2149fd5..b2587ea 100644
--- a/src/runspec.rs
+++ b/src/runspec.rs
@@ -1,6 +1,5 @@
use std::path::{Path, PathBuf};
-use log::{debug, error};
use serde::Deserialize;
use crate::logfile::LogError;
@@ -18,12 +17,10 @@ pub struct RunSpec {
impl RunSpec {
/// Read run specification from a file.
pub fn from_file(filename: &Path) -> Result<Self, RunSpecError> {
- debug!("loading CI run spec from {}", filename.display());
let file = std::fs::File::open(filename)
.map_err(|e| RunSpecError::ReadRunSpec(filename.into(), e))?;
let runspec: RunSpec = serde_yaml::from_reader(&file)
.map_err(|e| RunSpecError::ParseRunSpec(filename.into(), e))?;
- debug!("runspec: {:#?}", runspec);
Ok(runspec)
}
}