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
//! Enriching/context-bearing wrappers over GitHub Actions models
//! from [`github_actions_models`].
use github_actions_expressions::context;
use github_actions_models::common;
use github_actions_models::common::Env;
use github_actions_models::common::expr::LoE;
use crate::finding::location::{Locatable, SymbolicLocation};
use crate::models::inputs::HasInputs;
use crate::models::workflow::matrix::Matrix;
pub(crate) mod action;
pub(crate) mod coordinate;
pub(crate) mod dependabot;
pub(crate) mod inputs;
pub(crate) mod uses;
pub(crate) mod version;
pub(crate) mod workflow;
pub(crate) trait AsDocument<'a, 'doc> {
fn as_document(&'a self) -> &'doc yamlpath::Document;
}
/// Common fields between workflow and action step bodies.
pub(crate) enum StepBodyCommon<'s> {
Uses {
uses: &'s common::Uses,
with: &'s LoE<Env>,
},
Run {
run: &'s str,
_working_directory: Option<&'s str>,
_shell: Option<&'s LoE<String>>,
},
}
/// Common interfaces between workflow and action steps.
pub(crate) trait StepCommon<'doc>: Locatable<'doc> + HasInputs {
/// Returns the step's index within its parent job or action.
fn index(&self) -> usize;
/// Returns whether the given `env.name` environment access is "static,"
/// i.e. is not influenced by another expression.
fn env_is_static(&self, ctx: &context::Context) -> bool;
/// Returns a [`common::Uses`] for this step, if it has one.
fn uses(&self) -> Option<&'doc common::Uses>;
/// Returns this step's job's computed matrix, if present.
///
/// Composite action steps have no matrix.
fn matrix(&self) -> Option<Matrix<'doc>>;
/// Returns a [`StepBodyCommon`] for this step.
fn body(&self) -> StepBodyCommon<'doc>;
/// Returns the document which contains this step.
fn document(&self) -> &'doc yamlpath::Document;
/// Returns the effective shell for this step, if it can be determined.
/// This includes the step's explicit shell, job defaults, workflow defaults,
/// and runner defaults.
///
/// Returns `None` if the shell cannot be statically determined, including
/// if the shell is specified via an expression.
fn shell(&self) -> Option<(&str, SymbolicLocation<'doc>)>;
}
impl<'a, 'doc, T: StepCommon<'doc>> AsDocument<'a, 'doc> for T {
fn as_document(&'a self) -> &'doc yamlpath::Document {
self.document()
}
}