pipeline-service 2.4.0

Pipeline execution service for roxid
Documentation
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
use serde::{Deserialize, Serialize};
use serde_json::Value;

use std::collections::HashMap;

/// A GitHub Actions-compatible workflow definition.
///
/// This represents the top-level structure of a workflow YAML file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Workflow {
    /// The name of the workflow (displayed in GitHub Actions UI)
    pub name: Option<String>,

    /// The trigger configuration for the workflow
    #[serde(rename = "on")]
    pub on: Trigger,

    /// Workflow-level environment variables
    #[serde(default)]
    pub env: HashMap<String, String>,

    /// Default settings for all jobs in the workflow
    #[serde(default)]
    pub defaults: Option<Defaults>,

    /// The jobs that make up this workflow
    pub jobs: HashMap<String, Job>,

    /// Permissions for the GITHUB_TOKEN (parsed but not enforced locally)
    #[serde(default)]
    pub permissions: Option<Permissions>,

    /// Concurrency settings (parsed but not enforced locally)
    #[serde(default)]
    pub concurrency: Option<Concurrency>,
}

/// Trigger configuration for when the workflow should run.
///
/// Supports multiple trigger formats:
/// - Simple: `on: push`
/// - List: `on: [push, pull_request]`
/// - Detailed: `on: { push: { branches: [main] } }`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Trigger {
    /// Single event trigger: `on: push`
    Single(String),

    /// Multiple events: `on: [push, pull_request]`
    Multiple(Vec<String>),

    /// Detailed event configuration
    Detailed(HashMap<String, Option<EventConfig>>),
}

/// Configuration for a specific trigger event.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EventConfig {
    /// Branch filters for push/pull_request events
    #[serde(default)]
    pub branches: Vec<String>,

    /// Branch ignore patterns
    #[serde(default, rename = "branches-ignore")]
    pub branches_ignore: Vec<String>,

    /// Tag filters for push events
    #[serde(default)]
    pub tags: Vec<String>,

    /// Tag ignore patterns
    #[serde(default, rename = "tags-ignore")]
    pub tags_ignore: Vec<String>,

    /// Path filters
    #[serde(default)]
    pub paths: Vec<String>,

    /// Path ignore patterns
    #[serde(default, rename = "paths-ignore")]
    pub paths_ignore: Vec<String>,

    /// Event types for events like issues, pull_request_review, etc.
    #[serde(default)]
    pub types: Vec<String>,

    /// Cron schedules for schedule events
    #[serde(default)]
    pub cron: Option<String>,

    /// Inputs for workflow_dispatch
    #[serde(default)]
    pub inputs: HashMap<String, WorkflowInput>,

    /// Outputs for workflow_call
    #[serde(default)]
    pub outputs: HashMap<String, WorkflowOutput>,

    /// Secrets for workflow_call
    #[serde(default)]
    pub secrets: HashMap<String, WorkflowSecret>,
}

/// Input definition for workflow_dispatch or workflow_call triggers.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkflowInput {
    /// Description of the input
    #[serde(default)]
    pub description: Option<String>,

    /// Whether the input is required
    #[serde(default)]
    pub required: bool,

    /// Default value for the input
    #[serde(default)]
    pub default: Option<Value>,

    /// Input type (string, boolean, choice, environment)
    #[serde(default, rename = "type")]
    pub input_type: Option<String>,

    /// Options for choice type inputs
    #[serde(default)]
    pub options: Vec<String>,
}

/// Output definition for workflow_call triggers.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkflowOutput {
    /// Description of the output
    #[serde(default)]
    pub description: Option<String>,

    /// Value expression for the output
    pub value: String,
}

/// Secret definition for workflow_call triggers.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkflowSecret {
    /// Description of the secret
    #[serde(default)]
    pub description: Option<String>,

    /// Whether the secret is required
    #[serde(default)]
    pub required: bool,
}

/// Default settings for jobs and steps.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Defaults {
    /// Default settings for run steps
    #[serde(default)]
    pub run: Option<RunDefaults>,
}

/// Default settings for run steps.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct RunDefaults {
    /// Default shell to use
    #[serde(default)]
    pub shell: Option<String>,

    /// Default working directory
    #[serde(default, rename = "working-directory")]
    pub working_directory: Option<String>,
}

/// Permissions configuration for GITHUB_TOKEN.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Permissions {
    /// Read-all or write-all
    Level(String),

    /// Granular permissions
    Granular(HashMap<String, String>),
}

/// Concurrency settings to limit workflow runs.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Concurrency {
    /// Simple concurrency group name
    Simple(String),

    /// Detailed concurrency configuration
    Detailed {
        group: String,
        #[serde(default, rename = "cancel-in-progress")]
        cancel_in_progress: bool,
    },
}

