Skip to content

Commit 7e5e023

Browse files
fix: removing fail-on-diff and defaulting to oasdiff param of fail-on - updating tests, etc.
1 parent 468ff61 commit 7e5e023

File tree

4 files changed

+146
-28
lines changed

4 files changed

+146
-28
lines changed

.github/workflows/test.yaml

+33-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
with:
5454
base: 'specs/base.yaml'
5555
revision: 'specs/revision-breaking.yaml'
56-
fail-on-diff: false
56+
fail-on: 'WARN'
5757
- name: Test breaking changes action output
5858
run: |
5959
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
@@ -62,7 +62,7 @@ jobs:
6262
$delimiter
6363
)
6464
if [ "$output" != "1 breaking changes: 1 error, 0 warning" ]; then
65-
echo "Expected output '6 breaking changes: 2 error, 4 warning' but got '$output'" >&2
65+
echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2
6666
exit 1
6767
fi
6868
oasdiff_breaking_deprecation:
@@ -83,32 +83,55 @@ jobs:
8383
with:
8484
base: specs/base.yaml
8585
revision: specs/base-deprecation.yaml
86-
fail-on-diff: true
86+
fail-on: 'WARN'
8787
deprecation-days-beta: 14
8888
deprecation-days-stable: 21
89-
oasdiff_breaking_fail_on_explicit:
89+
oasdiff_breaking_fail_on_err:
9090
runs-on: ubuntu-latest
91-
name: Test breaking changes fail-on
91+
name: Test breaking changes fail-on (ERR)
9292
steps:
9393
- name: checkout
9494
uses: actions/checkout@v4
9595
- name: Running breaking action
96-
id: test_breaking_changes
96+
id: test_breaking_changes_err
9797
uses: ./breaking
9898
with:
9999
base: 'specs/base.yaml'
100100
revision: 'specs/revision-breaking.yaml'
101-
fail-on-diff: false
102-
fail-on: ERR
103-
- name: Test breaking changes action output
101+
fail-on: 'ERR'
102+
- name: Test breaking changes action output (ERR)
104103
run: |
105104
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
106105
output=$(cat <<-$delimiter
107106
${{ steps.test_breaking_changes.outputs.breaking }}
108107
$delimiter
109108
)
110109
if [ "$output" != "1 breaking changes: 1 error, 0 warning" ]; then
111-
echo "Expected output '6 breaking changes: 2 error, 4 warning' but got '$output'" >&2
110+
echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2
111+
exit 1
112+
fi
113+
oasdiff_breaking_fail_on_warn:
114+
runs-on: ubuntu-latest
115+
name: Test breaking changes fail-on (WARN)
116+
steps:
117+
- name: checkout
118+
uses: actions/checkout@v4
119+
- name: Running breaking action
120+
id: test_breaking_changes_err
121+
uses: ./breaking
122+
with:
123+
base: 'specs/base.yaml'
124+
revision: 'specs/revision-breaking-warning.yaml'
125+
fail-on: 'WARN'
126+
- name: Test breaking changes action output (WARN)
127+
run: |
128+
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
129+
output=$(cat <<-$delimiter
130+
${{ steps.test_breaking_changes.outputs.breaking }}
131+
$delimiter
132+
)
133+
if [ "$output" != "0 breaking changes: 0 error, 1 warning" ]; then
134+
echo "Expected output '0 breaking changes: 0 error, 1 warning' but got '$output'" >&2
112135
exit 1
113136
fi
114137
oasdiff_changelog:

breaking/action.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ inputs:
77
revision:
88
description: 'Path of revised OpenAPI spec in YAML or JSON format'
99
required: true
10-
fail-on-diff:
11-
description: 'Fail with exit code 1 if any breaking changes are found'
12-
required: false
13-
default: 'true'
1410
fail-on:
15-
description: 'Fail with exit code 1 if breaking changes are found at a particular status or severity level, e.g. ERR'
11+
description: 'Fail with exit code 1 if breaking changes are found at a particular status or severity level, e.g. ERR or WARN'
1612
required: false
17-
default: ''
13+
default: 'ERR'
1814
include-checks:
1915
description: 'Include any of the defined optional breaking changes checks'
2016
required: false
@@ -41,7 +37,6 @@ runs:
4137
args:
4238
- ${{ inputs.base }}
4339
- ${{ inputs.revision }}
44-
- ${{ inputs.fail-on-diff }}
4540
- ${{ inputs.fail-on }}
4641
- ${{ inputs.include-checks }}
4742
- ${{ inputs.include-path-params }}

