Skip to content

Commit 70ee75e

Browse files
committed
Fix expected output for tests and remove unused params
1 parent a91af38 commit 70ee75e

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

.github/workflows/test.yaml

+24-21
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ jobs:
7676
oasdiff_breaking:
7777
runs-on: ubuntu-latest
7878
name: Test breaking changes
79+
env:
80+
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "1 changes: 1 error, 0 warning, 0 info"
7981
steps:
8082
- name: checkout
8183
uses: actions/checkout@v4
@@ -85,7 +87,6 @@ jobs:
8587
with:
8688
base: 'specs/base.yaml'
8789
revision: 'specs/revision-breaking.yaml'
88-
fail-on-diff: false
8990
output-to-file: 'breaking.txt'
9091
- name: Test breaking changes action output
9192
run: |
@@ -94,8 +95,8 @@ jobs:
9495
${{ steps.test_breaking_changes.outputs.breaking }}
9596
$delimiter
9697
)
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
98+
if [ "$output" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]; then
99+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '$output'" >&2
99100
exit 1
100101
fi
101102
- name: Test breaking changes action output to file
@@ -105,13 +106,15 @@ jobs:
105106
exit 1
106107
fi
107108
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
109+
if [[ "${output}" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]]; then
110+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '${output}'" >&2
110111
exit 1
111112
fi
112113
oasdiff_breaking_fail_on:
113114
runs-on: ubuntu-latest
114115
name: Test fail on breaking changes
116+
env:
117+
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "2 changes: 0 error, 2 warning, 0 info"
115118
steps:
116119
- name: checkout
117120
uses: actions/checkout@v4
@@ -130,8 +133,8 @@ jobs:
130133
${{ steps.test_breaking_changes.outputs.breaking }}
131134
$delimiter
132135
)
133-
if [ "$output" != "2 breaking changes: 0 error, 2 warning" ]; then
134-
echo "Expected output '2 breaking changes: 0 error, 2 warning' but got '$output'" >&2
136+
if [ "$output" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]; then
137+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '$output'" >&2
135138
exit 1
136139
fi
137140
- name: Test breaking changes action output to file
@@ -141,13 +144,15 @@ jobs:
141144
exit 1
142145
fi
143146
output=$(cat breaking.txt | head -n 1)
144-
if [[ "${output}" != "2 breaking changes: 0 error, 2 warning" ]]; then
145-
echo "Expected output '2 breaking changes: 0 error, 2 warning' but got '${output}'" >&2
147+
if [[ "${output}" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]]; then
148+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '${output}'" >&2
146149
exit 1
147150
fi
148151
oasdiff_breaking_matching_delimiter_not_found:
149152
runs-on: ubuntu-latest
150153
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
154+
env:
155+
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "9 changes: 6 error, 3 warning, 0 info"
151156
steps:
152157
- name: checkout
153158
uses: actions/checkout@v4
@@ -157,21 +162,22 @@ jobs:
157162
with:
158163
base: 'specs/petstore-base.yaml'
159164
revision: 'specs/petstore-revision.yaml'
160-
fail-on-diff: false
161165
- name: Test breaking changes action output
162166
run: |
163167
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
164168
output=$(cat <<-$delimiter
165169
${{ steps.test_breaking_changes_matching_delimiter_not_found.outputs.breaking }}
166170
$delimiter
167171
)
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
172+
if [ "$output" != "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]; then
173+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '$output'" >&2
170174
exit 1
171175
fi
172176
oasdiff_breaking_composed:
173177
runs-on: ubuntu-latest
174178
name: Test breaking action with composed option
179+
env:
180+
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "1 changes: 1 error, 0 warning, 0 info"
175181
steps:
176182
- name: checkout
177183
uses: actions/checkout@v4
@@ -181,8 +187,6 @@ jobs:
181187
with:
182188
base: 'specs/glob/base/*.yaml'
183189
revision: 'specs/glob/revision/*.yaml'
184-
fail-on-diff: false
185-
format: 'text'
186190
composed: true
187191
- name: Test breaking action output
188192
run: |
@@ -191,8 +195,8 @@ jobs:
191195
${{ steps.test_breaking_composed.outputs.breaking }}
192196
$delimiter
193197
)
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
198+
if [[ ! "$output" =~ "$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT" ]]; then
199+
echo "Expected '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT', instead got '$output'" >&2
196200
exit 1
197201
fi
198202
oasdiff_breaking_deprecation:
@@ -213,12 +217,13 @@ jobs:
213217
with:
214218
base: specs/base.yaml
215219
revision: specs/base-deprecation.yaml
216-
fail-on-diff: true
217220
deprecation-days-beta: 14
218221
deprecation-days-stable: 21
219222
oasdiff_changelog:
220223
runs-on: ubuntu-latest
221224
name: Test generation of changelog
225+
env:
226+
OASDIFF_ACTION_TEST_EXPECTED_OUTPUT: "21 changes: 2 error, 4 warning, 15 info"
222227
steps:
223228
- name: checkout
224229
uses: actions/checkout@v4
@@ -231,10 +236,9 @@ jobs:
231236
output-to-file: "changelog.txt"
232237
- name: Test changelog action output
233238
run: |
234-
readonly expected_output="20 changes: 2 error, 4 warning, 14 info"
235239
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
240+
if [[ "${output}" != "${OASDIFF_ACTION_TEST_EXPECTED_OUTPUT}" ]]; then
241+
echo "Expected output '$OASDIFF_ACTION_TEST_EXPECTED_OUTPUT' but got '${output}'" >&2
238242
exit 1
239243
fi
240244
- name: Test changelog action output to file
@@ -260,7 +264,6 @@ jobs:
260264
with:
261265
base: 'specs/glob/base/*.yaml'
262266
revision: 'specs/glob/revision/*.yaml'
263-
format: 'text'
264267
composed: true
265268
- name: Test changelog action output
266269
run: |

0 commit comments

Comments
 (0)