Skip to content

Commit

Permalink
fix: Local check (#3)
Browse files Browse the repository at this point in the history
* chore: update package-lock.json

* fix: add package-lock.json (asyncapi#1542)

* chore: migrate github-action to cli (asyncapi#1487)

* New Github action added for cli

* Added new files in the github-action

* removed monorepo style for github action

* Updated github action with Dockerfile changes

* added command to pack cli for linux, docker build command

* added test-workflow for github-action

* chore: fix docker context

* chore: change docker context

* fix: dockerfile

* changed dockerfile

* fix: dockerfile

* Converted Dockerfile into multi stages

* added github-action folder

* added assets folder to github action image

* deleted act file script

* removed asyncapi.yaml file from .gitignore

* corrected output file for workflow

* updated Dockerfile

* added bundle file

* changed bundle files

* Updated README

* updated output bundle directory

---------

Co-authored-by: asyncapi-bot <[email protected]>
Co-authored-by: Ashish Padhy <[email protected]>

* feat: update oclif to v4 (asyncapi#1546)

* feat: update oclif to v4

* chore: removed unused dependencies

* Update myhook.ts

* chore: update package-lock.json version (asyncapi#1550)

* fix: add description for the start command in AsyncAPI CLI (asyncapi#1534) (asyncapi#1537)


Co-authored-by: Ashish Padhy <[email protected]>

* chore(release): v2.7.1 (asyncapi#1551)

* fix: update npm to latest for windows (asyncapi#1553)

* chore(release): v2.7.2 (asyncapi#1554)

* Update upload-release-assets.yml

---------

Co-authored-by: root <root@LAPTOP-K7PL9FIU>
Co-authored-by: Ashish Padhy <[email protected]>
Co-authored-by: Akshat Nema <[email protected]>
Co-authored-by: asyncapi-bot <[email protected]>
Co-authored-by: Taufiq Hassan <[email protected]>
  • Loading branch information
6 people authored Oct 22, 2024
1 parent 786f840 commit 16a5dc6
Show file tree
Hide file tree
Showing 25 changed files with 17,137 additions and 16,430 deletions.
345 changes: 345 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
name: PR testing of CLI action

on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]

jobs:
should-workflow-run:
runs-on: ubuntu-latest
steps:
- if: >
!github.event.pull_request.draft && !(
(github.actor == 'asyncapi-bot' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'asyncapi-bot-eve' && (
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
startsWith(github.event.pull_request.title, 'chore(release):')
)) ||
(github.actor == 'allcontributors[bot]' &&
startsWith(github.event.pull_request.title, 'docs: add')
)
)
id: should_run
name: Should Run
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
outputs:
shouldrun: ${{ steps.should_run.outputs.shouldrun }}

build-docker:
needs: should-workflow-run
name: Build Docker image
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get docker version
id: docker_version
run: >
ls -la;
action=$(cat action.yml);
regex='docker:\/\/asyncapi\/github-action-for-cli:([0-9.]+)';
[[ $action =~ $regex ]];
action_version=${BASH_REMATCH[1]};
echo "action_version=$action_version" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image and export
uses: docker/build-push-action@v5
with:
context: .
file: ./github-action/Dockerfile
tags: asyncapi/github-action-for-cli:${{ steps.docker_version.outputs.action_version }}
outputs: type=docker,dest=/tmp/asyncapi.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: asyncapi
path: /tmp/asyncapi.tar


test-defaults:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: ./github-action/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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: ./github-action/test/asyncapi.yml
command: validate

test-custom-command:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- 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 ./github-action/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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: ./github-action/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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- 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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
id: test
uses: ./
with:
filepath: github-action/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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
filepath: github-action/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 "./github-action/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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Make output directory
run: mkdir -p ./output/bundle
- name: Test GitHub Action
uses: ./
with:
custom_command: 'bundle ./github-action/test/bundle/asyncapi.yaml ./github-action/test/bundle/features.yaml --base ./github-action/test/bundle/asyncapi.yaml -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:
if: ${{ needs.should-workflow-run.outputs.shouldrun == 'true' }}
runs-on: ubuntu-latest
needs: [should-workflow-run, build-docker]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: asyncapi
path: /tmp
- name: Load Docker image
run: |
docker load --input /tmp/asyncapi.tar
docker image ls -a
- uses: actions/checkout@v4
- name: Test GitHub Action
uses: ./
with:
command: convert
filepath: github-action/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
22 changes: 4 additions & 18 deletions .github/workflows/upload-release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ jobs:
#fix for windows build issue #1433
name: Install p7zip-full nsis
run: sudo apt-get install -y p7zip-full nsis
- if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest'
- if: matrix.npm_script == 'pack:windows'
#npm cli 10 is buggy because of some cache issue
name: Install npm cli 8
name: Install npm cli 10
shell: bash
run: npm install -g npm@8.19.4
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
- name: Build project
Expand All @@ -75,18 +75,4 @@ jobs:
- name: Assets generation
shell: bash
run: npm run ${{ matrix.npm_script }}
- name: Update release
uses: softprops/action-gh-release@v1
with:
files: dist/${{ matrix.dist_folder }}/asyncapi.${{ matrix.extension }}
tag_name: v${{ steps.extractver.outputs.version }}
token: ${{ secrets.GH_TOKEN }}
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
name: Report workflow run status to Slack
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
with:
status: ${{ job.status }}
fields: repo,action,workflow
text: 'AsyncAPI CLI release build artifacts failed'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ node_modules
/test/integration/generate/models/
test.asyncapi-cli
asyncapi.json
asyncapi.yml
test/fixtures/minimaltemplate/__transpiled
.vscode

/action/
/github-action/output/

oclif.manifest.json
spec-examples.zip

Expand Down
Loading

0 comments on commit 16a5dc6

Please sign in to comment.