/// A job within a workflow.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Job {
    /// Display name for the job
    #[serde(default)]
    pub name: Option<String>,

    /// Jobs that must complete before this job runs
    #[serde(default)]
    pub needs: JobNeeds,

    /// Runner label (parsed but ignored locally - always runs locally)
    #[serde(default, rename = "runs-on")]
    pub runs_on: Option<RunsOn>,

    /// Conditional expression for job execution
    #[serde(default, rename = "if")]
    pub if_condition: Option<String>,

    /// Job-level environment variables
    #[serde(default)]
    pub env: HashMap<String, String>,

    /// Default settings for steps in this job
    #[serde(default)]
    pub defaults: Option<Defaults>,

    /// Job outputs to pass to dependent jobs
    #[serde(default)]
    pub outputs: HashMap<String, String>,

    /// Matrix strategy for running multiple job instances
    #[serde(default)]
    pub strategy: Option<Strategy>,

    /// The steps that make up this job
    #[serde(default)]
    pub steps: Vec<Step>,

    /// Service containers for the job
    #[serde(default)]
    pub services: HashMap<String, Service>,

    /// Container to run the job in
    #[serde(default)]
    pub container: Option<Container>,

    /// Job timeout in minutes
    #[serde(default, rename = "timeout-minutes")]
    pub timeout_minutes: Option<u32>,

    /// Whether to continue workflow if this job fails
    #[serde(default, rename = "continue-on-error")]
    pub continue_on_error: ContinueOnError,

    /// Permissions for this job's GITHUB_TOKEN
    #[serde(default)]
    pub permissions: Option<Permissions>,

    /// Concurrency settings for this job
    #[serde(default)]
    pub concurrency: Option<Concurrency>,

    /// Environment deployment target
    #[serde(default)]
    pub environment: Option<Environment>,
}

/// Job dependencies - can be a single string or a list.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(untagged)]
pub enum JobNeeds {
    #[default]
    None,
    Single(String),
    Multiple(Vec<String>),
}

impl JobNeeds {
    /// Convert to a vector of job IDs.
    pub fn to_vec(&self) -> Vec<String> {
        match self {
            JobNeeds::None => vec![],
            JobNeeds::Single(s) => vec![s.clone()],
            JobNeeds::Multiple(v) => v.clone(),
        }
    }

    /// Check if there are any dependencies.
    pub fn is_empty(&self) -> bool {
        match self {
            JobNeeds::None => true,
            JobNeeds::Single(_) => false,
            JobNeeds::Multiple(v) => v.is_empty(),
        }
    }
}

/// Runner specification - can be a string or a list of labels.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RunsOn {
    /// Single runner label: `runs-on: ubuntu-latest`
    Label(String),

    /// Multiple labels: `runs-on: [self-hosted, linux]`
    Labels(Vec<String>),

    /// Expression: `runs-on: ${{ matrix.os }}`
    Expression(String),
}

/// Continue-on-error setting - can be a boolean or an expression.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ContinueOnError {
    Bool(bool),
    Expression(String),
}

impl Default for ContinueOnError {
    fn default() -> Self {
        ContinueOnError::Bool(false)
    }
}

/// Strategy configuration for matrix builds.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Strategy {
    /// Matrix configuration
    #[serde(default)]
    pub matrix: Option<Matrix>,

    /// Whether to cancel all jobs if one fails
    #[serde(default = "default_fail_fast", rename = "fail-fast")]
    pub fail_fast: bool,

    /// Maximum number of jobs to run in parallel
    #[serde(default, rename = "max-parallel")]
    pub max_parallel: Option<u32>,
}

fn default_fail_fast() -> bool {
    true
}

/// Matrix configuration for parallel job execution.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Matrix {
    /// Matrix dimensions (dynamic keys)
    #[serde(flatten)]
    pub dimensions: HashMap<String, Vec<Value>>,

    /// Additional matrix combinations to include
    #[serde(default)]
    pub include: Vec<HashMap<String, Value>>,

    /// Matrix combinations to exclude
    #[serde(default)]
    pub exclude: Vec<HashMap<String, Value>>,
}

