-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: add ability to fail on ERR and other fail-on statuses for breaking changes #43
feat: add ability to fail on ERR and other fail-on statuses for breaking changes #43
Conversation
e18f685
to
6ddd3f7
Compare
breaking/entrypoint.sh
Outdated
if [ "$fail_on_diff" = "true" ]; then | ||
flags="${flags} --fail-on WARN" | ||
elif [ "$fail_on_diff" != "false" ] | ||
flags="${flags} --fail-on $fail_on_diff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a best practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effoeffi Is there a way to indicate in the oasdiff breaking change action
to only fail
on ERR
instead of WARN
?
This was one way to support/passthrough any status or error level without hardcoding the options in the action:
oasdiff-action/breaking/entrypoint.sh
Lines 17 to 20 in 6ddd3f7
if [ "$fail_on_diff" = "true" ]; then | |
flags="${flags} --fail-on WARN" | |
elif [ "$fail_on_diff" != "false" ] | |
flags="${flags} --fail-on $fail_on_diff" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, but it is not best practice to use 'var' as both a boolean and a string. I suggest converting it to a string similar to oasdiff
. Additionally, update the documentation, defaults, and create tests accordingly. Please also review other parameters for similar improvements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cf87137
to
e19710d
Compare
98ab600
to
468ff61
Compare
Taken from the oasdiff help:
This means that the behaviour you have described already exists, failing on Validated this is true with:
|
@tcooper-uk Re: #43 (comment) We want to fail on |
.github/workflows/test.yaml
Outdated
fail-on: ERR | ||
- name: Test breaking changes action output | ||
run: | | ||
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') | ||
output=$(cat <<-$delimiter | ||
${{ steps.test_breaking_changes.outputs.breaking }} | ||
$delimiter | ||
) | ||
if [ "$output" != "1 breaking changes: 1 error, 0 warning" ]; then | ||
echo "Expected output '6 breaking changes: 2 error, 4 warning' but got '$output'" >&2 | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you are testing?
I suggest taking an example that there is warnings but not errors and set fail-on: ERR and it should not fail
README.md
Outdated
| --include-checks | include-checks | csv | | ||
| --include-path-params | include-path-params | false | | ||
| --deprecation-days-beta | deprecation-days-beta | 31 | | ||
| --deprecation-days-stable | deprecation-days-stable | 180 | | ||
| --exclude-elements | exclude-elements | '' | | ||
|
||
This action delivers a summary of breaking changes, accessible as a GitHub step output named `breaking`. | ||
This action delivers a summary of breaking changes, accessible as a GitHub step output named `breaking`. Note: `fail-on-diff` takes precedence over `fail-on` when `fail-on-diff` is `true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets align with oasdiff by having only fail-on
. please remove fail-on-diff
, we can achieve this by using fail-on: WARN
breaking/entrypoint.sh
Outdated
if [ "$fail_on_diff" = "true" ]; then | ||
flags="${flags} --fail-on WARN" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effoeffi For #43 (comment), the reason it was not removed was that it would be a breaking change itself if it was removed from the action. If someone relies on the fail_on_diff
and it is removed, their workflows will break... of course fail-on
is more flexible for any status. Will update the pr
to remove fail_on_diff
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effoeffi For #43 (comment), the reason it was not removed was that it would be a breaking change itself if it was removed from the action. If someone relies on the
fail_on_diff
and it is removed, their workflows will break... of coursefail-on
is more flexible for any status. Will update thepr
to removefail_on_diff
though.
@jgill-shipwell that is why we are creating a release, and you should rely on it to avoid any breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@effoeffi Updated this pr
to remove fail_on_diff
and match the fail-on
param of oasdiff
. Updated the tests, etc.
… - updating tests, etc.
7e5e023
to
436f539
Compare
if [ -z "$fail_on" ]; then | ||
flags="${flags} --fail-on $fail_on" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to check if it is not empty, right? -n
?
with: | ||
base: 'specs/base.yaml' | ||
revision: 'specs/revision-breaking.yaml' | ||
fail-on-diff: false | ||
fail-on: 'WARN' | ||
output-to-file: 'breaking.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this test do not fail?
oasdiff docs:
To exit with return code 1 when any breaking changes are found, WARN-level or ERR-level, add the --fail-on WARN flag.
Can you please explain the why you decided to change fail-on-diff: false
to fail-on: 'WARN'
?
|---------------------------|-------------------------|---------| | ||
| --fail-on | fail-on | 'ERR' | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default oasdiff exit code is 0 if there is a breaking changes, why do you want to change that?
@@ -31,12 +31,12 @@ readonly exclude_elements="$8" | |||
readonly composed="$9" | |||
readonly output_to_file="${10}" | |||
|
|||
echo "running oasdiff breaking... base: $base, revision: $revision, fail_on_diff: $fail_on_diff, 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, composed: $composed, output_to_file: $output_to_file" | |||
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you delete composed: $composed, output_to_file: $output_to_file"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jgill-shipwell could you please check this PR and let me know if it resolves your issue?
Adds the ability to fail the action/build on other statuses such as
ERR
instead of justWARN
.