3
3
pull_request :
4
4
push :
5
5
jobs :
6
+ oasdiff_diff :
7
+ runs-on : ubuntu-latest
8
+ name : Test diff action
9
+ steps :
10
+ - name : checkout
11
+ uses : actions/checkout@v4
12
+ - name : Running diff action
13
+ id : test_ete
14
+ uses : ./diff
15
+ with :
16
+ base : https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml
17
+ revision : https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml
18
+ format : ' text'
19
+ output-to-file : ' diff.txt'
20
+ - name : Test diff action output to file
21
+ run : |
22
+ if [ ! -s diff.txt ]; then
23
+ echo "Diff file doesn't exist or is empty"
24
+ exit 1
25
+ fi
26
+ oasdiff_diff_exclude_elements :
27
+ runs-on : ubuntu-latest
28
+ name : Test diff action with exclude-elements option
29
+ steps :
30
+ - name : checkout
31
+ uses : actions/checkout@v4
32
+ - name : Running diff action with exclude-elements option
33
+ id : test_exclude_elements
34
+ uses : ./diff
35
+ with :
36
+ base : ' specs/base.yaml'
37
+ revision : ' specs/base-exclude-elements.yaml'
38
+ format : ' text'
39
+ exclude-elements : ' description,title,summary'
40
+ - name : Test diff action output
41
+ run : |
42
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
43
+ output=$(cat <<-$delimiter
44
+ ${{ steps.test_exclude_elements.outputs.diff }}
45
+ $delimiter
46
+ )
47
+ if [ "$output" != "No changes" ]; then
48
+ echo "Expected output 'No changes' but got '$output'" >&2
49
+ exit 1
50
+ fi
51
+ oasdiff_diff_composed :
52
+ runs-on : ubuntu-latest
53
+ name : Test diff action with composed option
54
+ steps :
55
+ - name : checkout
56
+ uses : actions/checkout@v4
57
+ - name : Running diff action with composed option
58
+ id : test_composed
59
+ uses : ./diff
60
+ with :
61
+ base : ' specs/glob/base/*.yaml'
62
+ revision : ' specs/glob/revision/*.yaml'
63
+ format : ' text'
64
+ composed : true
65
+ - name : Test diff action output
66
+ run : |
67
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
68
+ output=$(cat <<-$delimiter
69
+ ${{ steps.test_composed.outputs.diff }}
70
+ $delimiter
71
+ )
72
+ if [[ ! "$output" =~ "Deleted Endpoints: 1" ]]; then
73
+ echo "Expected 'Deleted Endpoints: 1' to be modified in diff, instead got '$output'" >&2
74
+ exit 1
75
+ fi
76
+ oasdiff_breaking :
77
+ runs-on : ubuntu-latest
78
+ name : Test breaking changes
79
+ steps :
80
+ - name : checkout
81
+ uses : actions/checkout@v4
82
+ - name : Running breaking action
83
+ id : test_breaking_changes
84
+ uses : ./breaking
85
+ with :
86
+ base : ' specs/base.yaml'
87
+ revision : ' specs/revision-breaking.yaml'
88
+ fail-on-diff : false
89
+ output-to-file : ' breaking.txt'
90
+ - name : Test breaking changes action output
91
+ run : |
92
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
93
+ output=$(cat <<-$delimiter
94
+ ${{ steps.test_breaking_changes.outputs.breaking }}
95
+ $delimiter
96
+ )
97
+ if [ "$output" != "1 breaking changes: 1 error, 0 warning" ]; then
98
+ echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2
99
+ exit 1
100
+ fi
101
+ - name : Test breaking changes action output to file
102
+ run : |
103
+ if [ ! -s breaking.txt ]; then
104
+ echo "Breaking changes file doesn't exist or is empty"
105
+ exit 1
106
+ fi
107
+ output=$(cat breaking.txt | head -n 1)
108
+ if [[ "${output}" != "1 breaking changes: 1 error, 0 warning" ]]; then
109
+ echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '${output}'" >&2
110
+ exit 1
111
+ fi
6
112
oasdiff_breaking_fail_on :
7
113
runs-on : ubuntu-latest
8
114
name : Test fail on breaking changes
16
122
base : ' specs/base.yaml'
17
123
revision : ' specs/revision-breaking-warn.yaml'
18
124
output-to-file : ' breaking.txt'
19
- fail-on : ' WARN '
125
+ fail-on : ' ERR '
20
126
- name : Test breaking changes action output
21
127
run : |
22
128
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
@@ -39,3 +145,132 @@ jobs:
39
145
echo "Expected output '2 breaking changes: 0 error, 2 warning' but got '${output}'" >&2
40
146
exit 1
41
147
fi
148
+ oasdiff_breaking_matching_delimiter_not_found :
149
+ runs-on : ubuntu-latest
150
+ name : Test breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found
151
+ steps :
152
+ - name : checkout
153
+ uses : actions/checkout@v4
154
+ - name : Running breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found
155
+ id : test_breaking_changes_matching_delimiter_not_found
156
+ uses : ./breaking
157
+ with :
158
+ base : ' specs/petstore-base.yaml'
159
+ revision : ' specs/petstore-revision.yaml'
160
+ fail-on-diff : false
161
+ - name : Test breaking changes action output
162
+ run : |
163
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
164
+ output=$(cat <<-$delimiter
165
+ ${{ steps.test_breaking_changes_matching_delimiter_not_found.outputs.breaking }}
166
+ $delimiter
167
+ )
168
+ if [ "$output" != "9 breaking changes: 6 error, 3 warning" ]; then
169
+ echo "Expected output '9 breaking changes: 6 error, 3 warning' but got '$output'" >&2
170
+ exit 1
171
+ fi
172
+ oasdiff_breaking_composed :
173
+ runs-on : ubuntu-latest
174
+ name : Test breaking action with composed option
175
+ steps :
176
+ - name : checkout
177
+ uses : actions/checkout@v4
178
+ - name : Running breaking action with composed option
179
+ id : test_breaking_composed
180
+ uses : ./breaking
181
+ with :
182
+ base : ' specs/glob/base/*.yaml'
183
+ revision : ' specs/glob/revision/*.yaml'
184
+ fail-on-diff : false
185
+ format : ' text'
186
+ composed : true
187
+ - name : Test breaking action output
188
+ run : |
189
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
190
+ output=$(cat <<-$delimiter
191
+ ${{ steps.test_breaking_composed.outputs.breaking }}
192
+ $delimiter
193
+ )
194
+ if [[ ! "$output" =~ "1 breaking changes: 1 error, 0 warning" ]]; then
195
+ echo "Expected '1 breaking changes: 1 error, 0 warning', instead got '$output'" >&2
196
+ exit 1
197
+ fi
198
+ oasdiff_breaking_deprecation :
199
+ runs-on : ubuntu-latest
200
+ name : Test breaking changes with deprecation
201
+ steps :
202
+ - name : checkout
203
+ uses : actions/checkout@v4
204
+ - name : Set date for deprecated specs
205
+ run : |
206
+ # Deprecate Beta in 14 days
207
+ sed -ie "s/{{SUNSET_DATE_BETA}}/$(date --date="14 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml
208
+ # Deprecate Stable in 21 days
209
+ sed -ie "s/{{SUNSET_DATE_STABLE}}/$(date --date="21 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml
210
+ - name : Running OpenAPI Spec check breaking action
211
+ id : test_breaking_deprecations
212
+ uses : ./breaking
213
+ with :
214
+ base : specs/base.yaml
215
+ revision : specs/base-deprecation.yaml
216
+ fail-on-diff : true
217
+ deprecation-days-beta : 14
218
+ deprecation-days-stable : 21
219
+ oasdiff_changelog :
220
+ runs-on : ubuntu-latest
221
+ name : Test generation of changelog
222
+ steps :
223
+ - name : checkout
224
+ uses : actions/checkout@v4
225
+ - name : Running changelog action
226
+ id : test_changelog
227
+ uses : ./changelog
228
+ with :
229
+ base : https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml
230
+ revision : https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml
231
+ output-to-file : " changelog.txt"
232
+ - name : Test changelog action output
233
+ run : |
234
+ readonly expected_output="20 changes: 2 error, 4 warning, 14 info"
235
+ output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1)
236
+ if [[ "${output}" != "${expected_output}" ]]; then
237
+ echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2
238
+ exit 1
239
+ fi
240
+ - name : Test changelog action output to file
241
+ run : |
242
+ if [ ! -s changelog.txt ]; then
243
+ echo "Changelog file doesn't exist or is empty"
244
+ exit 1
245
+ fi
246
+ output=$(cat changelog.txt | head -n 1)
247
+ if [[ "${output}" != "20 changes: 2 error, 4 warning, 14 info" ]]; then
248
+ echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2
249
+ exit 1
250
+ fi
251
+ oasdiff_changelog_composed :
252
+ runs-on : ubuntu-latest
253
+ name : Test changelog action with composed option
254
+ steps :
255
+ - name : checkout
256
+ uses : actions/checkout@v4
257
+ - name : Running changelog action with composed option
258
+ id : test_changelog_composed
259
+ uses : ./changelog
260
+ with :
261
+ base : ' specs/glob/base/*.yaml'
262
+ revision : ' specs/glob/revision/*.yaml'
263
+ format : ' text'
264
+ composed : true
265
+ - name : Test changelog action output
266
+ run : |
267
+ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
268
+ output=$(cat <<-$delimiter
269
+ ${{ steps.test_changelog_composed.outputs.changelog }}
270
+ $delimiter
271
+ )
272
+ if [[ ! "$output" =~ "1 changes: 1 error, 0 warning, 0 info" ]]; then
273
+ echo "Expected '1 changes: 1 error, 0 warning, 0 info', instead got '$output'" >&2
274
+ exit 1
275
+ fi
276
+
0 commit comments