radicle_ci_ambient/
lib.rs1#![allow(clippy::result_large_err)]
2
3use std::path::PathBuf;
4
5use ambient_ci::runlog::RunLogError;
6use radicle::prelude::RepoId;
7
8pub mod ambient;
9pub mod config;
10pub mod runlog;
11
12#[derive(Debug, thiserror::Error)]
13pub enum AdapterError {
14 #[error("failed to write message reporting run has been triggered")]
15 Triggered(#[source] radicle_ci_broker::msg::helper::MessageHelperError),
16
17 #[error("failed to write response message reporting success")]
18 Succeded(#[source] radicle_ci_broker::msg::helper::MessageHelperError),
19
20 #[error("failed to write response message reporting failure")]
21 Failed(#[source] radicle_ci_broker::msg::helper::MessageHelperError),
22
23 #[error("failed to read request from stdin")]
24 ReadRequest(#[source] radicle_ci_broker::msg::helper::MessageHelperError),
25
26 #[error(transparent)]
27 Config(#[from] crate::config::ConfigError),
28
29 #[error("failed to extract commit from request message")]
30 Commit(#[source] radicle_ci_broker::msg::MessageError),
31
32 #[error("failed to create a temporary directory")]
33 TempDir(#[source] std::io::Error),
34
35 #[error("failed to load Radicle profile")]
36 Profile(#[source] radicle::profile::Error),
37
38 #[error("failed to invoke command {0}")]
39 Invoke(&'static str, #[source] std::io::Error),
40
41 #[error("failed to run command {0}")]
42 Command(&'static str, #[source] std::io::Error),
43
44 #[error("failed to serialize Ambient project list to YAML")]
45 ToYaml(#[source] serde_norway::Error),
46
47 #[error("failed to serialize Ambient configuration value as YAML")]
48 AmbientConfigToYaml(#[source] serde_norway::Error),
49
50 #[error("failed to write Ambient project list to file")]
51 WriteProjects(#[source] std::io::Error),
52
53 #[error("failed to create directory {0}")]
54 CreateDirs(PathBuf, #[source] std::io::Error),
55
56 #[error("failed to write run log to file")]
57 WriteRunLog(PathBuf, #[source] std::io::Error),
58
59 #[error("failed to read CI plan from project {0}")]
60 ReadPlan(PathBuf, #[source] std::io::Error),
61
62 #[error("failed to parse CI plan as YAML fro file {0}")]
63 ParsePlan(PathBuf, #[source] serde_norway::Error),
64
65 #[error("failed to serialize trigger message as JSON")]
66 ToJson(#[source] serde_json::Error),
67
68 #[error("failed to write temporary configuration file")]
69 WriteConfig(#[source] std::io::Error),
70
71 #[error("failed to run ambient to get its configurarion")]
72 GetAmbientConfig,
73
74 #[error(transparent)]
75 AdminLog(#[from] radicle_ci_broker::msg::helper::LogError),
76
77 #[error(transparent)]
78 MessageHelper(#[from] radicle_ci_broker::msg::helper::MessageHelperError),
79
80 #[error("failed to measure how long CI run took")]
81 Elapsed(#[source] std::time::SystemTimeError),
82
83 #[error("programming error: field {0} is not set in RunInfoBuilder")]
84 Missing(&'static str),
85
86 #[error("failed to format time stamp")]
87 TimeOffset(#[source] std::time::SystemTimeError),
88
89 #[error("failed to format time stamp")]
90 Timestamp(#[source] time::error::Format),
91
92 #[error("failed to load identity doc for repository {0}")]
93 GetIdDoc(RepoId, #[source] radicle::storage::RepositoryError),
94
95 #[error("failed to get project information from repository identity doc")]
96 GetProject(#[source] radicle::identity::doc::PayloadError),
97
98 #[error("failed to create temporary directory on remote host {0}")]
99 Mkdtemp(String, #[source] clingwrap::runner::CommandError),
100
101 #[error("failed to parse JSON run log from Ambient")]
102 RunLog(#[source] RunLogError),
103}