Skip to content

Commit

Permalink
Nomenclature update: error -> failure (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnmadelaine authored Feb 13, 2024
1 parent 6b9300b commit cfb1f1d
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 58 deletions.
16 changes: 1 addition & 15 deletions nix/lib/gitea/mkGiteaStatus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,7 @@ utils: lib: {
job_encoded=$(echo -n "$job" | jq '@uri' -sRr)
target_url="${typhon_url}/evaluation/$evaluation/$system_encoded/$job_encoded"
context="Typhon: $system / $job"
case $status in
"error")
state="failure"
;;
"pending")
state="pending"
;;
"success")
state="success"
;;
*)
state="error"
;;
esac
state="$status"
payload=$(echo null | jq \
--arg state "$state" \
Expand Down
16 changes: 1 addition & 15 deletions nix/lib/github/mkGithubStatus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,7 @@ utils: lib: {
job_encoded=$(echo -n "$job" | jq '@uri' -sRr)
target_url="${typhon_url}/evaluation/$evaluation/$system_encoded/$job_encoded"
context="Typhon: $system / $job"
case $status in
"error")
state="failure"
;;
"pending")
state="pending"
;;
"success")
state="success"
;;
*)
state="error"
;;
esac
state="$status"
payload=$(echo null | jq \
--arg state "$state" \
Expand Down
2 changes: 1 addition & 1 deletion typhon-core/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Action {
let status = match res {
Some(Err(_)) => {
let _ = finish(None);
TaskStatusKind::Error
TaskStatusKind::Failure
}
Some(Ok(stdout)) => finish(Some(stdout)),
None => {
Expand Down
2 changes: 1 addition & 1 deletion typhon-core/src/build_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn finish_build(drv: DrvPath, sender: mpsc::UnboundedSender<Msg>, res: Output) -
let _ = sender.send(Msg::Finished(drv, res.clone()));
match res {
Some(Some(())) => TaskStatusKind::Success,
Some(None) => TaskStatusKind::Error,
Some(None) => TaskStatusKind::Failure,
None => TaskStatusKind::Canceled,
}
}
Expand Down
4 changes: 2 additions & 2 deletions typhon-core/src/evaluations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ impl Evaluation {
match r {
Some(Ok(new_jobs)) => match self.create_new_jobs(&mut conn, new_jobs) {
Ok(()) => TaskStatusKind::Success,
Err(_) => TaskStatusKind::Error,
Err(_) => TaskStatusKind::Failure,
},
Some(Err(_)) => TaskStatusKind::Error,
Some(Err(_)) => TaskStatusKind::Failure,
None => TaskStatusKind::Canceled,
}
}
Expand Down
12 changes: 6 additions & 6 deletions typhon-core/src/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ impl Project {
Some(Ok(x)) => self_.finish_refresh(x),
Some(Err(e)) => {
tracing::warn!("refresh error for project {}: {}", self_.handle(), e);
Ok(TaskStatusKind::Error)
Ok(TaskStatusKind::Failure)
}
None => Ok(TaskStatusKind::Canceled),
};
(
status.unwrap_or(TaskStatusKind::Error),
status.unwrap_or(TaskStatusKind::Failure),
Event::ProjectUpdated(self_.handle()),
)
}
Expand Down Expand Up @@ -253,10 +253,10 @@ impl Project {
if self_.finish_update_jobsets(decls).is_ok() {
TaskStatusKind::Success
} else {
TaskStatusKind::Error
TaskStatusKind::Failure
}
}
Err(_) => TaskStatusKind::Error,
Err(_) => TaskStatusKind::Failure,
}
}
None => TaskStatusKind::Canceled,
Expand Down Expand Up @@ -305,12 +305,12 @@ impl Project {
}
Err(_) => {
let _ = sender.send(None);
TaskStatusKind::Error
TaskStatusKind::Failure
}
},
None => {
let _ = sender.send(None);
TaskStatusKind::Error
TaskStatusKind::Failure
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions typhon-core/src/runs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Run {
let res = build_handle.wait().await;
match res {
Some(Some(())) => TaskStatusKind::Success,
Some(None) => TaskStatusKind::Error,
Some(None) => TaskStatusKind::Failure,
None => TaskStatusKind::Canceled,
}
};
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Run {

let finish = move |res| match res {
Some(_) => TaskStatusKind::Success,
None => TaskStatusKind::Error,
None => TaskStatusKind::Failure,
};

action.spawn(conn, finish)?;
Expand Down
25 changes: 13 additions & 12 deletions typhon-types/src/task_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum TaskStatus {
/** The task is done and succeeded */
Success(TimeRange),
/** The task is done and failed */
Error(TimeRange),
Failure(TimeRange),
/** The task was canceled: either while running (then the payload
* is a `Some(TimeRange {start,end})`) or before running. */
// TODO: we should have either a TimeRange or a {end}, right?
Expand All @@ -38,7 +38,7 @@ pub enum TaskStatusKind {
#[default]
Pending = 0,
Success = 1,
Error = 2,
Failure = 2,
Canceled = 3,
}

Expand All @@ -61,7 +61,7 @@ impl From<&TaskStatus> for TaskStatusKind {
match status {
TaskStatus::Pending { .. } => Self::Pending,
TaskStatus::Success(..) => Self::Success,
TaskStatus::Error(..) => Self::Error,
TaskStatus::Failure(..) => Self::Failure,
TaskStatus::Canceled(..) => Self::Canceled,
}
}
Expand All @@ -75,7 +75,8 @@ impl From<TaskStatus> for TaskStatusKind {

const SUCCESS_TIME_INVARIANT: &str =
"a `TaskStatus::Success` requires a start time and an end time";
const ERROR_TIME_INVARIANT: &str = "a `TaskStatus::Error` requires a start time and an end time";
const FAILURE_TIME_INVARIANT: &str =
"a `TaskStatus::Failure` requires a start time and an end time";
impl TaskStatusKind {
/** Promotes a `TaskStatusKind` to a `TaskStatus`, given a start
* time and a finish time. Note those are optional: a success task
Expand All @@ -90,7 +91,7 @@ impl TaskStatusKind {
match self {
Self::Pending => TaskStatus::Pending { start },
Self::Success => TaskStatus::Success(range.expect(SUCCESS_TIME_INVARIANT)),
Self::Error => TaskStatus::Error(range.expect(ERROR_TIME_INVARIANT)),
Self::Failure => TaskStatus::Failure(range.expect(FAILURE_TIME_INVARIANT)),
Self::Canceled => TaskStatus::Canceled(range),
}
}
Expand All @@ -101,7 +102,7 @@ impl TaskStatus {
pub fn times(self) -> (Option<OffsetDateTime>, Option<OffsetDateTime>) {
match self {
Self::Pending { start } => (start, None),
Self::Success(range) | Self::Error(range) | Self::Canceled(Some(range)) => {
Self::Success(range) | Self::Failure(range) | Self::Canceled(Some(range)) => {
(Some(range.start), Some(range.end))
}
Self::Canceled(None) => (None, None),
Expand All @@ -116,7 +117,7 @@ impl TaskStatus {
let rhs_kind: TaskStatusKind = rhs.into();
let range = start.zip(end).map(|(start, end)| TimeRange { start, end });
match lhs_kind.max(rhs_kind) {
TaskStatusKind::Error => Self::Error(range.expect(ERROR_TIME_INVARIANT)),
TaskStatusKind::Failure => Self::Failure(range.expect(FAILURE_TIME_INVARIANT)),
TaskStatusKind::Pending => Self::Pending { start },
TaskStatusKind::Canceled => Self::Canceled(range),
TaskStatusKind::Success => Self::Success(range.expect(SUCCESS_TIME_INVARIANT)),
Expand All @@ -127,7 +128,7 @@ impl TaskStatus {
impl TryFrom<i32> for TaskStatusKind {
type Error = ();
fn try_from(n: i32) -> Result<TaskStatusKind, ()> {
let arr = [Self::Pending, Self::Success, Self::Error, Self::Canceled];
let arr = [Self::Pending, Self::Success, Self::Failure, Self::Canceled];
arr.get(n as usize).ok_or(()).copied()
}
}
Expand All @@ -142,7 +143,7 @@ impl std::fmt::Display for TaskStatusKind {
match self {
Self::Pending => write!(f, "pending"),
Self::Success => write!(f, "success"),
Self::Error => write!(f, "error"),
Self::Failure => write!(f, "failure"),
Self::Canceled => write!(f, "canceled"),
}
}
Expand All @@ -160,8 +161,8 @@ impl core::cmp::Ord for TaskStatusKind {
return Ordering::Equal;
}
match (self, rhs) {
(TaskStatusKind::Error, _) => Ordering::Greater,
(_, TaskStatusKind::Error) => Ordering::Less,
(TaskStatusKind::Failure, _) => Ordering::Greater,
(_, TaskStatusKind::Failure) => Ordering::Less,
(TaskStatusKind::Pending, _) => Ordering::Greater,
(_, TaskStatusKind::Pending) => Ordering::Less,
(TaskStatusKind::Canceled, _) => Ordering::Greater,
Expand Down Expand Up @@ -193,7 +194,7 @@ impl From<&crate::responses::RunInfo> for TaskStatus {
Some(TaskStatusKind::Success),
Some(TaskStatusKind::Success),
) => TaskStatusKind::Success,
_ => TaskStatusKind::Error,
_ => TaskStatusKind::Failure,
};
kind.into_task_status(start, end)
}
Expand Down
2 changes: 1 addition & 1 deletion typhon-webapp/src/components/evaluations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl EvalStatus {
TaskStatusKind::Success => HybridStatusKind::EvalSucceeded {
build: self.jobs.unwrap_or_default().into(),
},
TaskStatusKind::Error | TaskStatusKind::Canceled => HybridStatusKind::EvalStopped,
TaskStatusKind::Failure | TaskStatusKind::Canceled => HybridStatusKind::EvalStopped,
}
}
pub fn summary(&self) -> TaskStatus {
Expand Down
2 changes: 1 addition & 1 deletion typhon-webapp/src/components/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn HybridStatus(#[prop(into)] status: Signal<HybridStatusKind>) -> impl Into
match build {
TaskStatusKind::Success => BiCheckCircleSolid,
TaskStatusKind::Pending => BiLoaderAltRegular,
TaskStatusKind::Error => BiXCircleSolid,
TaskStatusKind::Failure => BiXCircleSolid,
TaskStatusKind::Canceled => BiStopCircleRegular,
}
}
Expand Down
2 changes: 1 addition & 1 deletion typhon-webapp/src/components/time_related.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn TaskStatusDuration(#[prop(into)] status: Signal<TaskStatus>) -> impl Into
view! {
<Duration duration=Signal::derive(move || match status() {
TaskStatus::Success(range)
| TaskStatus::Error(range)
| TaskStatus::Failure(range)
| TaskStatus::Canceled(Some(range)) => Some(range.into()),
TaskStatus::Pending { start: Some(start) } => {
let now = use_context::<crate::utils::CurrentTime>().unwrap().0;
Expand Down
2 changes: 1 addition & 1 deletion typhon-webapp/src/pages/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ pub fn JobSubpage(
}
}
TaskStatus::Success(..) => make("succeeded"),
TaskStatus::Error(..) => make("failed"),
TaskStatus::Failure(..) => make("failed"),
TaskStatus::Canceled(Some(..)) => make("canceled"),
TaskStatus::Canceled(None) => view! { <>canceled</> },
}
Expand Down

0 comments on commit cfb1f1d

Please sign in to comment.