1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use crate::{config_enum, config_struct, is_false};
use moon_common::Id;
use schematic::{Config, env};
config_enum!(
/// Toggles the state of actions within the pipeline.
#[derive(Config)]
#[serde(untagged)]
pub enum PipelineActionSwitch {
Default,
Enabled(bool),
Only(Vec<Id>),
}
);
impl PipelineActionSwitch {
pub fn is_disabled(&self) -> bool {
match self {
Self::Default => false,
Self::Enabled(value) => !value,
Self::Only(list) => list.is_empty(),
}
}
pub fn is_enabled(&self, id: &Id) -> bool {
match self {
Self::Default => true,
Self::Enabled(value) => *value,
Self::Only(list) => list.contains(id),
}
}
}
impl From<bool> for PipelineActionSwitch {
fn from(value: bool) -> Self {
Self::Enabled(value)
}
}
config_struct!(
/// Configures aspects of the action pipeline.
#[derive(Config)]
pub struct PipelineConfig {
/// Automatically clean the cache after every task run.
/// @since 1.24.0
#[setting(default = true, env = "MOON_PIPELINE_AUTO_CLEAN_CACHE", parse_env = env::parse_bool)]
pub auto_clean_cache: bool,
/// The lifetime in which task outputs will be cached.
#[setting(default = "7 days", env = "MOON_PIPELINE_CACHE_LIFETIME")]
pub cache_lifetime: String,
/// Automatically inherit color settings for all tasks being ran.
#[setting(default = true)]
pub inherit_colors_for_piped_tasks: bool,
/// Run the `InstallDependencies` actions for each running task
/// when changes to lockfiles and manifests are detected.
/// @since 1.34.0
#[setting(nested)]
pub install_dependencies: PipelineActionSwitch,
/// A threshold in milliseconds in which to force kill running child
/// processes after the pipeline receives an external signal. A value
/// of 0 will not kill the process and let them run to completion.
#[setting(default = 2000, env = "MOON_PIPELINE_KILL_PROCESS_THRESHOLD")]
pub kill_process_threshold: u32,
/// Logs the task's command and arguments when running the task.
#[serde(default, skip_serializing_if = "is_false")]
pub log_running_command: bool,
/// Run the `SyncProject` actions in the pipeline for each owning project
/// of a running task.
/// @since 1.34.0
#[setting(nested)]
pub sync_projects: PipelineActionSwitch,
/// When creating `SyncProject` actions, recursively create a `SyncProject`
/// action for each project dependency, and link them as a relationship.
/// @since 1.34.0
#[setting(default = true)]
pub sync_project_dependencies: bool,
/// Run the `SyncWorkspace` action before all actions in the pipeline.
/// @since 1.34.0
#[setting(default = true)]
pub sync_workspace: bool,
}
);