forked from the-distro/ofborg
eval: initialize nixpkgs and generic evaluation strategies, based on a trait developed in a different iteration
This commit is contained in:
parent
9c83a06ab1
commit
379761c036
45
ofborg/src/tasks/eval/generic.rs
Normal file
45
ofborg/src/tasks/eval/generic.rs
Normal file
|
@ -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<EvalChecker> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn all_evaluations_passed(
|
||||
&mut self,
|
||||
_co: &Path,
|
||||
_status: &mut CommitStatus,
|
||||
) -> StepResult<Vec<BuildJob>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
|
@ -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<EvalChecker>;
|
||||
fn all_evaluations_passed(
|
||||
&mut self,
|
||||
co: &Path,
|
||||
status: &mut CommitStatus,
|
||||
) -> StepResult<Vec<BuildJob>>;
|
||||
}
|
||||
|
||||
type StepResult<T> = Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Fail(String),
|
||||
FailWithGist(String, String, String),
|
||||
}
|
||||
|
|
45
ofborg/src/tasks/eval/nixpkgs.rs
Normal file
45
ofborg/src/tasks/eval/nixpkgs.rs
Normal file
|
@ -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<EvalChecker> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn all_evaluations_passed(
|
||||
&mut self,
|
||||
_co: &Path,
|
||||
_status: &mut CommitStatus,
|
||||
) -> StepResult<Vec<BuildJob>> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue