diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 99b951e..6816f28 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -41,6 +41,31 @@ jobs: echo "Expected output 'No changes' but got '$output'" >&2 exit 1 fi + oasdiff_diff_composed: + runs-on: ubuntu-latest + name: Test diff action with composed option + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running diff action with composed option + id: test_composed + uses: ./diff + with: + base: 'specs/glob/base/*.yaml' + revision: 'specs/glob/revision/*.yaml' + format: 'text' + composed: true + - name: Test diff action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_composed.outputs.diff }} + $delimiter + ) + if [[ ! "$output" =~ "Deleted Endpoints: 1" ]]; then + echo "Expected 'Deleted Endpoints: 1' to be modified in diff, instead got '$output'" >&2 + exit 1 + fi oasdiff_breaking: runs-on: ubuntu-latest name: Test breaking changes @@ -62,9 +87,35 @@ jobs: $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 + echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2 exit 1 fi + oasdiff_breaking_composed: + runs-on: ubuntu-latest + name: Test breaking action with composed option + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running breaking action with composed option + id: test_breaking_composed + uses: ./breaking + with: + base: 'specs/glob/base/*.yaml' + revision: 'specs/glob/revision/*.yaml' + fail-on-diff: false + format: 'text' + composed: true + - name: Test breaking action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_breaking_composed.outputs.breaking }} + $delimiter + ) + if [[ ! "$output" =~ "1 breaking changes: 1 error, 0 warning" ]]; then + echo "Expected '1 breaking changes: 1 error, 0 warning', instead got '$output'" >&2 + exit 1 + fi oasdiff_breaking_deprecation: runs-on: ubuntu-latest name: Test breaking changes with deprecation @@ -105,4 +156,29 @@ jobs: if [[ "${output}" != "${expected_output}" ]]; then echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 exit 1 - fi + fi + oasdiff_changelog_composed: + runs-on: ubuntu-latest + name: Test changelog action with composed option + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running changelog action with composed option + id: test_changelog_composed + uses: ./changelog + with: + base: 'specs/glob/base/*.yaml' + revision: 'specs/glob/revision/*.yaml' + format: 'text' + composed: true + - name: Test changelog action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_changelog_composed.outputs.changelog }} + $delimiter + ) + if [[ ! "$output" =~ "1 changes: 1 error, 0 warning, 0 info" ]]; then + echo "Expected '1 changes: 1 error, 0 warning, 0 info', instead got '$output'" >&2 + exit 1 + fi \ No newline at end of file diff --git a/README.md b/README.md index 234d57f..5941ce2 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This action supports additional arguments that are converted to parameters for t | --format | format | yaml | | --include-path-params | include-path-params | false | | --exclude-elements | exclude-elements | '' | +| --composed | composed | false | ### Check for breaking API changes, and fail if any are found Copy and paste the following snippet into your build .yml file: @@ -45,6 +46,7 @@ Additional arguments: | --deprecation-days-beta | deprecation-days-beta | 31 | | --deprecation-days-stable | deprecation-days-stable | 180 | | --exclude-elements | exclude-elements | '' | +| --composed | composed | false | This action delivers a summary of breaking changes, accessible as a GitHub step output named `breaking`. @@ -63,4 +65,5 @@ Additional arguments: | CLI | Action input | Default | |--------|--------|--------| | --include-path-params | include-path-params | false | -| --exclude-elements | exclude-elements | '' | \ No newline at end of file +| --exclude-elements | exclude-elements | '' | +| --composed | composed | false | \ No newline at end of file diff --git a/breaking/action.yml b/breaking/action.yml index 3a43bee..833f107 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -28,6 +28,10 @@ inputs: description: 'Exclude certain kinds of changes' required: false default: '' + composed: + description: 'Run in composed mode' + required: false + default: 'false' outputs: breaking: description: 'Output summary of API breaking changes, encompassing both warnings and errors' @@ -43,3 +47,4 @@ runs: - ${{ inputs.deprecation-days-beta }} - ${{ inputs.deprecation-days-stable }} - ${{ inputs.exclude-elements }} + - ${{ inputs.composed }} diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index df79af8..18c800f 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -9,6 +9,7 @@ readonly include_path_params="$5" readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" +readonly composed="$9" 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" @@ -32,6 +33,9 @@ fi if [ "$exclude_elements" != "" ]; then flags="${flags} --exclude-elements ${exclude_elements}" fi +if [ "$composed" = "true" ]; then + flags="${flags} -c" +fi echo "flags: $flags" # *** github action step output *** diff --git a/changelog/action.yml b/changelog/action.yml index 6056fa8..c445741 100644 --- a/changelog/action.yml +++ b/changelog/action.yml @@ -15,6 +15,10 @@ inputs: description: 'Exclude certain kinds of changes' required: false default: '' + composed: + description: 'Run in composed mode' + required: false + default: 'false' outputs: changelog: description: 'Output summary of API changelog' @@ -26,3 +30,4 @@ runs: - ${{ inputs.revision }} - ${{ inputs.include-path-params }} - ${{ inputs.exclude-elements }} + - ${{ inputs.composed }} diff --git a/changelog/entrypoint.sh b/changelog/entrypoint.sh index 8a74214..c0139e7 100755 --- a/changelog/entrypoint.sh +++ b/changelog/entrypoint.sh @@ -5,6 +5,7 @@ readonly base="$1" readonly revision="$2" readonly include_path_params="$3" readonly exclude_elements="$4" +readonly composed="$5" echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params, exclude_elements: $exclude_elements" @@ -16,6 +17,9 @@ fi if [ "$exclude_elements" != "" ]; then flags="${flags} --exclude-elements ${exclude_elements}" fi +if [ "$composed" = "true" ]; then + flags="${flags} -c" +fi echo "flags: $flags" set -o pipefail diff --git a/diff/action.yml b/diff/action.yml index 550a93a..f9bbd65 100644 --- a/diff/action.yml +++ b/diff/action.yml @@ -23,6 +23,10 @@ inputs: description: 'Exclude certain kinds of changes' required: false default: '' + composed: + description: 'Run in composed mode' + required: false + default: 'false' outputs: diff: description: 'Output summary of API diff' @@ -36,3 +40,4 @@ runs: - ${{ inputs.fail-on-diff }} - ${{ inputs.include-path-params }} - ${{ inputs.exclude-elements }} + - ${{ inputs.composed }} diff --git a/diff/entrypoint.sh b/diff/entrypoint.sh index 8d0cd68..fdcb4c1 100755 --- a/diff/entrypoint.sh +++ b/diff/entrypoint.sh @@ -7,6 +7,7 @@ readonly format="$3" readonly fail_on_diff="$4" readonly include_path_params="$5" readonly exclude_elements="$6" +readonly composed="$7" echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff, include_path_params: $include_path_params, exclude_elements: $exclude_elements" @@ -24,6 +25,9 @@ fi if [ "$exclude_elements" != "" ]; then flags="${flags} --exclude-elements ${exclude_elements}" fi +if [ "$composed" = "true" ]; then + flags="${flags} -c" +fi echo "flags: $flags" # *** github action step output *** diff --git a/specs/glob/base/base.yaml b/specs/glob/base/base.yaml new file mode 100644 index 0000000..acdeb1f --- /dev/null +++ b/specs/glob/base/base.yaml @@ -0,0 +1,111 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string \ No newline at end of file diff --git a/specs/glob/revision/revision-breaking.yaml b/specs/glob/revision/revision-breaking.yaml new file mode 100644 index 0000000..c9c246d --- /dev/null +++ b/specs/glob/revision/revision-breaking.yaml @@ -0,0 +1,80 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string \ No newline at end of file