breaking/entrypoint.sh

+8-11
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ set -e
33

44
readonly base="$1"
55
readonly revision="$2"
6-
readonly fail_on_diff="$3"
7-
readonly fail_on="$4"
8-
readonly include_checks="$5"
9-
readonly include_path_params="$6"
10-
readonly deprecation_days_beta="$7"
11-
readonly deprecation_days_stable="$8"
12-
readonly exclude_elements="$9"
6+
readonly fail_on="$3"
7+
readonly include_checks="$4"
8+
readonly include_path_params="$5"
9+
readonly deprecation_days_beta="$6"
10+
readonly deprecation_days_stable="$7"
11+
readonly exclude_elements="$8"
1312

14-
echo "running oasdiff breaking... base: $base, revision: $revision, fail_on_diff: $fail_on_diff, fail_on: $fail_on, include_checks: $include_checks, include_path_params: $include_path_params, deprecation_days_beta: $deprecation_days_beta, deprecation_days_stable: $deprecation_days_stable, exclude_elements: $exclude_elements"
13+
echo "running oasdiff breaking... base: $base, revision: $revision, fail_on: $fail_on, include_checks: $include_checks, include_path_params: $include_path_params, deprecation_days_beta: $deprecation_days_beta, deprecation_days_stable: $deprecation_days_stable, exclude_elements: $exclude_elements"
1514

1615
# Build flags to pass in command
1716
flags=""
18-
if [ "$fail_on_diff" = "true" ]; then
19-
flags="${flags} --fail-on WARN"
20-
elif [ -z "$fail_on" ]; then
17+
if [ -z "$fail_on" ]; then
2118
flags="${flags} --fail-on $fail_on"
2219
fi
2320
if [ "$include_path_params" = "true" ]; then

specs/revision-breaking-warning.yaml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: Swagger Petstore
5+
license:
6+
name: MIT
7+
servers:
8+
- url: http://petstore.swagger.io/v1
9+
paths:
10+
/pets:
11+
get:
12+
summary: List all pets
13+
operationId: listPets
14+
tags:
15+
- pets
16+
responses:
17+
'200':
18+
description: A paged array of pets
19+
headers:
20+
x-next:
21+
description: A link to the next page of responses
22+
schema:
23+
type: string
24+
content:
25+
application/json:
26+
schema:
27+
$ref: "#/components/schemas/Pets"
28+
default:
29+
description: unexpected error
30+
content:
31+
application/json:
32+
schema:
33+
$ref: "#/components/schemas/Error"
34+
post:
35+
summary: Create a pet
36+
operationId: createPets
37+
tags:
38+
- pets
39+
responses:
40+
'201':
41+
description: Null response
42+
default:
43+
description: unexpected error
44+
content:
45+
application/json:
46+
schema:
47+
$ref: "#/components/schemas/Error"
48+
/pets/{petId}:
49+
get:
50+
summary: Info for a specific pet
51+
operationId: showPetById
52+
tags:
53+
- pets
54+
parameters:
55+
- name: petId
56+
in: path
57+
required: true
58+
description: The id of the pet to retrieve
59+
schema:
60+
type: string
61+
responses:
62+
'200':
63+
description: Expected response to a valid request
64+
content:
65+
application/json:
66+
schema:
67+
$ref: "#/components/schemas/Pet"
68+
default:
69+
description: unexpected error
70+
content:
71+
application/json:
72+
schema:
73+
$ref: "#/components/schemas/Error"
74+
components:
75+
schemas:
76+
Pet:
77+
type: object
78+
required:
79+
- id
80+
- name
81+
properties:
82+
id:
83+
type: integer
84+
format: int64
85+
name:
86+
type: string
87+
tag:
88+
type: string
89+
Pets:
90+
type: array
91+
items:
92+
$ref: "#/components/schemas/Pet"
93+
Error:
94+
type: object
95+
required:
96+
- code
97+
- message
98+
properties:
99+
code:
100+
type: integer
101+
format: int32
102+
message:
103+
type: string

0 commit comments

Comments
 (0)