@@ -36,6 +36,45 @@ def fixture_uses_step():
36
36
return Step .init (0 , "default" , step_yaml )
37
37
38
38
39
+ @pytest .fixture (name = "uses_step_no_comments" )
40
+ def fixture_uses_step_no_comments ():
41
+ step_str = """\
42
+ name: Download Artifacts
43
+ uses: bitwarden/download-artifacts@main
44
+ with:
45
+ workflow: upload-test-artifacts.yml
46
+ artifacts: artifact
47
+ path: artifact
48
+ branch: main
49
+
50
+ """
51
+ yaml = YAML ()
52
+ step_yaml = yaml .load (step_str )
53
+ return Step .init (0 , "default" , step_yaml )
54
+
55
+
56
+ @pytest .fixture (name = "uses_step_no_ref" )
57
+ def fixture_uses_step_no_ref ():
58
+ step_str = """\
59
+ name: Run Local Workflow
60
+ uses: ./.github/workflows/_local.yml
61
+ """
62
+ yaml = YAML ()
63
+ step_yaml = yaml .load (step_str )
64
+ return Step .init (0 , "default" , step_yaml )
65
+
66
+
67
+ @pytest .fixture (name = "uses_step_no_ref_with_comments" )
68
+ def fixture_uses_step_no_ref_with_comments ():
69
+ step_str = """\
70
+ name: Run Local Workflow
71
+ uses: ./.github/workflows/_local.yml # A comment
72
+ """
73
+ yaml = YAML ()
74
+ step_yaml = yaml .load (step_str )
75
+ return Step .init (0 , "default" , step_yaml )
76
+
77
+
39
78
def test_step_default (default_step ):
40
79
assert default_step .key == 0
41
80
assert default_step .job == "default"
@@ -74,5 +113,32 @@ def test_step_keyword_field(uses_step):
74
113
def test_step_comment (uses_step ):
75
114
assert uses_step .key == 0
76
115
assert uses_step .job == "default"
77
- assert uses_step .uses_comment is not None
116
+ assert uses_step .uses_ref == "main"
117
+ assert uses_step .uses_version == "v1.0.0"
78
118
assert uses_step .uses_comment == "# v1.0.0"
119
+
120
+
121
+ def test_step_no_comments (uses_step_no_comments ):
122
+ assert uses_step_no_comments .key == 0
123
+ assert uses_step_no_comments .job == "default"
124
+ assert uses_step_no_comments .uses_ref == "main"
125
+ assert uses_step_no_comments .uses_version is None
126
+ assert uses_step_no_comments .uses_comment is None
127
+
128
+
129
+ def test_step_no_ref (uses_step_no_ref ):
130
+ assert uses_step_no_ref .key == 0
131
+ assert uses_step_no_ref .job == "default"
132
+ assert uses_step_no_ref .uses_ref is None
133
+ assert uses_step_no_ref .uses_version is None
134
+ assert uses_step_no_ref .uses_comment is None
135
+
136
+
137
+ def test_step_no_ref_with_comments (uses_step_no_ref_with_comments ):
138
+ assert uses_step_no_ref_with_comments .key == 0
139
+ assert uses_step_no_ref_with_comments .job == "default"
140
+ assert uses_step_no_ref_with_comments .uses_ref is None
141
+ assert (
142
+ uses_step_no_ref_with_comments .uses_version == "comment"
143
+ ) # We are not currently validating the version matches a specific format
144
+ assert uses_step_no_ref_with_comments .uses_comment == "# A comment"
0 commit comments