Hi,
I'm using this action to validate whether the version in the openapi spec was updated correctly. So for example, I'd have a PR which does not bump the version inside the spec file, but it makes a change, which according to this action, is flagged as major. I then let the workflow fail. However, if the same breaking change was made alongside a version bump, then I'm fine with it.
I do this in my workflow by calling this action with continue-on-error: true and then a subsequent step check if the version was changed and fail the workflow if it did. See below for an excerpt of my workflow.
Now the problem is that this action fails both if it cannot parse the spec as well as if there is a breaking change. While it distinguishes between the two cases with exit codes (1 = breaking, >=2 = fail to parse), there's no way for me to detect which one it was. I want to make sure that if the parsing fails, the entire workflow should fail.
My idea is to add a new output (e.g. status: OK | BREAKING | ERROR) which I can then use to distinguish between the two cases.
- name: Detect breaking change
id: breaking
if: github.event_name == 'pull_request' && steps.base.outputs.has_base == 'true'
continue-on-error: true
uses: oasdiff/oasdiff-action/breaking@v0.0.51
with:
base: base-spec.yaml
revision: ${{ env.SPEC_FILE }}
fail-on: ERR
- name: Enforce version bump
if: github.event_name == 'pull_request' && steps.base.outputs.has_base == 'true'
env:
BASE_V: ${{ steps.base.outputs.base_version }}
HEAD_V: ${{ steps.base.outputs.head_version }}
CHANGED: ${{ steps.diff.outcome == 'failure' }}
BREAKING: ${{ steps.breaking.outcome == 'failure' }}
run: |
if [ "$CHANGED" != "true" ]; then
echo "No meaningful spec change (cosmetic only, if any); no version bump required."
exit 0
fi
if [ "$HEAD_V" = "$BASE_V" ]; then
echo "::error::Spec $SPEC_FILE changed but info.version was not bumped (still $BASE_V). Bump it."
exit 1
fi
if [ "$BREAKING" = "true" ] && [ "${HEAD_V%%.*}" -le "${BASE_V%%.*}" ]; then
echo "::error::Breaking change in $SPEC_FILE; requires a MAJOR version bump ($BASE_V -> $HEAD_V)."
exit 1
fi
echo "Version bump OK for $SPEC_FILE: $BASE_V -> $HEAD_V (breaking=$BREAKING)."
Hi,
I'm using this action to validate whether the version in the openapi spec was updated correctly. So for example, I'd have a PR which does not bump the version inside the spec file, but it makes a change, which according to this action, is flagged as major. I then let the workflow fail. However, if the same breaking change was made alongside a version bump, then I'm fine with it.
I do this in my workflow by calling this action with
continue-on-error: trueand then a subsequent step check if the version was changed and fail the workflow if it did. See below for an excerpt of my workflow.Now the problem is that this action fails both if it cannot parse the spec as well as if there is a breaking change. While it distinguishes between the two cases with exit codes (1 = breaking, >=2 = fail to parse), there's no way for me to detect which one it was. I want to make sure that if the parsing fails, the entire workflow should fail.
My idea is to add a new output (e.g.
status: OK | BREAKING | ERROR) which I can then use to distinguish between the two cases.