Skip to content

Commit

Permalink
[Issue 46] Unable to process file command 'output' successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
effoeffi committed Mar 11, 2024
1 parent 205ce7e commit 75b4dc8
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 203 deletions.
207 changes: 4 additions & 203 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
base: 'petstore-base.yaml'
revision: 'petstore-revision.yaml'
119 changes: 119 additions & 0 deletions specs/petstore-base.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 75b4dc8

Please sign in to comment.