From 75b4dc8d98c986417315316cd56a4d835dd5d5a8 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 12:49:33 +0200 Subject: [PATCH 01/30] [Issue 46] Unable to process file command 'output' successfully --- .github/workflows/test.yaml | 207 +---------------------------------- specs/petstore-base.yaml | 119 ++++++++++++++++++++ specs/petstore-revision.yaml | 118 ++++++++++++++++++++ 3 files changed, 241 insertions(+), 203 deletions(-) create mode 100644 specs/petstore-base.yaml create mode 100644 specs/petstore-revision.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6ffb4a5..9fb48be 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,207 +9,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: Running diff action - id: test_ete - uses: ./diff + - name: Checking OpenAPI Spec changes + uses: oasdiff/oasdiff-action/breaking@v0.0.18 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 - format: 'text' - output-to-file: 'diff.txt' - - name: Test diff action output to file - run: | - if [ ! -s diff.txt ]; then - echo "Diff file doesn't exist or is empty" - exit 1 - fi - oasdiff_diff_exclude_elements: - runs-on: ubuntu-latest - name: Test diff action with exclude-elements option - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running diff action with exclude-elements option - id: test_exclude_elements - uses: ./diff - with: - base: 'specs/base.yaml' - revision: 'specs/base-exclude-elements.yaml' - format: 'text' - exclude-elements: 'description,title,summary' - - name: Test diff action output - run: | - delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') - output=$(cat <<-$delimiter - ${{ steps.test_exclude_elements.outputs.diff }} - $delimiter - ) - if [ "$output" != "No changes" ]; then - 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 - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running breaking action - id: test_breaking_changes - uses: ./breaking - with: - base: 'specs/base.yaml' - revision: 'specs/revision-breaking.yaml' - fail-on-diff: false - output-to-file: 'breaking.txt' - - 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 '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2 - exit 1 - fi - - name: Test breaking changes action output to file - run: | - if [ ! -s breaking.txt ]; then - echo "Breaking changes file doesn't exist or is empty" - exit 1 - fi - output=$(cat breaking.txt | head -n 1) - if [[ "${output}" != "1 breaking changes: 1 error, 0 warning" ]]; then - 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 - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set date for deprecated specs - run: | - # Deprecate Beta in 14 days - sed -ie "s/{{SUNSET_DATE_BETA}}/$(date --date="14 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml - # Deprecate Stable in 21 days - sed -ie "s/{{SUNSET_DATE_STABLE}}/$(date --date="21 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml - - name: Running OpenAPI Spec check breaking action - id: test_breaking_deprecations - uses: ./breaking - with: - base: specs/base.yaml - revision: specs/base-deprecation.yaml - fail-on-diff: true - deprecation-days-beta: 14 - deprecation-days-stable: 21 - oasdiff_changelog: - runs-on: ubuntu-latest - name: Test generation of changelog - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running changelog action - id: test_changelog - uses: ./changelog - 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 - output-to-file: "changelog.txt" - - name: Test changelog action output - run: | - readonly expected_output="20 changes: 2 error, 4 warning, 14 info" - output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1) - if [[ "${output}" != "${expected_output}" ]]; then - echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 - exit 1 - fi - - name: Test changelog action output to file - run: | - if [ ! -s changelog.txt ]; then - echo "Changelog file doesn't exist or is empty" - exit 1 - fi - output=$(cat changelog.txt | head -n 1) - if [[ "${output}" != "20 changes: 2 error, 4 warning, 14 info" ]]; then - echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 - exit 1 - 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 + base: 'petstore-base.yaml' + revision: 'petstore-revision.yaml' \ No newline at end of file diff --git a/specs/petstore-base.yaml b/specs/petstore-base.yaml new file mode 100644 index 0000000..7ed987f --- /dev/null +++ b/specs/petstore-base.yaml @@ -0,0 +1,119 @@ +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 + maximum: 100 + 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 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + required: true + 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 + maxItems: 100 + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/specs/petstore-revision.yaml b/specs/petstore-revision.yaml new file mode 100644 index 0000000..1409f20 --- /dev/null +++ b/specs/petstore-revision.yaml @@ -0,0 +1,118 @@ +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 + maximum: 100 + 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 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + required: true + 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 + - tag2 + properties: + id: + type: integer + format: int64 + name: + type: string + tag2: + type: string + Pets: + type: array + maxItems: 100 + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + properties: + code: + type: integer + format: int32 + message: + type: string From 14dc02ea30d91cc1ea3a3c200747ef4ff437db46 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 12:51:13 +0200 Subject: [PATCH 02/30] fix path --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9fb48be..8ea0cf8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,5 +12,5 @@ jobs: - name: Checking OpenAPI Spec changes uses: oasdiff/oasdiff-action/breaking@v0.0.18 with: - base: 'petstore-base.yaml' - revision: 'petstore-revision.yaml' \ No newline at end of file + base: 'specs/petstore-base.yaml' + revision: 'specs/petstore-revision.yaml' \ No newline at end of file From 7a6145b7e53a97c61d1ab29cc29d285d10fa5da8 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 12:56:15 +0200 Subject: [PATCH 03/30] t1 --- .github/workflows/test.yaml | 1 - breaking/entrypoint.sh | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8ea0cf8..2f35bed 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,5 @@ name: 'Test oasdiff actions' on: - pull_request: push: jobs: oasdiff_diff: diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index e5d885d..d7bf93f 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -29,7 +29,7 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -readonly output_to_file="${10}" +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" @@ -66,25 +66,41 @@ echo "flags: $flags" # {delimiter} # see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + +echo "***effi 1*** delimiter: $delimiter" + echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" +echo "***effi 2***" + if [ -n "$flags" ]; then output=$(oasdiff breaking "$base" "$revision" $flags) else output=$(oasdiff breaking "$base" "$revision") fi +echo "***effi 3***" + if [ -n "$output" ]; then write_output "$(echo "$output" | head -n 1)" "$output" else write_output "No breaking changes" fi +echo "***effi 4***" + echo "$delimiter" >>"$GITHUB_OUTPUT" +echo "***effi 5***" + # *** github action step output *** # Updating GitHub Action summary with formatted output flags="$flags --format githubactions" + +echo "***effi 6*** flag: $flags" + # Writes the summary to log and updates GitHub Action summary oasdiff breaking "$base" "$revision" $flags + +echo "***effi 7***" \ No newline at end of file From f695702318f7b6ec948419841c3d82629a7f4a20 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 12:59:51 +0200 Subject: [PATCH 04/30] t2 --- breaking/entrypoint.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index d7bf93f..5fe0cf1 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -73,34 +73,34 @@ echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" echo "***effi 2***" -if [ -n "$flags" ]; then - output=$(oasdiff breaking "$base" "$revision" $flags) -else - output=$(oasdiff breaking "$base" "$revision") -fi +# if [ -n "$flags" ]; then +# output=$(oasdiff breaking "$base" "$revision" $flags) +# else +# output=$(oasdiff breaking "$base" "$revision") +# fi -echo "***effi 3***" +# echo "***effi 3***" -if [ -n "$output" ]; then - write_output "$(echo "$output" | head -n 1)" "$output" -else - write_output "No breaking changes" -fi +# if [ -n "$output" ]; then +# write_output "$(echo "$output" | head -n 1)" "$output" +# else +# write_output "No breaking changes" +# fi -echo "***effi 4***" +# echo "***effi 4***" -echo "$delimiter" >>"$GITHUB_OUTPUT" +# echo "$delimiter" >>"$GITHUB_OUTPUT" -echo "***effi 5***" +# echo "***effi 5***" -# *** github action step output *** +# # *** github action step output *** -# Updating GitHub Action summary with formatted output -flags="$flags --format githubactions" +# # Updating GitHub Action summary with formatted output +# flags="$flags --format githubactions" -echo "***effi 6*** flag: $flags" +# echo "***effi 6*** flag: $flags" -# Writes the summary to log and updates GitHub Action summary -oasdiff breaking "$base" "$revision" $flags +# # Writes the summary to log and updates GitHub Action summary +# oasdiff breaking "$base" "$revision" $flags -echo "***effi 7***" \ No newline at end of file +# echo "***effi 7***" \ No newline at end of file From 410b9e3d23867077fda7f05460a1196fd84f11c3 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:00:41 +0200 Subject: [PATCH 05/30] t3 --- breaking/entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 5fe0cf1..0443abb 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -65,13 +65,13 @@ echo "flags: $flags" # {value} # {delimiter} # see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings -delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') +# delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') -echo "***effi 1*** delimiter: $delimiter" +# echo "***effi 1*** delimiter: $delimiter" -echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" +# echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" -echo "***effi 2***" +# echo "***effi 2***" # if [ -n "$flags" ]; then # output=$(oasdiff breaking "$base" "$revision" $flags) From e32a01a4076a41a766ac335fafbf5fcf87fe6e5a Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:01:30 +0200 Subject: [PATCH 06/30] t4 --- breaking/entrypoint.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 0443abb..7c2f247 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -1,24 +1,24 @@ #!/bin/sh set -e -write_output () { - local output="$1" - if [ -n "$output_to_file" ]; then - local file_output="$2" - if [ -z "$file_output" ]; then - file_output=$output - fi - echo "$file_output" >> "$output_to_file" - fi - # github-action limits output to 1MB - # we count bytes because unicode has multibyte characters - size=$(echo "$output" | wc -c) - if [ "$size" -ge "1000000" ]; then - echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2 - output=$(echo "$output" | head -c 1000000) - fi - echo "$output" >>"$GITHUB_OUTPUT" -} +# write_output () { +# local output="$1" +# if [ -n "$output_to_file" ]; then +# local file_output="$2" +# if [ -z "$file_output" ]; then +# file_output=$output +# fi +# echo "$file_output" >> "$output_to_file" +# fi +# # github-action limits output to 1MB +# # we count bytes because unicode has multibyte characters +# size=$(echo "$output" | wc -c) +# if [ "$size" -ge "1000000" ]; then +# echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2 +# output=$(echo "$output" | head -c 1000000) +# fi +# echo "$output" >>"$GITHUB_OUTPUT" +# } readonly base="$1" readonly revision="$2" From 254ea589e01f45d6325b27fdf791a5a85f60ad4f Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:07:20 +0200 Subject: [PATCH 07/30] t5 --- breaking/entrypoint.sh | 47 ------------------------------------------ 1 file changed, 47 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 7c2f247..5c04456 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -57,50 +57,3 @@ if [ "$composed" = "true" ]; then flags="$flags -c" fi echo "flags: $flags" - -# *** github action step output *** - -# output name should be in the syntax of multiple lines: -# {name}<<{delimiter} -# {value} -# {delimiter} -# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings -# delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') - -# echo "***effi 1*** delimiter: $delimiter" - -# echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" - -# echo "***effi 2***" - -# if [ -n "$flags" ]; then -# output=$(oasdiff breaking "$base" "$revision" $flags) -# else -# output=$(oasdiff breaking "$base" "$revision") -# fi - -# echo "***effi 3***" - -# if [ -n "$output" ]; then -# write_output "$(echo "$output" | head -n 1)" "$output" -# else -# write_output "No breaking changes" -# fi - -# echo "***effi 4***" - -# echo "$delimiter" >>"$GITHUB_OUTPUT" - -# echo "***effi 5***" - -# # *** github action step output *** - -# # Updating GitHub Action summary with formatted output -# flags="$flags --format githubactions" - -# echo "***effi 6*** flag: $flags" - -# # Writes the summary to log and updates GitHub Action summary -# oasdiff breaking "$base" "$revision" $flags - -# echo "***effi 7***" \ No newline at end of file From 1e52f76fc27e06c44c4ded3f308b9960e2ad653c Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:10:21 +0200 Subject: [PATCH 08/30] t6 --- breaking/action.yml | 5 ----- breaking/entrypoint.sh | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/breaking/action.yml b/breaking/action.yml index 8238bd9..833f107 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -32,10 +32,6 @@ inputs: description: 'Run in composed mode' required: false default: 'false' - output-to-file: - description: 'Output to a file at the given path' - required: false - default: '' outputs: breaking: description: 'Output summary of API breaking changes, encompassing both warnings and errors' @@ -52,4 +48,3 @@ runs: - ${{ inputs.deprecation-days-stable }} - ${{ inputs.exclude-elements }} - ${{ inputs.composed }} - - ${{ inputs.output-to-file }} diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 5c04456..f0ebc9d 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -29,9 +29,9 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -readonly output_to_file="$10" +# 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_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 # Build flags to pass in command flags="" From 3cc3bfcd2e086d9dbbf62e843c9b8c682b6a22d9 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:13:15 +0200 Subject: [PATCH 09/30] t7 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2f35bed..fc51e82 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - name: Checking OpenAPI Spec changes - uses: oasdiff/oasdiff-action/breaking@v0.0.18 + uses: ./breaking with: base: 'specs/petstore-base.yaml' revision: 'specs/petstore-revision.yaml' \ No newline at end of file From 25ea8f50bdff60ec97422fc0f46617b89419f1a4 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:15:09 +0200 Subject: [PATCH 10/30] t8 --- breaking/action.yml | 5 +++ breaking/entrypoint.sh | 71 ++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/breaking/action.yml b/breaking/action.yml index 833f107..d0b8e29 100644 --- a/breaking/action.yml +++ b/breaking/action.yml @@ -32,6 +32,10 @@ inputs: description: 'Run in composed mode' required: false default: 'false' + output-to-file: + description: 'Output to a file at the given path' + required: false + default: '' outputs: breaking: description: 'Output summary of API breaking changes, encompassing both warnings and errors' @@ -48,3 +52,4 @@ runs: - ${{ inputs.deprecation-days-stable }} - ${{ inputs.exclude-elements }} - ${{ inputs.composed }} + - ${{ inputs.output-to-file }} \ No newline at end of file diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index f0ebc9d..e5d885d 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -1,24 +1,24 @@ #!/bin/sh set -e -# write_output () { -# local output="$1" -# if [ -n "$output_to_file" ]; then -# local file_output="$2" -# if [ -z "$file_output" ]; then -# file_output=$output -# fi -# echo "$file_output" >> "$output_to_file" -# fi -# # github-action limits output to 1MB -# # we count bytes because unicode has multibyte characters -# size=$(echo "$output" | wc -c) -# if [ "$size" -ge "1000000" ]; then -# echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2 -# output=$(echo "$output" | head -c 1000000) -# fi -# echo "$output" >>"$GITHUB_OUTPUT" -# } +write_output () { + local output="$1" + if [ -n "$output_to_file" ]; then + local file_output="$2" + if [ -z "$file_output" ]; then + file_output=$output + fi + echo "$file_output" >> "$output_to_file" + fi + # github-action limits output to 1MB + # we count bytes because unicode has multibyte characters + size=$(echo "$output" | wc -c) + if [ "$size" -ge "1000000" ]; then + echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2 + output=$(echo "$output" | head -c 1000000) + fi + echo "$output" >>"$GITHUB_OUTPUT" +} readonly base="$1" readonly revision="$2" @@ -29,9 +29,9 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -# readonly output_to_file="$10" +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 +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" # Build flags to pass in command flags="" @@ -57,3 +57,34 @@ if [ "$composed" = "true" ]; then flags="$flags -c" fi echo "flags: $flags" + +# *** github action step output *** + +# output name should be in the syntax of multiple lines: +# {name}<<{delimiter} +# {value} +# {delimiter} +# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings +delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') +echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" + +if [ -n "$flags" ]; then + output=$(oasdiff breaking "$base" "$revision" $flags) +else + output=$(oasdiff breaking "$base" "$revision") +fi + +if [ -n "$output" ]; then + write_output "$(echo "$output" | head -n 1)" "$output" +else + write_output "No breaking changes" +fi + +echo "$delimiter" >>"$GITHUB_OUTPUT" + +# *** github action step output *** + +# Updating GitHub Action summary with formatted output +flags="$flags --format githubactions" +# Writes the summary to log and updates GitHub Action summary +oasdiff breaking "$base" "$revision" $flags From bd6e0fce6240ed18ee503fafc45b8510aff1e687 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:16:00 +0200 Subject: [PATCH 11/30] t9 --- breaking/entrypoint.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index e5d885d..3b4af97 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -57,34 +57,3 @@ if [ "$composed" = "true" ]; then flags="$flags -c" fi echo "flags: $flags" - -# *** github action step output *** - -# output name should be in the syntax of multiple lines: -# {name}<<{delimiter} -# {value} -# {delimiter} -# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings -delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') -echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" - -if [ -n "$flags" ]; then - output=$(oasdiff breaking "$base" "$revision" $flags) -else - output=$(oasdiff breaking "$base" "$revision") -fi - -if [ -n "$output" ]; then - write_output "$(echo "$output" | head -n 1)" "$output" -else - write_output "No breaking changes" -fi - -echo "$delimiter" >>"$GITHUB_OUTPUT" - -# *** github action step output *** - -# Updating GitHub Action summary with formatted output -flags="$flags --format githubactions" -# Writes the summary to log and updates GitHub Action summary -oasdiff breaking "$base" "$revision" $flags From 27ecf9a87559ecf2e80fecdf3fdc97cf5291c616 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:16:46 +0200 Subject: [PATCH 12/30] t9 --- breaking/entrypoint.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 3b4af97..873edfc 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -57,3 +57,13 @@ if [ "$composed" = "true" ]; then flags="$flags -c" fi echo "flags: $flags" + +# *** github action step output *** + +# output name should be in the syntax of multiple lines: +# {name}<<{delimiter} +# {value} +# {delimiter} +# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings +delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') +echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" From deed2d290eac8005004080f27b561dd3a2b049f5 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:17:18 +0200 Subject: [PATCH 13/30] t11 --- breaking/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 873edfc..0640c69 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -66,4 +66,4 @@ echo "flags: $flags" # {delimiter} # see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') -echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" +# echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" From 3fdce76c757b826cfd2f53d8180d6821664832b4 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:26:11 +0200 Subject: [PATCH 14/30] t12 --- breaking/entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 0640c69..b8dd77d 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -2,7 +2,9 @@ set -e write_output () { + local output="$1" + if [ -n "$output_to_file" ]; then local file_output="$2" if [ -z "$file_output" ]; then @@ -10,6 +12,7 @@ write_output () { fi echo "$file_output" >> "$output_to_file" fi + # github-action limits output to 1MB # we count bytes because unicode has multibyte characters size=$(echo "$output" | wc -c) @@ -66,4 +69,6 @@ echo "flags: $flags" # {delimiter} # see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') -# echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" +echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" +write_output "No breaking changes" +echo "$delimiter" >>"$GITHUB_OUTPUT" \ No newline at end of file From 42db04d9ade2c064c03f7589b341fd7623e699f2 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:33:13 +0200 Subject: [PATCH 15/30] t13 --- breaking/entrypoint.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index b8dd77d..9a9233b 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -70,5 +70,12 @@ echo "flags: $flags" # see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" + +if [ -n "$flags" ]; then + output=$(oasdiff breaking "$base" "$revision" $flags) +else + output=$(oasdiff breaking "$base" "$revision") +fi + write_output "No breaking changes" echo "$delimiter" >>"$GITHUB_OUTPUT" \ No newline at end of file From 3971f66cc4ac4e2451fb8918d662064e34a7eb0c Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:35:54 +0200 Subject: [PATCH 16/30] t14 --- breaking/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 9a9233b..6577730 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -72,9 +72,9 @@ delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" if [ -n "$flags" ]; then - output=$(oasdiff breaking "$base" "$revision" $flags) + breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) else - output=$(oasdiff breaking "$base" "$revision") + breaking_changes=$(oasdiff breaking "$base" "$revision") fi write_output "No breaking changes" From 546d91900f63ddb1db3e6e433cb5fb203dc6fac1 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:38:42 +0200 Subject: [PATCH 17/30] t14 --- breaking/entrypoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 6577730..5f2e7de 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -71,11 +71,11 @@ echo "flags: $flags" delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" -if [ -n "$flags" ]; then - breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) -else - breaking_changes=$(oasdiff breaking "$base" "$revision") -fi +# if [ -n "$flags" ]; then +# breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) +# else +# breaking_changes=$(oasdiff breaking "$base" "$revision") +# fi write_output "No breaking changes" echo "$delimiter" >>"$GITHUB_OUTPUT" \ No newline at end of file From 87a797d50ece71e67937156d1880d2baa3b1a6e6 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:39:57 +0200 Subject: [PATCH 18/30] t15 --- breaking/entrypoint.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 5f2e7de..fed9a27 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -61,6 +61,12 @@ if [ "$composed" = "true" ]; then fi echo "flags: $flags" +if [ -n "$flags" ]; then + breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) +else + breaking_changes=$(oasdiff breaking "$base" "$revision") +fi + # *** github action step output *** # output name should be in the syntax of multiple lines: @@ -71,11 +77,5 @@ echo "flags: $flags" delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" -# if [ -n "$flags" ]; then -# breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) -# else -# breaking_changes=$(oasdiff breaking "$base" "$revision") -# fi - write_output "No breaking changes" echo "$delimiter" >>"$GITHUB_OUTPUT" \ No newline at end of file From 30ebd5ac6e09f95295124d838d41616de041598f Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:45:01 +0200 Subject: [PATCH 19/30] t16 --- breaking/entrypoint.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index fed9a27..fa43720 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -2,9 +2,7 @@ set -e write_output () { - local output="$1" - if [ -n "$output_to_file" ]; then local file_output="$2" if [ -z "$file_output" ]; then @@ -12,7 +10,6 @@ write_output () { fi echo "$file_output" >> "$output_to_file" fi - # github-action limits output to 1MB # we count bytes because unicode has multibyte characters size=$(echo "$output" | wc -c) @@ -61,15 +58,16 @@ if [ "$composed" = "true" ]; then fi echo "flags: $flags" +# Check for breaking changes if [ -n "$flags" ]; then breaking_changes=$(oasdiff breaking "$base" "$revision" $flags) else breaking_changes=$(oasdiff breaking "$base" "$revision") fi -# *** github action step output *** +# *** GitHub Action step output *** -# output name should be in the syntax of multiple lines: +# Output name should be in the syntax of multiple lines: # {name}<<{delimiter} # {value} # {delimiter} @@ -77,5 +75,17 @@ fi delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') echo "breaking<<$delimiter" >>"$GITHUB_OUTPUT" -write_output "No breaking changes" -echo "$delimiter" >>"$GITHUB_OUTPUT" \ No newline at end of file +if [ -n "$breaking_changes" ]; then + write_output "$(echo "$breaking_changes" | head -n 1)" "$breaking_changes" +else + write_output "No breaking changes" +fi + +echo "$delimiter" >>"$GITHUB_OUTPUT" + +# *** END GitHub Action step output *** + +# Updating GitHub Action summary with formatted output +flags="$flags --format githubactions" +# Writes the summary to log and updates GitHub Action summary +oasdiff breaking "$base" "$revision" $flags From b6415bb7d3616d30db95fb6df3cf29bb5f4db9dd Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:47:29 +0200 Subject: [PATCH 20/30] fail-on-diff: false --- .github/workflows/test.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fc51e82..151c819 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,4 +12,5 @@ jobs: uses: ./breaking with: base: 'specs/petstore-base.yaml' - revision: 'specs/petstore-revision.yaml' \ No newline at end of file + revision: 'specs/petstore-revision.yaml' + fail-on-diff: false \ No newline at end of file From 0998a139158422b3ca82aeb0861684a202b2da1a Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 13:57:08 +0200 Subject: [PATCH 21/30] all tests --- .github/workflows/test.yaml | 219 +++++++++++++++++++++++++++++++++++- 1 file changed, 215 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 151c819..22ece3d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,5 +1,6 @@ name: 'Test oasdiff actions' on: + pull_request: push: jobs: oasdiff_diff: @@ -8,9 +9,219 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: Checking OpenAPI Spec changes + - name: Running diff action + id: test_ete + uses: ./diff + 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 + format: 'text' + output-to-file: 'diff.txt' + - name: Test diff action output to file + run: | + if [ ! -s diff.txt ]; then + echo "Diff file doesn't exist or is empty" + exit 1 + fi + oasdiff_diff_exclude_elements: + runs-on: ubuntu-latest + name: Test diff action with exclude-elements option + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running diff action with exclude-elements option + id: test_exclude_elements + uses: ./diff + with: + base: 'specs/base.yaml' + revision: 'specs/base-exclude-elements.yaml' + format: 'text' + exclude-elements: 'description,title,summary' + - name: Test diff action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_exclude_elements.outputs.diff }} + $delimiter + ) + if [ "$output" != "No changes" ]; then + 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 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running breaking action + id: test_breaking_changes + uses: ./breaking + with: + base: 'specs/base.yaml' + revision: 'specs/revision-breaking.yaml' + fail-on-diff: false + output-to-file: 'breaking.txt' + - 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 '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2 + exit 1 + fi + - name: Test breaking changes action output to file + run: | + if [ ! -s breaking.txt ]; then + echo "Breaking changes file doesn't exist or is empty" + exit 1 + fi + output=$(cat breaking.txt | head -n 1) + if [[ "${output}" != "1 breaking changes: 1 error, 0 warning" ]]; then + echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '${output}'" >&2 + exit 1 + fi + oasdiff_breaking_matching_delimiter_not_found: + runs-on: ubuntu-latest + name: Test breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found + uses: ./breaking + with: + base: 'specs/petstore-base.yaml' + revision: 'specs/petstore-revision.yaml' + fail-on-diff: false + 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 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Set date for deprecated specs + run: | + # Deprecate Beta in 14 days + sed -ie "s/{{SUNSET_DATE_BETA}}/$(date --date="14 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml + # Deprecate Stable in 21 days + sed -ie "s/{{SUNSET_DATE_STABLE}}/$(date --date="21 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml + - name: Running OpenAPI Spec check breaking action + id: test_breaking_deprecations uses: ./breaking with: - base: 'specs/petstore-base.yaml' - revision: 'specs/petstore-revision.yaml' - fail-on-diff: false \ No newline at end of file + base: specs/base.yaml + revision: specs/base-deprecation.yaml + fail-on-diff: true + deprecation-days-beta: 14 + deprecation-days-stable: 21 + oasdiff_changelog: + runs-on: ubuntu-latest + name: Test generation of changelog + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running changelog action + id: test_changelog + uses: ./changelog + 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 + output-to-file: "changelog.txt" + - name: Test changelog action output + run: | + readonly expected_output="20 changes: 2 error, 4 warning, 14 info" + output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1) + if [[ "${output}" != "${expected_output}" ]]; then + echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 + exit 1 + fi + - name: Test changelog action output to file + run: | + if [ ! -s changelog.txt ]; then + echo "Changelog file doesn't exist or is empty" + exit 1 + fi + output=$(cat changelog.txt | head -n 1) + if [[ "${output}" != "20 changes: 2 error, 4 warning, 14 info" ]]; then + echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 + exit 1 + 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 From 11419d395e5b7ec25e3caa383a48acaa0e574e69 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 14:02:11 +0200 Subject: [PATCH 22/30] format --- breaking/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index fa43720..396064b 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -29,7 +29,7 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -readonly output_to_file="${10}" +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" From 892a7fb71d34720f2efa646faccdd63a249a971c Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 14:03:41 +0200 Subject: [PATCH 23/30] revert --- breaking/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 396064b..fa43720 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -29,7 +29,7 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -readonly output_to_file="$10" +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" From 1ccf75b6575ffa5edc8082f4729372937a411814 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 14:28:05 +0200 Subject: [PATCH 24/30] test output --- .github/workflows/test.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 22ece3d..0c21ebc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -116,11 +116,23 @@ jobs: - name: checkout uses: actions/checkout@v4 - name: Running breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found + id: test_breaking_changes_matching_delimiter_not_found uses: ./breaking with: base: 'specs/petstore-base.yaml' revision: 'specs/petstore-revision.yaml' fail-on-diff: false + - name: Test breaking changes action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_breaking_changes_matching_delimiter_not_found.outputs.breaking }} + $delimiter + ) + if [ "$output" != "9 breaking changes: 6 error, 3 warning" ]; then + echo "Expected output '9 breaking changes: 6 error, 3 warning' but got '$output'" >&2 + exit 1 + fi oasdiff_breaking_composed: runs-on: ubuntu-latest name: Test breaking action with composed option From 8576396450d3aaf537dcf2ce32da53f0a8368e95 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:04:46 +0200 Subject: [PATCH 25/30] oasdiff/oasdiff-action/breaking@v0.0.16 --- .github/workflows/test.yaml | 212 +----------------------------------- 1 file changed, 1 insertion(+), 211 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c21ebc..0d521fb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,112 +3,6 @@ on: pull_request: push: jobs: - oasdiff_diff: - runs-on: ubuntu-latest - name: Test diff action - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running diff action - id: test_ete - uses: ./diff - 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 - format: 'text' - output-to-file: 'diff.txt' - - name: Test diff action output to file - run: | - if [ ! -s diff.txt ]; then - echo "Diff file doesn't exist or is empty" - exit 1 - fi - oasdiff_diff_exclude_elements: - runs-on: ubuntu-latest - name: Test diff action with exclude-elements option - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running diff action with exclude-elements option - id: test_exclude_elements - uses: ./diff - with: - base: 'specs/base.yaml' - revision: 'specs/base-exclude-elements.yaml' - format: 'text' - exclude-elements: 'description,title,summary' - - name: Test diff action output - run: | - delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') - output=$(cat <<-$delimiter - ${{ steps.test_exclude_elements.outputs.diff }} - $delimiter - ) - if [ "$output" != "No changes" ]; then - 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 - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running breaking action - id: test_breaking_changes - uses: ./breaking - with: - base: 'specs/base.yaml' - revision: 'specs/revision-breaking.yaml' - fail-on-diff: false - output-to-file: 'breaking.txt' - - 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 '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2 - exit 1 - fi - - name: Test breaking changes action output to file - run: | - if [ ! -s breaking.txt ]; then - echo "Breaking changes file doesn't exist or is empty" - exit 1 - fi - output=$(cat breaking.txt | head -n 1) - if [[ "${output}" != "1 breaking changes: 1 error, 0 warning" ]]; then - echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '${output}'" >&2 - exit 1 - fi oasdiff_breaking_matching_delimiter_not_found: runs-on: ubuntu-latest name: Test breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found @@ -117,7 +11,7 @@ jobs: uses: actions/checkout@v4 - name: Running breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found id: test_breaking_changes_matching_delimiter_not_found - uses: ./breaking + uses: oasdiff/oasdiff-action/breaking@v0.0.16 with: base: 'specs/petstore-base.yaml' revision: 'specs/petstore-revision.yaml' @@ -133,107 +27,3 @@ jobs: echo "Expected output '9 breaking changes: 6 error, 3 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 - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set date for deprecated specs - run: | - # Deprecate Beta in 14 days - sed -ie "s/{{SUNSET_DATE_BETA}}/$(date --date="14 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml - # Deprecate Stable in 21 days - sed -ie "s/{{SUNSET_DATE_STABLE}}/$(date --date="21 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml - - name: Running OpenAPI Spec check breaking action - id: test_breaking_deprecations - uses: ./breaking - with: - base: specs/base.yaml - revision: specs/base-deprecation.yaml - fail-on-diff: true - deprecation-days-beta: 14 - deprecation-days-stable: 21 - oasdiff_changelog: - runs-on: ubuntu-latest - name: Test generation of changelog - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Running changelog action - id: test_changelog - uses: ./changelog - 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 - output-to-file: "changelog.txt" - - name: Test changelog action output - run: | - readonly expected_output="20 changes: 2 error, 4 warning, 14 info" - output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1) - if [[ "${output}" != "${expected_output}" ]]; then - echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 - exit 1 - fi - - name: Test changelog action output to file - run: | - if [ ! -s changelog.txt ]; then - echo "Changelog file doesn't exist or is empty" - exit 1 - fi - output=$(cat changelog.txt | head -n 1) - if [[ "${output}" != "20 changes: 2 error, 4 warning, 14 info" ]]; then - echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 - exit 1 - 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 From debb6fe622376378c6a34039d836899b622e4922 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:07:22 +0200 Subject: [PATCH 26/30] move up --- .github/workflows/test.yaml | 2 +- breaking/entrypoint.sh | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0d521fb..8e6b92d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v4 - name: Running breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found id: test_breaking_changes_matching_delimiter_not_found - uses: oasdiff/oasdiff-action/breaking@v0.0.16 + uses: ./breaking with: base: 'specs/petstore-base.yaml' revision: 'specs/petstore-revision.yaml' diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index fa43720..09712ec 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -65,6 +65,9 @@ else breaking_changes=$(oasdiff breaking "$base" "$revision") fi +# Writes the summary to log and updates GitHub Action summary +oasdiff breaking "$base" "$revision" "$flags --format githubactions" + # *** GitHub Action step output *** # Output name should be in the syntax of multiple lines: @@ -82,10 +85,3 @@ else fi echo "$delimiter" >>"$GITHUB_OUTPUT" - -# *** END GitHub Action step output *** - -# Updating GitHub Action summary with formatted output -flags="$flags --format githubactions" -# Writes the summary to log and updates GitHub Action summary -oasdiff breaking "$base" "$revision" $flags From d7f69a0abe294da190c5818960139e2906a5398f Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:09:01 +0200 Subject: [PATCH 27/30] mu 2 --- .github/workflows/test.yaml | 1 - breaking/entrypoint.sh | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8e6b92d..635d129 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,5 @@ name: 'Test oasdiff actions' on: - pull_request: push: jobs: oasdiff_breaking_matching_delimiter_not_found: diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index 09712ec..e574c73 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -65,8 +65,10 @@ else breaking_changes=$(oasdiff breaking "$base" "$revision") fi +# Updating GitHub Action summary with formatted output +flags_with_githubactions="$flags --format githubactions" # Writes the summary to log and updates GitHub Action summary -oasdiff breaking "$base" "$revision" "$flags --format githubactions" +oasdiff breaking "$base" "$revision" $flags_with_githubactions # *** GitHub Action step output *** From 3c73c6bc9cfab1ed0c59ed0d7df69012b2d09b29 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:28:12 +0200 Subject: [PATCH 28/30] all --- .github/workflows/test.yaml | 211 ++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 635d129..0c21ebc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,7 +1,114 @@ name: 'Test oasdiff actions' on: + pull_request: push: jobs: + oasdiff_diff: + runs-on: ubuntu-latest + name: Test diff action + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running diff action + id: test_ete + uses: ./diff + 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 + format: 'text' + output-to-file: 'diff.txt' + - name: Test diff action output to file + run: | + if [ ! -s diff.txt ]; then + echo "Diff file doesn't exist or is empty" + exit 1 + fi + oasdiff_diff_exclude_elements: + runs-on: ubuntu-latest + name: Test diff action with exclude-elements option + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running diff action with exclude-elements option + id: test_exclude_elements + uses: ./diff + with: + base: 'specs/base.yaml' + revision: 'specs/base-exclude-elements.yaml' + format: 'text' + exclude-elements: 'description,title,summary' + - name: Test diff action output + run: | + delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-') + output=$(cat <<-$delimiter + ${{ steps.test_exclude_elements.outputs.diff }} + $delimiter + ) + if [ "$output" != "No changes" ]; then + 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 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running breaking action + id: test_breaking_changes + uses: ./breaking + with: + base: 'specs/base.yaml' + revision: 'specs/revision-breaking.yaml' + fail-on-diff: false + output-to-file: 'breaking.txt' + - 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 '1 breaking changes: 1 error, 0 warning' but got '$output'" >&2 + exit 1 + fi + - name: Test breaking changes action output to file + run: | + if [ ! -s breaking.txt ]; then + echo "Breaking changes file doesn't exist or is empty" + exit 1 + fi + output=$(cat breaking.txt | head -n 1) + if [[ "${output}" != "1 breaking changes: 1 error, 0 warning" ]]; then + echo "Expected output '1 breaking changes: 1 error, 0 warning' but got '${output}'" >&2 + exit 1 + fi oasdiff_breaking_matching_delimiter_not_found: runs-on: ubuntu-latest name: Test breaking action with petsotre to validate no error of unable to process file command 'output' successfully and invalid value and matching delimiter not found @@ -26,3 +133,107 @@ jobs: echo "Expected output '9 breaking changes: 6 error, 3 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 + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Set date for deprecated specs + run: | + # Deprecate Beta in 14 days + sed -ie "s/{{SUNSET_DATE_BETA}}/$(date --date="14 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml + # Deprecate Stable in 21 days + sed -ie "s/{{SUNSET_DATE_STABLE}}/$(date --date="21 day" "+%Y-%m-%d")/" specs/base-deprecation.yaml + - name: Running OpenAPI Spec check breaking action + id: test_breaking_deprecations + uses: ./breaking + with: + base: specs/base.yaml + revision: specs/base-deprecation.yaml + fail-on-diff: true + deprecation-days-beta: 14 + deprecation-days-stable: 21 + oasdiff_changelog: + runs-on: ubuntu-latest + name: Test generation of changelog + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Running changelog action + id: test_changelog + uses: ./changelog + 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 + output-to-file: "changelog.txt" + - name: Test changelog action output + run: | + readonly expected_output="20 changes: 2 error, 4 warning, 14 info" + output=$(echo "${{steps.test_changelog.outputs.changelog}}" | head -n 1) + if [[ "${output}" != "${expected_output}" ]]; then + echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 + exit 1 + fi + - name: Test changelog action output to file + run: | + if [ ! -s changelog.txt ]; then + echo "Changelog file doesn't exist or is empty" + exit 1 + fi + output=$(cat changelog.txt | head -n 1) + if [[ "${output}" != "20 changes: 2 error, 4 warning, 14 info" ]]; then + echo "Expected output '20 changes: 2 error, 4 warning, 14 info' but got '${output}'" >&2 + exit 1 + 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 From 3a39d498d235eef4658bffde928983940d9536ac Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:36:56 +0200 Subject: [PATCH 29/30] fix: In POSIX sh, local is undefined --- breaking/entrypoint.sh | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index e574c73..b0ddf51 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -1,36 +1,37 @@ #!/bin/sh set -e +readonly base="$1" +readonly revision="$2" +readonly fail_on_diff="$3" +readonly include_checks="$4" +readonly include_path_params="$5" +readonly deprecation_days_beta="$6" +readonly deprecation_days_stable="$7" +readonly exclude_elements="$8" +readonly composed="$9" +readonly output_to_file="$10" + write_output () { - local output="$1" + _write_output_output="$1" if [ -n "$output_to_file" ]; then - local file_output="$2" - if [ -z "$file_output" ]; then - file_output=$output + _write_output_file_output="$2" + if [ -z "$_write_output_file_output" ]; then + _write_output_file_output=$_write_output_output + fi - echo "$file_output" >> "$output_to_file" + echo "$_write_output_file_output" >> "$output_to_file" fi # github-action limits output to 1MB # we count bytes because unicode has multibyte characters - size=$(echo "$output" | wc -c) + size=$(echo "$_write_output_output" | wc -c) if [ "$size" -ge "1000000" ]; then echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2 - output=$(echo "$output" | head -c 1000000) + _write_output_output=$(echo "$_write_output_output" | head -c 1000000) fi - echo "$output" >>"$GITHUB_OUTPUT" + echo "$_write_output_output" >>"$GITHUB_OUTPUT" } -readonly base="$1" -readonly revision="$2" -readonly fail_on_diff="$3" -readonly include_checks="$4" -readonly include_path_params="$5" -readonly deprecation_days_beta="$6" -readonly deprecation_days_stable="$7" -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" # Build flags to pass in command From fc826b9f0d21b85b085842521c7a8cc445412c08 Mon Sep 17 00:00:00 2001 From: effoeffi Date: Mon, 11 Mar 2024 15:39:41 +0200 Subject: [PATCH 30/30] fix --- breaking/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breaking/entrypoint.sh b/breaking/entrypoint.sh index b0ddf51..e52050c 100755 --- a/breaking/entrypoint.sh +++ b/breaking/entrypoint.sh @@ -10,7 +10,7 @@ readonly deprecation_days_beta="$6" readonly deprecation_days_stable="$7" readonly exclude_elements="$8" readonly composed="$9" -readonly output_to_file="$10" +readonly output_to_file="${10}" write_output () { _write_output_output="$1"