/// A step within a job.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Step {
    /// Unique identifier for the step (used in outputs)
    #[serde(default)]
    pub id: Option<String>,

    /// Display name for the step
    #[serde(default)]
    pub name: Option<String>,

    /// Conditional expression for step execution
    #[serde(default, rename = "if")]
    pub if_condition: Option<String>,

    /// Shell command to run
    #[serde(default)]
    pub run: Option<String>,

    /// Shell to use for the run command
    #[serde(default)]
    pub shell: Option<String>,

    /// Working directory for the step
    #[serde(default, rename = "working-directory")]
    pub working_directory: Option<String>,

    /// Action to use (e.g., "actions/checkout@v4")
    #[serde(default)]
    pub uses: Option<String>,

    /// Inputs to pass to the action
    #[serde(default)]
    pub with: HashMap<String, Value>,

    /// Step-level environment variables
    #[serde(default)]
    pub env: HashMap<String, String>,

    /// Whether to continue job if this step fails
    #[serde(default, rename = "continue-on-error")]
    pub continue_on_error: bool,

    /// Step timeout in minutes
    #[serde(default, rename = "timeout-minutes")]
    pub timeout_minutes: Option<u32>,
}

impl Step {
    /// Get a display name for the step.
    pub fn display_name(&self) -> String {
        if let Some(name) = &self.name {
            name.clone()
        } else if let Some(uses) = &self.uses {
            format!("Run {}", uses)
        } else if let Some(run) = &self.run {
            // Truncate long commands
            let first_line = run.lines().next().unwrap_or(run);
            if first_line.len() > 50 {
                format!("{}...", &first_line[..47])
            } else {
                format!("Run {}", first_line)
            }
        } else {
            "Unnamed step".to_string()
        }
    }

    /// Check if this is a run step.
    pub fn is_run(&self) -> bool {
        self.run.is_some()
    }

    /// Check if this is a uses step.
    pub fn is_uses(&self) -> bool {
        self.uses.is_some()
    }
}

/// Service container definition.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Service {
    /// Docker image to use
    pub image: String,

    /// Environment variables for the container
    #[serde(default)]
    pub env: HashMap<String, String>,

    /// Port mappings (host:container)
    #[serde(default)]
    pub ports: Vec<String>,

    /// Volume mounts
    #[serde(default)]
    pub volumes: Vec<String>,

    /// Additional docker options
    #[serde(default)]
    pub options: Option<String>,

    /// Credentials for private registries
    #[serde(default)]
    pub credentials: Option<ContainerCredentials>,
}

/// Container configuration for running a job.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Container {
    /// Simple image name
    Image(String),

    /// Detailed container configuration
    Detailed(ContainerConfig),
}

/// Detailed container configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContainerConfig {
    /// Docker image to use
    pub image: String,

    /// Environment variables for the container
    #[serde(default)]
    pub env: HashMap<String, String>,

    /// Port mappings
    #[serde(default)]
    pub ports: Vec<String>,

    /// Volume mounts
    #[serde(default)]
    pub volumes: Vec<String>,

    /// Additional docker options
    #[serde(default)]
    pub options: Option<String>,

    /// Credentials for private registries
    #[serde(default)]
    pub credentials: Option<ContainerCredentials>,
}

/// Credentials for container registries.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContainerCredentials {
    /// Username for the registry
    pub username: String,

    /// Password for the registry
    pub password: String,
}

