Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support oasdiff with subcommands #8

Merged
merged 4 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/checkout@v3
- name: Running OpenAPI Spec check breaking tag action
id: test_breaking_changes
uses: oasdiff/oasdiff-action/check-breaking@v0.0.6
uses: oasdiff/oasdiff-action/check-breaking@v0.0.9
with:
base: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test1.yaml
revision: https://raw.githubusercontent.com/Tufin/oasdiff/main/data/openapi-test3.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
GitHub actions for comparing OpenAPI specs and detect breaking changes, based on [oasdiff](https://github.com/Tufin/oasdiff) tool

## How to use?
Depend on your use case:
Depends on your use case:

### Find diff
### Generate a diff report
Copy and paste the following snippet into your build .yml file:
```
- name: Running OpenAPI Spec diff action
Expand Down
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_warns_argument=$(if [ "$fail_on_warns" = "true" ]; then echo "-fail-on-warns"; fi)
set -o pipefail

oasdiff -check-breaking -fail-on-diff -base "$base" -revision "$revision" "$fail_on_warns_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
2 changes: 1 addition & 1 deletion diff/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
fail-on-diff:
description: 'Fail with exit code 1 if a difference is found'
required: false
default: false
default: 'false'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
9 changes: 5 additions & 4 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
oasdiff -fail-on-diff -format "$format" -base "$base" -revision "$revision"
set -o pipefail

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