diff --git a/ofborg/src/tasks/eval/generic.rs b/ofborg/src/tasks/eval/generic.rs new file mode 100644 index 0000000..f8462ae --- /dev/null +++ b/ofborg/src/tasks/eval/generic.rs @@ -0,0 +1,45 @@ +use ofborg::checkout::CachedProjectCo; +use ofborg::commitstatus::CommitStatus; +use ofborg::evalchecker::EvalChecker; +use ofborg::message::buildjob::BuildJob; +use std::path::Path; +use tasks::eval::{EvaluationStrategy, StepResult}; + +pub struct GenericStrategy {} +impl GenericStrategy { + pub fn new() -> GenericStrategy { + Self {} + } +} + +impl EvaluationStrategy for GenericStrategy { + fn pre_clone(&mut self) -> StepResult<()> { + Ok(()) + } + + fn on_target_branch(&mut self, _co: &Path, _status: &mut CommitStatus) -> StepResult<()> { + Ok(()) + } + + fn after_fetch(&mut self, _co: &CachedProjectCo) -> StepResult<()> { + Ok(()) + } + + fn merge_conflict(&mut self) {} + + fn after_merge(&mut self, _status: &mut CommitStatus) -> StepResult<()> { + Ok(()) + } + + fn evaluation_checks(&self) -> Vec { + vec![] + } + + fn all_evaluations_passed( + &mut self, + _co: &Path, + _status: &mut CommitStatus, + ) -> StepResult> { + Ok(vec![]) + } +} diff --git a/ofborg/src/tasks/eval/mod.rs b/ofborg/src/tasks/eval/mod.rs index 35a344b..74b7b2d 100644 --- a/ofborg/src/tasks/eval/mod.rs +++ b/ofborg/src/tasks/eval/mod.rs @@ -1,2 +1,33 @@ pub mod stdenvs; pub use self::stdenvs::Stdenvs; +mod nixpkgs; +pub use self::nixpkgs::NixpkgsStrategy; +mod generic; +pub use self::generic::GenericStrategy; +use ofborg::checkout::CachedProjectCo; +use ofborg::commitstatus::CommitStatus; +use ofborg::evalchecker::EvalChecker; +use ofborg::message::buildjob::BuildJob; +use std::path::Path; + +pub trait EvaluationStrategy { + fn pre_clone(&mut self) -> StepResult<()>; + fn on_target_branch(&mut self, co: &Path, status: &mut CommitStatus) -> StepResult<()>; + fn after_fetch(&mut self, co: &CachedProjectCo) -> StepResult<()>; + fn merge_conflict(&mut self); + fn after_merge(&mut self, status: &mut CommitStatus) -> StepResult<()>; + fn evaluation_checks(&self) -> Vec; + fn all_evaluations_passed( + &mut self, + co: &Path, + status: &mut CommitStatus, + ) -> StepResult>; +} + +type StepResult = Result; + +#[derive(Debug)] +pub enum Error { + Fail(String), + FailWithGist(String, String, String), +} diff --git a/ofborg/src/tasks/eval/nixpkgs.rs b/ofborg/src/tasks/eval/nixpkgs.rs new file mode 100644 index 0000000..cf30b9d --- /dev/null +++ b/ofborg/src/tasks/eval/nixpkgs.rs @@ -0,0 +1,45 @@ +use ofborg::checkout::CachedProjectCo; +use ofborg::commitstatus::CommitStatus; +use ofborg::evalchecker::EvalChecker; +use ofborg::message::buildjob::BuildJob; +use std::path::Path; +use tasks::eval::{EvaluationStrategy, StepResult}; + +pub struct NixpkgsStrategy {} +impl NixpkgsStrategy { + pub fn new() -> NixpkgsStrategy { + Self {} + } +} + +impl EvaluationStrategy for NixpkgsStrategy { + fn pre_clone(&mut self) -> StepResult<()> { + Ok(()) + } + + fn on_target_branch(&mut self, _co: &Path, _status: &mut CommitStatus) -> StepResult<()> { + Ok(()) + } + + fn after_fetch(&mut self, _co: &CachedProjectCo) -> StepResult<()> { + Ok(()) + } + + fn merge_conflict(&mut self) {} + + fn after_merge(&mut self, _status: &mut CommitStatus) -> StepResult<()> { + Ok(()) + } + + fn evaluation_checks(&self) -> Vec { + vec![] + } + + fn all_evaluations_passed( + &mut self, + _co: &Path, + _status: &mut CommitStatus, + ) -> StepResult> { + Ok(vec![]) + } +}