Skip to content

feat!: refactor action to be CLI based #13

feat!: refactor action to be CLI based

feat!: refactor action to be CLI based #13

Workflow file for this run

name: PR testing of CLI action
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
jobs:
test-defaults:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: test/asyncapi.yml
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./output/asyncapi.md" ]; then
echo "Files exist"
else
echo "Files do not exist:- ./output/asyncapi.md"
echo "Action failed"
exit 1
fi
test-validate-success:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: test/asyncapi.yml
command: validate
test-custom-command:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
# Custom command to generate models
# Note: You can use command itself to generate models, but this is just an example for testing custom commands
custom_command: "generate models typescript ./test/asyncapi.yml -o ./output"
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./output/AnonymousSchema_1.ts" ]; then
echo "Models have been generated"
else
echo "Models have not been generated"
echo "Action failed"
exit 1
fi
test-custom-output:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: test/asyncapi.yml
output: custom-output
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./custom-output/asyncapi.md" ]; then
echo "Files exist"
else
echo "Files do not exist:- ./custom-output/asyncapi.md"
echo "Action failed"
exit 1
fi
test-file-not-found:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
id: test
uses: ./
with:
filepath: non_existent_file.yml
continue-on-error: true
- name: Check for failure
run: |
if [ "${{ steps.test.outcome }}" == "success" ]; then
echo "Test Failure: non_existent_file.yml should throw an error but did not"
exit 1
else
echo "Test Success: non_existent_file.yml threw an error as expected"
fi
test-invalid-input:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
id: test
uses: ./
with:
filepath: test/asyncapi.yml
command: generate # No template or language specified
template: '' # Empty string
continue-on-error: true
- name: Check for failure
run: |
if [ "${{ steps.test.outcome }}" == "success" ]; then
echo "Test Failure: generate command should throw an error as no template or language specified but did not"
exit 1
else
echo "Test Success: generate command threw an error as expected"
fi
test-optimize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: test/unoptimized.yml
command: optimize
parameters: '-o new-file --no-tty'
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./test/unoptimized_optimized.yml" ]; then
echo "The specified file has been optimized"
else
echo "The specified file has not been optimized"
echo "Action failed"
exit 1
fi
test-bundle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Make output directory
run: mkdir -p ./output/bundle
- name: Test GitHub Action
uses: ./
with:
custom_command: 'bundle ./test/bundle/asyncapi.yaml ./test/bundle/features.yaml --base ./test/bundle/asyncapi.yaml --reference-into-components -o ./output/bundle/asyncapi.yaml'
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./output/bundle/asyncapi.yaml" ]; then
echo "The specified files have been bundled"
else
echo "The specified files have not been bundled"
echo "Action failed"
exit 1
fi
test-convert:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
command: convert
filepath: test/asyncapi.yml
output: output/convert/asyncapi.yaml
- name: Assert GitHub Action
run: |
echo "Listing all files"
ls -R
echo "Asserting GitHub Action"
if [ -f "./output/convert/asyncapi.yaml" ]; then
echo "The specified file has been converted"
else
echo "The specified file has not been converted"
echo "Action failed"
exit 1
fi