mirror of
https://seed.radicle.dev/rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE.git
synced 2026-11-03 18:30:43 +08:00
adapt to new trigger message structure in broker
This commit is contained in:
Generated
+662
-53
File diff suppressed because it is too large
Load Diff
+12
-1
@@ -33,6 +33,7 @@ impl Engine {
|
||||
/// not existing. The caller should handle the error in some
|
||||
/// suitable way, such as report that to its stderr, and exit
|
||||
/// non-zero.
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn new() -> Result<Self, EngineError> {
|
||||
// Get config, open admin log for writing. If either of these
|
||||
// fails, we can't write about the problem to the admin log,
|
||||
@@ -53,6 +54,7 @@ impl Engine {
|
||||
/// from stdin, write responses to stdout. Update node admin log
|
||||
/// with any problems that aren't inherent in the git repository
|
||||
/// (those go into the run log).
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn run(&mut self) -> Result<bool, EngineError> {
|
||||
let req = match self.setup() {
|
||||
Ok(req) => req,
|
||||
@@ -65,7 +67,10 @@ impl Engine {
|
||||
// Check that we got the right kind of request.
|
||||
let mut success = false;
|
||||
match req {
|
||||
Request::Trigger { repo, commit } => {
|
||||
Request::Trigger { .. } => {
|
||||
let repo = req.repo();
|
||||
let commit = req.commit();
|
||||
|
||||
self.run_info_builder.repo(repo);
|
||||
self.run_info_builder.commit(commit);
|
||||
match self.run_helper(repo, commit) {
|
||||
@@ -100,6 +105,7 @@ impl Engine {
|
||||
|
||||
// Set up CI to run. If something goes wrong, return the error,
|
||||
// and assume the caller logs it to the admin log.
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn setup(&mut self) -> Result<Request, EngineError> {
|
||||
// Write something to the admin log to indicate we start.
|
||||
self.adminlog.writeln("Native CI run starts")?;
|
||||
@@ -113,6 +119,7 @@ impl Engine {
|
||||
|
||||
// Finish up after a CI run. If something goes wrong, return the
|
||||
// error, and assume the caller logs it to the admin log.
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn finish(&mut self) -> Result<(), EngineError> {
|
||||
// Write response message indicating the run has finished.
|
||||
let ri = self.run_info_builder.build()?;
|
||||
@@ -140,6 +147,7 @@ impl Engine {
|
||||
|
||||
// Execute the CI run. Log any problems to a log for this run, and
|
||||
// persist that. Update the run info builder as needed.
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn run_helper(&mut self, rid: RepoId, commit: Oid) -> Result<bool, EngineError> {
|
||||
// Pick a run id and create a directory for files related to
|
||||
// the run.
|
||||
@@ -185,12 +193,14 @@ impl Engine {
|
||||
|
||||
/// Report results to caller (via stdout) and to users (via report
|
||||
/// on web page).
|
||||
#[allow(clippy::result_large_err)]
|
||||
pub fn report(&mut self) -> Result<(), EngineError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a per-run directory.
|
||||
#[allow(clippy::result_large_err)]
|
||||
fn mkdir_run(config: &Config) -> Result<(Uuid, PathBuf), EngineError> {
|
||||
let state = &config.state;
|
||||
if !state.exists() {
|
||||
@@ -204,6 +214,7 @@ fn mkdir_run(config: &Config) -> Result<(Uuid, PathBuf), EngineError> {
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum EngineError {
|
||||
#[error("failed to create per-run parent directory {0}")]
|
||||
CreateState(PathBuf, #[source] std::io::Error),
|
||||
|
||||
Reference in New Issue
Block a user