Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add composed mode to actions. #41

Merged
merged 9 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 78 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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`.

Expand All @@ -63,4 +65,5 @@ Additional arguments:
| CLI | Action input | Default |
|--------|--------|--------|
| --include-path-params | include-path-params | false |
| --exclude-elements | exclude-elements | '' |
| --exclude-elements | exclude-elements | '' |
| --composed | composed | false |
5 changes: 5 additions & 0 deletions breaking/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -43,3 +47,4 @@ runs:
- ${{ inputs.deprecation-days-beta }}
- ${{ inputs.deprecation-days-stable }}
- ${{ inputs.exclude-elements }}
- ${{ inputs.composed }}
4 changes: 4 additions & 0 deletions breaking/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 ***
Expand Down
5 changes: 5 additions & 0 deletions changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -26,3 +30,4 @@ runs:
- ${{ inputs.revision }}
- ${{ inputs.include-path-params }}
- ${{ inputs.exclude-elements }}
- ${{ inputs.composed }}
4 changes: 4 additions & 0 deletions changelog/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions diff/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -36,3 +40,4 @@ runs:
- ${{ inputs.fail-on-diff }}
- ${{ inputs.include-path-params }}
- ${{ inputs.exclude-elements }}
- ${{ inputs.composed }}
4 changes: 4 additions & 0 deletions diff/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 ***
Expand Down
111 changes: 111 additions & 0 deletions specs/glob/base/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
openapi: "3.0.0"

Check failure on line 1 in specs/glob/base/base.yaml

View workflow job for this annotation

GitHub Actions / Test breaking action with composed option

api-removed-without-deprecation

in API GET /pets api removed without deprecation
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
Loading
Loading