/// Environment deployment target.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Environment {
    /// Simple environment name
    Name(String),

    /// Detailed environment configuration
    Detailed {
        name: String,
        #[serde(default)]
        url: Option<String>,
    },
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_simple_workflow() {
        let yaml = r#"
name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Hello, World!"
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        assert_eq!(workflow.name, Some("CI".to_string()));
        assert!(matches!(workflow.on, Trigger::Single(ref s) if s == "push"));
        assert!(workflow.jobs.contains_key("build"));
    }

    #[test]
    fn test_parse_workflow_with_multiple_triggers() {
        let yaml = r#"
name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: cargo test
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        assert!(matches!(workflow.on, Trigger::Multiple(ref v) if v.len() == 2));
    }

    #[test]
    fn test_parse_workflow_with_detailed_triggers() {
        let yaml = r#"
name: CI
on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Building"
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        if let Trigger::Detailed(events) = &workflow.on {
            assert!(events.contains_key("push"));
            assert!(events.contains_key("pull_request"));
        } else {
            panic!("Expected detailed trigger");
        }
    }

    #[test]
    fn test_parse_job_with_needs() {
        let yaml = r#"
name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: cargo build
  test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - run: cargo test
  deploy:
    needs: [build, test]
    runs-on: ubuntu-latest
    steps:
      - run: echo "Deploying"
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();

        let build = workflow.jobs.get("build").unwrap();
        assert!(build.needs.is_empty());

        let test = workflow.jobs.get("test").unwrap();
        assert_eq!(test.needs.to_vec(), vec!["build"]);

        let deploy = workflow.jobs.get("deploy").unwrap();
        assert_eq!(deploy.needs.to_vec(), vec!["build", "test"]);
    }

    #[test]
    fn test_parse_matrix_strategy() {
        let yaml = r#"
name: Matrix CI
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [16, 18, 20]
        os: [ubuntu-latest, macos-latest]
    steps:
      - run: echo "Testing"
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        let job = workflow.jobs.get("test").unwrap();
        let strategy = job.strategy.as_ref().unwrap();
        let matrix = strategy.matrix.as_ref().unwrap();

        assert!(matrix.dimensions.contains_key("node"));
        assert!(matrix.dimensions.contains_key("os"));
    }

    #[test]
    fn test_parse_step_with_uses() {
        let yaml = r#"
name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm test
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        let job = workflow.jobs.get("build").unwrap();

        assert!(job.steps[0].is_uses());
        assert_eq!(job.steps[0].uses, Some("actions/checkout@v4".to_string()));

        assert!(job.steps[1].is_uses());
        assert!(job.steps[1].with.contains_key("node-version"));

        assert!(job.steps[2].is_run());
    }

    #[test]
    fn test_parse_step_with_if_condition() {
        let yaml = r#"
name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Always runs"
      - run: echo "Only on main"
        if: github.ref == 'refs/heads/main'
      - run: echo "On failure"
        if: failure()
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        let job = workflow.jobs.get("build").unwrap();

        assert!(job.steps[0].if_condition.is_none());
        assert_eq!(
            job.steps[1].if_condition,
            Some("github.ref == 'refs/heads/main'".to_string())
        );
        assert_eq!(job.steps[2].if_condition, Some("failure()".to_string()));
    }

    #[test]
    fn test_parse_job_outputs() {
        let yaml = r#"
name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.version }}
    steps:
      - id: version
        run: echo "version=1.0.0" >> $GITHUB_OUTPUT
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        let job = workflow.jobs.get("build").unwrap();

        assert!(job.outputs.contains_key("version"));
        assert_eq!(job.steps[0].id, Some("version".to_string()));
    }

    #[test]
    fn test_parse_services() {
        let yaml = r#"
name: CI
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:15
        env:
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432:5432
    steps:
      - run: echo "Testing with postgres"
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();
        let job = workflow.jobs.get("test").unwrap();

        let postgres = job.services.get("postgres").unwrap();
        assert_eq!(postgres.image, "postgres:15");
        assert!(postgres.env.contains_key("POSTGRES_PASSWORD"));
    }

    #[test]
    fn test_parse_env_at_all_levels() {
        let yaml = r#"
name: CI
on: push
env:
  WORKFLOW_VAR: workflow
jobs:
  build:
    runs-on: ubuntu-latest
    env:
      JOB_VAR: job
    steps:
      - run: echo "Hello"
        env:
          STEP_VAR: step
"#;
        let workflow: Workflow = serde_yaml::from_str(yaml).unwrap();

        assert_eq!(
            workflow.env.get("WORKFLOW_VAR"),
            Some(&"workflow".to_string())
        );

        let job = workflow.jobs.get("build").unwrap();
        assert_eq!(job.env.get("JOB_VAR"), Some(&"job".to_string()));
        assert_eq!(job.steps[0].env.get("STEP_VAR"), Some(&"step".to_string()));
    }

    #[test]
    fn test_step_display_name() {
        let step_with_name = Step {
            id: None,
            name: Some("Build project".to_string()),
            if_condition: None,
            run: Some("cargo build".to_string()),
            shell: None,
            working_directory: None,
            uses: None,
            with: HashMap::new(),
            env: HashMap::new(),
            continue_on_error: false,
            timeout_minutes: None,
        };
        assert_eq!(step_with_name.display_name(), "Build project");

        let step_with_uses = Step {
            id: None,
            name: None,
            if_condition: None,
            run: None,
            shell: None,
            working_directory: None,
            uses: Some("actions/checkout@v4".to_string()),
            with: HashMap::new(),
            env: HashMap::new(),
            continue_on_error: false,
            timeout_minutes: None,
        };
        assert_eq!(step_with_uses.display_name(), "Run actions/checkout@v4");

        let step_with_run = Step {
            id: None,
            name: None,
            if_condition: None,
            run: Some("echo hello".to_string()),
            shell: None,
            working_directory: None,
            uses: None,
            with: HashMap::new(),
            env: HashMap::new(),
            continue_on_error: false,
            timeout_minutes: None,
        };
        assert_eq!(step_with_run.display_name(), "Run echo hello");
    }

    #[test]
    fn test_job_needs_to_vec() {
        assert!(JobNeeds::None.to_vec().is_empty());
        assert_eq!(
            JobNeeds::Single("build".to_string()).to_vec(),
            vec!["build"]
        );
        assert_eq!(
            JobNeeds::Multiple(vec!["build".to_string(), "test".to_string()]).to_vec(),
            vec!["build", "test"]
        );
    }
}