Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven committed Jul 2, 2023
1 parent 214d1e0 commit c624547
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
9 changes: 2 additions & 7 deletions check-breaking/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ inputs:
description: "Path of revised OpenAPI spec in YAML or JSON format"
required: true
fail-on-diff:
description: "Fail with exit code 1 if any ERR-level breaking changes are found"
description: "Fail with exit code 1 if any breaking changes are found"
required: false
default: true
fail-on-warns:
description: "Fail with exit code 1 if any WARN-level breaking changes are found"
required: false
default: 'false'
default: 'true'
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.base }}
- ${{ inputs.revision }}
- ${{ inputs.fail-on-diff }}
- ${{ inputs.fail-on-warns }}
12 changes: 6 additions & 6 deletions check-breaking/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
readonly base="$1"
readonly revision="$2"
readonly fail_on_diff="$3"
readonly fail_on_warns="$4"

echo "running oasdiff check for breaking-changes... base: $base, revision: $revision, fail_on_diff: $fail_on_diff, fail_on_warns: $fail_on_warns"
echo "running oasdiff check for breaking-changes... base: $base, revision: $revision, fail_on_diff: $fail_on_diff"

readonly fail_on_argument=$(if [ "$fail_on_warns" = "true" ]; then echo "--fail-on WARN"; fi)
set -o pipefail

oasdiff breaking "$base" "$revision" "$fail_on_argument"
if [ $? != 0 ] && [ "$fail_on_diff" = "true" ]; then
exit 1
if [[ $fail_on_diff = "true" ]]; then
oasdiff breaking "$base" "$revision" --fail-on WARN
else
oasdiff breaking "$base" "$revision"
fi
7 changes: 4 additions & 3 deletions diff/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ readonly fail_on_diff="$4"

echo "running oasdiff... base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff"

if [ "$fail_on_diff" = "true" ]
then
set -o pipefail

if [[ $fail_on_diff" == "true" ]]; then
oasdiff diff "$base" "$revision" --fail-on-diff --format "$format"
else
oasdiff diff "$base" "$revision" --format "$format"
oasdiff diff "$base" "$revision" --format "$format"
fi

0 comments on commit c624547

Please sign in to comment.