shrub_rs/models/
builtin.rs

1use crate::models::params::{KeyValueParam, S3CopyFile};
2
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6/// Describe how task failures should be indicated.
7#[derive(Serialize, Deserialize, Debug, Clone)]
8#[serde(rename_all = "lowercase")]
9pub enum EvgCommandType {
10    /// Failures should indicate a "test" failure.
11    Test,
12    /// Failures should indicate a "system" failure.
13    System,
14    /// Failures should indicate a "setup" failure.
15    Setup,
16}
17
18/// Visibility of files in S3.
19#[derive(Serialize, Deserialize, Debug, Clone)]
20#[serde(rename_all = "lowercase")]
21pub enum S3Visibility {
22    /// Allows anyone to see the file.
23    Public,
24
25    /// Only logged in users will be able to see the file.
26    Private,
27
28    /// Visible to logged in users, shared with a pre-signed URL.
29    Signed,
30
31    /// Hides the file from everyone.
32    None,
33}
34
35/// Describe which cloud provider should be used.
36#[derive(Serialize, Deserialize, Debug, Clone)]
37#[serde(rename_all = "lowercase")]
38pub enum CloudProvider {
39    /// Use Amazon EC2.
40    EC2,
41    /// Use docker.
42    Docker,
43}
44
45#[derive(Serialize, Deserialize, Debug, Clone)]
46#[serde(rename_all = "lowercase")]
47pub enum ScriptingHarness {
48    Python,
49    Python2,
50    Golang,
51    Roswell,
52}
53
54#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
55#[serde(untagged)]
56pub enum TimeoutValue {
57    Int(u64),
58    Expansion(String),
59}
60
61impl From<u64> for TimeoutValue {
62    fn from(item: u64) -> TimeoutValue {
63        TimeoutValue::Int(item)
64    }
65}
66
67impl From<&str> for TimeoutValue {
68    fn from(item: &str) -> TimeoutValue {
69        TimeoutValue::Expansion(item.to_string())
70    }
71}
72
73#[cfg(test)]
74mod timeout_value_tests {
75    use super::*;
76
77    #[test]
78    fn test_int_to_timeout_value() {
79        let timeout = TimeoutValue::from(42);
80
81        assert_eq!(TimeoutValue::Int(42), timeout);
82    }
83
84    #[test]
85    fn test_string_to_timeout_value() {
86        let timeout = TimeoutValue::from("${timeout_expansion}");
87
88        assert_eq!(
89            TimeoutValue::Expansion(String::from("${timeout_expansion}")),
90            timeout
91        );
92    }
93}
94
95/// Parameters describing how to extract files from a gzipped tarball.
96#[derive(Debug, Serialize, Deserialize, Clone)]
97pub struct ArchiveTargzExtractParams {
98    /// Path to tarball to extract.
99    pub path: String,
100    /// Path of directory to extract files to.
101    pub destination: String,
102    /// A list of filename globs to exclude.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub exclude_files: Option<Vec<String>>,
105}
106
107/// Parameters describing how to create a gzipped tarball.
108#[derive(Debug, Serialize, Deserialize, Clone)]
109pub struct ArchiveTargzPackParams {
110    /// The tgz files that will be created.
111    pub target: String,
112    /// The directory to compress.
113    pub source_dir: String,
114    /// A list of filename globs to include.
115    pub include: Vec<String>,
116    /// A list of filename globs to exclude.
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub exclude_files: Option<Vec<String>>,
119}
120
121/// Parameters describing how to attach artifacts to a task.
122#[derive(Debug, Serialize, Deserialize, Clone)]
123pub struct AttachArtifactsParams {
124    /// An array of gitignore file globs to attach.
125    pub files: Vec<String>,
126    /// Path to start process the files, relative to the working directory.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub prefix: Option<String>,
129
130    /// Don't fail if files are not found to attach.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub optional: Option<bool>,
133
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub ignore_artifacts_for_spawn: Option<bool>,
136}
137
138/// Parameters describing how to attach Evergreen test results format to task.
139#[derive(Debug, Serialize, Deserialize, Clone)]
140pub struct AttachResultsParams {
141    /// Path to a json file to parse and upload.
142    pub file_location: String,
143}
144
145/// Parameters describing how to attach XUnit test results format to task.
146#[derive(Debug, Serialize, Deserialize, Clone)]
147pub struct AttachXUnitResultsParams {
148    /// Path to a xunit file to parse and upload.
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub file: Option<String>,
151
152    /// List of paths to a xunit file to parse and upload.
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub files: Option<Vec<String>>,
155}
156
157/// Parameters describing how to update task expansions at runtime.
158#[derive(Debug, Serialize, Deserialize, Clone)]
159pub struct ExpansionsUpdateParams {
160    /// key-value pairs for updating the task's expansions.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub updates: Option<Vec<KeyValueParam>>,
163
164    /// Path to yaml file containing expansion updates.
165    #[serde(skip_serializing_if = "Option::is_none")]
166    pub file: Option<String>,
167
168    /// Do not error if the file is missing.
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub ignore_missing_file: Option<bool>,
171
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub env: Option<HashMap<String, String>>,
174}
175
176/// Parameters describing how to write task's expansions to a file.
177#[derive(Debug, Serialize, Deserialize, Clone)]
178pub struct ExpansionsWriteParams {
179    /// Path to file to write expansions to.
180    pub file: String,
181
182    /// Include redacted landscape variable.
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub redacted: Option<bool>,
185}
186
187/// Parameters describing how to generate dynamic tasks.
188#[derive(Debug, Serialize, Deserialize, Clone)]
189pub struct GenerateTasksParams {
190    /// List of json files to generate tasks from.
191    pub files: Vec<String>,
192}
193
194/// Parameters describing how to clone tracked landscape and apply revision associated with task.
195#[derive(Debug, Serialize, Deserialize, Clone)]
196pub struct GitGetProjectParams {
197    /// Directory to clone repository into.
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub directory: Option<String>,
200
201    /// Token to use to clone instead of ssh key on host.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub token: Option<String>,
204
205    /// Map of revisions to use for any modules.
206    #[serde(skip_serializing_if = "Option::is_none")]
207    pub revisions: Option<HashMap<String, String>>,
208}
209
210/// Parameters describing how to dynamically generate a short lived github access token.
211#[derive(Debug, Serialize, Deserialize, Clone)]
212pub struct GitHubGenerateTokenParams {
213    /// The account owner of the repository.
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub owner: Option<String>,
216
217    /// The name of the repository without the .git extension.
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub repo: Option<String>,
220
221    /// The name for the expansion the token will be saved in.
222    pub expansion_name: String,
223
224    /// Which permissions it should be restricted to.
225    #[serde(skip_serializing_if = "Option::is_none")]
226    pub permissions: Option<HashMap<String, String>>,
227}
228
229/// Parameters describing how to parse gotest results and attach them to the task.
230#[derive(Debug, Serialize, Deserialize, Clone)]
231pub struct GotestParseFilesParams {
232    /// List of globs to parse and attach.
233    pub files: Vec<String>,
234}
235
236#[derive(Debug, Serialize, Deserialize, Clone)]
237#[serde(rename_all = "lowercase")]
238pub enum HostScope {
239    /// Tear down host when task is finished.
240    Task,
241
242    /// Tear down host when build is finished.
243    Build,
244}
245
246/// Description of an EBS block device.
247#[derive(Debug, Serialize, Deserialize, Clone)]
248pub struct EbsDevice {
249    pub device_name: String,
250    pub ebs_iops: u64,
251    pub ebs_size: u64,
252    pub ebs_snapshot_id: String,
253}
254
255/// Docker registry settings.
256#[derive(Debug, Serialize, Deserialize, Clone)]
257pub struct RegistrySettings {
258    /// Registry to pull image from.
259    pub registry_name: String,
260
261    /// Username for the registry.
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub registry_username: Option<String>,
264
265    /// Password for the registry.
266    #[serde(skip_serializing_if = "Option::is_none")]
267    pub registry_password: Option<String>,
268}
269
270/// Parameters describing how to start a new host from a task.
271#[derive(Debug, Serialize, Deserialize, Clone)]
272pub struct HostCreateParams {
273    /// Name of a file containing all the parameters.
274    #[serde(skip_serializing_if = "Option::is_none")]
275    pub file: Option<String>,
276
277    // Agent Params
278    /// Number of hosts to start, between 1 and 10 defaults to 1.
279    #[serde(skip_serializing_if = "Option::is_none")]
280    pub num_hosts: Option<u16>,
281
282    /// Cloud Provider for host.
283    pub provider: CloudProvider,
284
285    /// How many times Evergreen should try to create this host.
286    #[serde(skip_serializing_if = "Option::is_none")]
287    pub retries: Option<u64>,
288
289    /// When Evergreen will tear down the host.
290    #[serde(skip_serializing_if = "Option::is_none")]
291    pub scope: Option<HostScope>,
292
293    /// Stop waiting for hosts to be ready when spawning.
294    #[serde(skip_serializing_if = "Option::is_none")]
295    pub timeout_setup_secs: Option<u64>,
296
297    /// Tear down this host after this many seconds.
298    #[serde(skip_serializing_if = "Option::is_none")]
299    pub timeout_teardown_secs: Option<u64>,
300
301    // EC2 Params
302    /// EC2 AMI to start.
303    #[serde(skip_serializing_if = "Option::is_none")]
304    pub ami: Option<String>,
305
306    /// AWS access key ID.
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub aws_access_key_id: Option<String>,
309
310    /// AWS secret key.
311    #[serde(skip_serializing_if = "Option::is_none")]
312    pub aws_secret_access_key: Option<String>,
313
314    /// Name of EBS device.
315    #[serde(skip_serializing_if = "Option::is_none")]
316    pub device_name: Option<String>,
317
318    /// Evergreen distro to start.
319    #[serde(skip_serializing_if = "Option::is_none")]
320    pub distro: Option<String>,
321
322    #[serde(skip_serializing_if = "Option::is_none")]
323    pub ebs_block_device: Option<EbsDevice>,
324
325    /// EC2 Instance type.
326    #[serde(skip_serializing_if = "Option::is_none")]
327    pub instance_type: Option<String>,
328
329    /// Indicates instance should only have IPv6 address.
330    #[serde(skip_serializing_if = "Option::is_none")]
331    pub ipv6: Option<bool>,
332
333    /// EC2 region.
334    #[serde(skip_serializing_if = "Option::is_none")]
335    pub region: Option<String>,
336
337    /// List of security groups to set.
338    #[serde(skip_serializing_if = "Option::is_none")]
339    pub security_group_ids: Option<Vec<String>>,
340
341    /// Swap a spot instance.
342    #[serde(skip_serializing_if = "Option::is_none")]
343    pub spot: Option<bool>,
344
345    /// Subnet ID for the VPC.
346    #[serde(skip_serializing_if = "Option::is_none")]
347    pub subnet_id: Option<String>,
348
349    /// Path to file to load as EC2 user data on boot.
350    #[serde(skip_serializing_if = "Option::is_none")]
351    pub userdata_file: Option<String>,
352
353    #[serde(skip_serializing_if = "Option::is_none")]
354    pub userdata_command: Option<String>,
355
356    /// Ec2 Key name.
357    #[serde(skip_serializing_if = "Option::is_none")]
358    pub key_name: Option<String>,
359
360    // docker settings.
361    /// Docker image to use.
362    #[serde(skip_serializing_if = "Option::is_none")]
363    pub image: Option<String>,
364
365    /// Command to run on the container.
366    #[serde(skip_serializing_if = "Option::is_none")]
367    pub command: Option<String>,
368
369    /// make ports available.
370    #[serde(skip_serializing_if = "Option::is_none")]
371    pub publish_ports: Option<bool>,
372
373    /// Information of registry to pull image from.
374    #[serde(skip_serializing_if = "Option::is_none")]
375    pub registry: Option<RegistrySettings>,
376
377    /// Set to wait for logs in the background.
378    #[serde(skip_serializing_if = "Option::is_none")]
379    pub background: Option<bool>,
380
381    /// Time to wait for the container to finish running.
382    #[serde(skip_serializing_if = "Option::is_none")]
383    pub container_wait_timeout_secs: Option<u64>,
384
385    /// Check for running container and logs at this interval.
386    #[serde(skip_serializing_if = "Option::is_none")]
387    pub pool_frequency_secs: Option<u64>,
388
389    /// Path to write stdout logs from the container.
390    #[serde(skip_serializing_if = "Option::is_none")]
391    pub stdout_file_name: Option<String>,
392
393    /// Path to write stderr logs from the container.
394    #[serde(skip_serializing_if = "Option::is_none")]
395    pub stderr_file_name: Option<String>,
396
397    /// Map of environment variables to pass to container.
398    #[serde(skip_serializing_if = "Option::is_none")]
399    pub environment_vars: Option<HashMap<String, String>>,
400}
401
402/// Parameters describing how to get information about hosts previously created.
403#[derive(Debug, Serialize, Deserialize, Clone)]
404pub struct HostListParams {
405    /// If `wait` is set, the number of hosts to wait to be running before returning.
406    pub num_hosts: u64,
407    /// Path of file to write host info to.
408    #[serde(skip_serializing_if = "Option::is_none")]
409    pub path: Option<String>,
410    /// Time to wait for `num_hosts` to be running.
411    pub timeout_seconds: u64,
412    /// If true, wait for `num_hosts` to be running.
413    pub wait: bool,
414    /// If true, do not log host info to the task logs.
415    #[serde(skip_serializing_if = "Option::is_none")]
416    pub silent: Option<bool>,
417}
418
419/// Parameters describing how to save json-formatted task data.
420#[derive(Debug, Serialize, Deserialize, Clone)]
421pub struct JsonSendParams {
422    /// Json file to save.
423    pub file: String,
424
425    /// Name of the file you're saving.
426    pub name: String,
427}
428
429/// Parameters describing how to increment a key val.
430#[derive(Debug, Serialize, Deserialize, Clone)]
431pub struct KeyValIncParams {
432    pub destination: String,
433    pub key: String,
434}
435
436/// Parameters describing how to send perf results to cedar.
437#[derive(Debug, Serialize, Deserialize, Clone)]
438pub struct PerfSendParams {
439    /// Json or yaml file containing test results.
440    pub file: String,
441
442    /// AWS key to upload file with.
443    pub aws_key: String,
444
445    /// AWS secret to upload file with.
446    pub aws_secret: String,
447
448    /// S3 bucket to upload to.
449    pub bucket: String,
450
451    /// Prefix within the S3 bucket.
452    pub prefix: String,
453
454    /// AWS region of the bucket.
455    #[serde(skip_serializing_if = "Option::is_none")]
456    pub region: Option<String>,
457}
458
459/// Parameters describing how to set downstream expansions.
460#[derive(Debug, Serialize, Deserialize, Clone)]
461pub struct DownstreamExpansionsSetParams {
462    // Filename to read the expansions from
463    pub file: String,
464}
465
466/// Parameters describing how to set downstream expansions.
467#[derive(Debug, Serialize, Deserialize, Clone)]
468pub struct EC2AssumeRoleParams {
469    // ARN of the role you want to assume
470    pub role_arn: String,
471
472    // String in JSON format that you want to use as an inline session policy
473    #[serde(skip_serializing_if = "Option::is_none")]
474    pub policy: Option<String>,
475
476    // How long the returned credentials will be valid (default 900)
477    #[serde(skip_serializing_if = "Option::is_none")]
478    pub duration_seconds: Option<u64>,
479}
480
481/// Parameters describing how to download a file from S3.
482#[derive(Debug, Serialize, Deserialize, Clone)]
483pub struct S3GetParams {
484    /// Local file to save.
485    pub local_file: Option<String>,
486
487    /// Local directory to save to.
488    pub extract_to: Option<String>,
489
490    /// S3 Path to get file from.
491    pub remote_file: String,
492
493    /// S3 bucket to upload to.
494    pub bucket: String,
495
496    // List of build variants to run command for.
497    #[serde(skip_serializing_if = "Option::is_none")]
498    pub build_variants: Option<Vec<String>>,
499
500    // The collection of fields that are used to authenticate to s3
501    #[serde(flatten)]
502    auth_mode: S3AuthMode,
503}
504
505/// Parameters describing how to upload a file from S3.
506#[derive(Debug, Serialize, Deserialize, Clone)]
507pub struct S3PutParams {
508    /// Local file to upload.
509    #[serde(skip_serializing_if = "Option::is_none")]
510    pub local_file: Option<String>,
511
512    /// List of globs to indicate files to upload.
513    #[serde(skip_serializing_if = "Option::is_none")]
514    pub local_files_include_filter: Option<Vec<String>>,
515
516    /// Path to where to start looking for `local_files_include_filter`.
517    #[serde(skip_serializing_if = "Option::is_none")]
518    pub local_files_include_filter_prefix: Option<String>,
519
520    /// S3 Path to upload to.
521    pub remote_file: String,
522
523    /// S3 bucket to upload to.
524    pub bucket: String,
525
526    /// Permission string to upload with.
527    pub permissions: String,
528
529    /// The MIME type of the file.
530    pub content_type: String,
531
532    /// Display string for file in the Evergreen UI.
533    #[serde(skip_serializing_if = "Option::is_none")]
534    pub display_name: Option<String>,
535
536    /// If true, do not fail if file is not found.
537    #[serde(skip_serializing_if = "Option::is_none")]
538    pub optional: Option<bool>,
539
540    // AWS region for this bucket.
541    #[serde(skip_serializing_if = "Option::is_none")]
542    pub region: Option<String>,
543
544    // AWS visibility of uploaded file.
545    #[serde(skip_serializing_if = "Option::is_none")]
546    pub visibility: Option<String>,
547
548    // Use S3 conditional writes to skip updating the file if it already exists
549    #[serde(skip_serializing_if = "Option::is_none")]
550    pub skip_existing: Option<StringOrBool>,
551
552    // The collection of fields that are used to authenticate to s3
553    #[serde(flatten)]
554    auth_mode: S3AuthMode,
555}
556
557#[derive(Clone, Debug, Serialize, Deserialize)]
558#[serde(untagged)]
559pub enum S3AuthMode {
560    AutomaticAssumeRole{
561        // The AWS IAM role to assume before running this operation
562        role_arn: String,
563    },
564    PreviouslyAssumedRole{
565        /// AWS key to auth to s3.
566        aws_key: String,
567
568        /// AWS secret to auth to s3.
569        aws_secret: String,
570
571        /// AWS session token to auth to s3.
572        aws_session_token: String,
573    },
574    StaticCredentials{
575        /// AWS key to auth to s3.
576        aws_key: String,
577
578        /// AWS secret to auth to s3.
579        aws_secret: String,
580    },
581}
582
583// Use this enum in cases where Evergreen accepts either a string or a boolean
584// in yaml for inputs.
585#[derive(Debug, Serialize, Deserialize, Clone)]
586#[serde(untagged)]
587pub enum StringOrBool {
588    Bool(bool),
589    String(String),
590}
591
592/// Parameters describing how to copy an S3 file.
593#[derive(Debug, Serialize, Deserialize, Clone)]
594pub struct S3CopyParams {
595    /// S3 Files to copy.
596    pub s3_copy_files: Vec<S3CopyFile>,
597
598    /// AWS key to use to download file.
599    pub aws_key: String,
600
601    /// AWS secret to use to download file.
602    pub aws_secret: String,
603}
604
605/// Parameters describing how to run a shell script.
606#[derive(Debug, Serialize, Deserialize, Clone)]
607pub struct ShellExecParams {
608    /// Script to run.
609    pub script: String,
610
611    /// Directory to execute shell script in.
612    #[serde(skip_serializing_if = "Option::is_none")]
613    pub working_dir: Option<String>,
614
615    /// Map of environment variables and their values.
616    #[serde(skip_serializing_if = "Option::is_none")]
617    pub env: Option<HashMap<String, String>>,
618
619    /// If true, add all expansions to shell's env.
620    #[serde(skip_serializing_if = "Option::is_none")]
621    pub add_expansions_to_env: Option<bool>,
622
623    /// Specify 1 or more expansions to include in the shell's env.
624    #[serde(skip_serializing_if = "Option::is_none")]
625    pub include_expansions_in_env: Option<Vec<String>>,
626
627    /// If true, do not wait for script to exit before running next command.
628    #[serde(skip_serializing_if = "Option::is_none")]
629    pub background: Option<bool>,
630
631    /// If true, does not log any shell output during execution.
632    #[serde(skip_serializing_if = "Option::is_none")]
633    pub silent: Option<bool>,
634
635    /// If true, causes command to be marked as success regardless of script's exit code.
636    #[serde(skip_serializing_if = "Option::is_none")]
637    pub continue_on_err: Option<bool>,
638
639    /// If true, scripts output will be written to task's system logs instead of test logs.
640    #[serde(skip_serializing_if = "Option::is_none")]
641    pub system_log: Option<bool>,
642
643    /// Shell to use.
644    #[serde(skip_serializing_if = "Option::is_none")]
645    pub shell: Option<String>,
646
647    /// If true, discard output sent to stdout.
648    #[serde(skip_serializing_if = "Option::is_none")]
649    pub ignore_standard_out: Option<bool>,
650
651    /// If true, discard output sent to stderr.
652    #[serde(skip_serializing_if = "Option::is_none")]
653    pub ignore_standard_error: Option<bool>,
654
655    /// If true, send stderr to stdout.
656    #[serde(skip_serializing_if = "Option::is_none")]
657    pub redirect_standard_error_to_output: Option<bool>,
658}
659
660/// Parameters describing how to run a shell script.
661#[derive(Debug, Serialize, Deserialize, Clone)]
662pub struct PapertrailTraceParams {
663    /// Directory to run command in.
664    #[serde(skip_serializing_if = "Option::is_none")]
665    pub work_dir: Option<String>,
666
667    /// Papertrail key ID.
668    pub key_id: String,
669
670    /// Papertrail secret key.
671    pub secret_key: String,
672
673    /// Papertrail product name.
674    pub product: String,
675
676    /// Version of the product that traced files belong to.
677    pub version: String,
678
679    /// List of filenames that should be traced by this command.
680    pub filenames: Vec<String>,
681}
682
683/// Parameters common to SubprocessExec and SubprocessScripting.
684#[derive(Debug, Serialize, Deserialize, Clone)]
685pub struct SubprocessExecutionConfig {
686    /// If true, does not log any shell output during execution.
687    #[serde(skip_serializing_if = "Option::is_none")]
688    pub silent: Option<bool>,
689
690    /// If true, causes command to be marked as success regardless of script's exit code.
691    #[serde(skip_serializing_if = "Option::is_none")]
692    pub continue_on_err: Option<bool>,
693
694    /// If true, scripts output will be written to task's system logs instead of test logs.
695    #[serde(skip_serializing_if = "Option::is_none")]
696    pub system_log: Option<bool>,
697
698    /// If true, discard output sent to stdout.
699    #[serde(skip_serializing_if = "Option::is_none")]
700    pub ignore_standard_out: Option<bool>,
701
702    /// If true, discard output sent to stderr.
703    #[serde(skip_serializing_if = "Option::is_none")]
704    pub ignore_standard_error: Option<bool>,
705
706    /// If true, send stderr to stdout.
707    #[serde(skip_serializing_if = "Option::is_none")]
708    pub redirect_standard_error_to_output: Option<bool>,
709
710    /// List of paths to prepend to PATH.
711    #[serde(skip_serializing_if = "Option::is_none")]
712    pub add_to_path: Option<Vec<String>>,
713
714    /// If true, add all expansions to shell's env.
715    #[serde(skip_serializing_if = "Option::is_none")]
716    pub add_expansions_to_env: Option<bool>,
717
718    /// Specify 1 or more expansions to include in the shell's env.
719    #[serde(skip_serializing_if = "Option::is_none")]
720    pub include_expansions_in_env: Option<Vec<String>>,
721}
722
723/// Parameters describing how to run a binary file.
724#[derive(Debug, Serialize, Deserialize, Clone)]
725pub struct SubprocessExecParams {
726    /// Binary to run.
727    #[serde(skip_serializing_if = "Option::is_none")]
728    pub binary: Option<String>,
729
730    /// Arguments to pass to binary.
731    #[serde(skip_serializing_if = "Option::is_none")]
732    pub args: Option<Vec<String>>,
733
734    /// Command String.
735    #[serde(skip_serializing_if = "Option::is_none")]
736    pub command: Option<String>,
737
738    /// Directory to execute shell script in.
739    #[serde(skip_serializing_if = "Option::is_none")]
740    pub working_dir: Option<String>,
741
742    /// Map of environment variables and their values.
743    #[serde(skip_serializing_if = "Option::is_none")]
744    pub env: Option<HashMap<String, String>>,
745
746    /// If true, do not wait for script to exit before running next command.
747    #[serde(skip_serializing_if = "Option::is_none")]
748    pub background: Option<bool>,
749
750    /// Shell to use.
751    #[serde(skip_serializing_if = "Option::is_none")]
752    pub shell: Option<String>,
753
754    /// Execution configuration.
755    #[serde(flatten)]
756    pub execution_config: SubprocessExecutionConfig,
757}
758
759#[derive(Debug, Serialize, Deserialize, Clone)]
760pub struct ScriptingTestOptions {
761    /// Name of test
762    #[serde(skip_serializing_if = "Option::is_none")]
763    pub name: Option<String>,
764
765    /// Any additional argument to the test binary.
766    #[serde(skip_serializing_if = "Option::is_none")]
767    pub args: Option<Vec<String>>,
768
769    /// Filter names of tests to run based on this pattern.
770    #[serde(skip_serializing_if = "Option::is_none")]
771    pub pattern: Option<String>,
772
773    #[serde(skip_serializing_if = "Option::is_none")]
774    pub timeout_secs: Option<u64>,
775
776    /// The number of times test should be run.
777    #[serde(skip_serializing_if = "Option::is_none")]
778    pub count: Option<u64>,
779}
780
781/// Parameters describing how to execute a command insdie a scripting harness.
782#[derive(Debug, Serialize, Deserialize, Clone)]
783pub struct SubprocessScriptingParams {
784    /// Scripting harness to use.
785    pub harness: ScriptingHarness,
786
787    /// Commandline args as a to run.
788    #[serde(skip_serializing_if = "Option::is_none")]
789    pub command: Option<String>,
790
791    /// Commandline args as a to run.
792    #[serde(skip_serializing_if = "Option::is_none")]
793    pub args: Option<Vec<String>>,
794
795    /// Directory where tets should be run.
796    #[serde(skip_serializing_if = "Option::is_none")]
797    pub test_dir: Option<String>,
798
799    /// Describes how to tests in test_dir will be executed.
800    #[serde(skip_serializing_if = "Option::is_none")]
801    pub test_options: Option<ScriptingTestOptions>,
802
803    /// Total number of seconds environment should be stored for.
804    #[serde(skip_serializing_if = "Option::is_none")]
805    pub cache_duration_secs: Option<u64>,
806
807    /// Indicates that harness should not be reused between executions.
808    #[serde(skip_serializing_if = "Option::is_none")]
809    pub cleanup_harness: Option<bool>,
810
811    /// Lockfile describing dependencies.
812    #[serde(skip_serializing_if = "Option::is_none")]
813    pub lock_file: Option<String>,
814
815    /// List of dependencies to install.
816    #[serde(skip_serializing_if = "Option::is_none")]
817    pub packages: Option<Vec<String>>,
818
819    /// Path to hosting interpreter or binary.
820    #[serde(skip_serializing_if = "Option::is_none")]
821    pub harness_path: Option<String>,
822
823    /// Execution configuration.
824    #[serde(flatten)]
825    pub execution_config: SubprocessExecutionConfig,
826}
827
828/// Parameters describing how to set timeouts for the current task.
829#[derive(Debug, Serialize, Deserialize, Clone)]
830pub struct TimeoutUpdateParams {
831    /// Set the maximum time a task can run.
832    #[serde(skip_serializing_if = "Option::is_none")]
833    pub exec_timeout_secs: Option<TimeoutValue>,
834
835    /// Set the maximum time that can elapse with no output to stdout.
836    #[serde(skip_serializing_if = "Option::is_none")]
837    pub timeout_secs: Option<TimeoutValue>,
838}
839
840/// Built-in Evergreen Commands.
841#[derive(Debug, Serialize, Deserialize, Clone)]
842#[serde(tag = "command", content = "params")]
843pub enum EvgCommandSpec {
844    /// Extract files from a a gzipped tarball.
845    #[serde(rename = "archive.targz_extract")]
846    ArchiveTargzExtract(ArchiveTargzExtractParams),
847
848    /// Create a tar-gzipped file.
849    #[serde(rename = "archive.targz_pack")]
850    ArchiveTargzPack(ArchiveTargzPackParams),
851
852    #[serde(rename = "archive.auto_extract")]
853    ArchiveAutoExtract,
854
855    /// Upload files to be include in the "Files" section of a task.
856    #[serde(rename = "attach.artifacts")]
857    AttachArtifacts(AttachArtifactsParams),
858
859    /// Parse test results in Evergreen's JSON test format and attach to task.
860    #[serde(rename = "attach.results")]
861    AttachResults(AttachResultsParams),
862
863    /// Parse test results in XUnit format and attach to task.
864    #[serde(rename = "attach.xunit_results")]
865    AttachXUnitResults(AttachXUnitResultsParams),
866
867    /// Update the task's expansions at runtime.
868    #[serde(rename = "expansions.update")]
869    ExpansionsUpdate(Option<ExpansionsUpdateParams>),
870
871    /// Write the task's expansions to a file.
872    #[serde(rename = "expansions.write")]
873    ExpansionsWrite(ExpansionsWriteParams),
874
875    /// Dynamically generate tasks from a provided json file.
876    #[serde(rename = "generate.tasks")]
877    GenerateTasks(GenerateTasksParams),
878
879    /// Clone the tracked landscape and apply revision associated with task.
880    #[serde(rename = "git.get_project")]
881    GitGetProject(Option<GitGetProjectParams>),
882
883    /// Clone the tracked landscape and apply revision associated with task.
884    #[serde(rename = "github.generate_token")]
885    GitHubGenerateToken(GitHubGenerateTokenParams),
886
887    /// Parse gotest results and attach them to the task.
888    #[serde(rename = "gotest.parse_files")]
889    GotestParseFiles(GotestParseFilesParams),
890
891    /// Start a new evergreen host.
892    #[serde(rename = "host.create")]
893    HostCreate(HostCreateParams),
894
895    /// Get information about hosts create with 'hosts.create'.
896    #[serde(rename = "host.list")]
897    HostList(HostListParams),
898
899    /// Save json-formatted task data to the task.
900    #[serde(rename = "json.send")]
901    JsonSend(JsonSendParams),
902
903    #[serde(rename = "keyval.inc")]
904    KeyValInc(KeyValIncParams),
905
906    /// Update landscape expansions with the manifest.
907    #[serde(rename = "manifest.load")]
908    ManifestLoad,
909
910    /// Send performance test data to Cedar.
911    #[serde(rename = "perf.send")]
912    PerfSend(PerfSendParams),
913
914    // Takes the key-value pairs written in the file and makes them available to the child patches.
915    #[serde(rename = "downstream_expansions.set")]
916    DownstreamExpansionsSet(DownstreamExpansionsSetParams),
917
918    // Calls the aws assumeRole API and returns credentials as expansions.
919    #[serde(rename = "ec2.assume_role")]
920    EC2AssumeRole(EC2AssumeRoleParams),
921
922    /// Download a file from S3.
923    #[serde(rename = "s3.get")]
924    S3Get(S3GetParams),
925
926    /// Upload a file to S3.
927    #[serde(rename = "s3.put")]
928    S3Put(S3PutParams),
929
930    /// Copies a file from one S3 location to another.
931    #[serde(rename = "s3Copy.copy")]
932    S3Copy(S3CopyParams),
933
934    /// Execute the provided shell script.
935    #[serde(rename = "shell.exec")]
936    ShellExec(ShellExecParams),
937
938    /// Trace the provided artifacts.
939    #[serde(rename = "papertrail.trace")]
940    PapertrailExec(PapertrailTraceParams),
941
942    /// Execute the specified binary.
943    #[serde(rename = "subprocess.exec")]
944    SubprocessExec(SubprocessExecParams),
945
946    /// Execute a command inside a scripting harness.
947    #[serde(rename = "subprocess.scripting")]
948    SubprocessScripting(SubprocessScriptingParams),
949
950    /// Set the timeouts for the current task.
951    #[serde(rename = "timeout.update")]
952    TimeoutUpdate(TimeoutUpdateParams),
953}
954
955#[derive(Debug, Serialize, Deserialize, Clone)]
956pub struct BuiltInCommand {
957    /// Description the built-in command to run.
958    #[serde(flatten)]
959    pub command: EvgCommandSpec,
960
961    /// How command status should be indicated.
962    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
963    pub command_type: Option<EvgCommandType>,
964
965    #[serde(skip_serializing_if = "Option::is_none")]
966    pub params_yaml: Option<String>,
967}