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

feat!: refactor action to be CLI based #348

Merged
merged 36 commits into from
Jan 8, 2024

Conversation

Shurtu-gal
Copy link
Collaborator

@Shurtu-gal Shurtu-gal commented Nov 24, 2023

Description

The PR changes the GitHub action from being just a generator to an all-in-one tool.

What's New:

  • Introduced new commands: validate, convert, optimise.
  • Enabled model generation by language.

Changes Made

  • Removed all NodeJS files and dependencies from the GitHub Action.
  • Refactored the action to expose the Command-Line Interface (CLI) functionality through the Docker container using a bash script.
  • Introduced a Makefile to streamline and simplify the development process.
  • Implemented a bash script that dynamically executes commands based on user inputs, transforming the action into a comprehensive interface for CLI operations.

Breaking Changes:

Previously, the parameter option was exclusive to template parameters. It has now been expanded to apply to all commands. Therefore, users must now add -p before template params for the same functionality.

Things left

  • Update README
  • Add tests to test various edge cases
  • Write a test workflow for production tests
  • Release 3.0
  • Rename Repository.

Related issue(s)
Fixes #281

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@Shurtu-gal Shurtu-gal marked this pull request as ready for review November 26, 2023 15:08
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some questions about your decisions to do things in a specific way

config file

why did you decide to introduce a config file. You executed it perfectly, but is this really needed. In past I faced a similar design decision: should I do a config to allow multiple runs, or should I basically document how to have workflow with multiple steps that use the same action, and I choose to drop idea with config. Config adds a lot of additional maintenance effort, but also makes things harder to use. Also I think that when you look at the ecosystem of GitHub Actions, the general principle is to have a single run responsibility. Example: I have a workflow where I need to checkout 2 different repositories, and to do it, I have 2 separate steps, one to checkout repo A and one to checkout repo B - 2 separate steps, not one step with 2 checkouts. It makes future debugging much much easier, as you can clearly see what step failed.

so what I think is better workflow for any platform/devops team is when they can do:

    - name: Validating AsyncAPI document
      uses: docker://asyncapi/github-action-for-cli:3.0.0
      with:
        command: validate
        filepath: ./asyncapi.yml
    - name: Generate models
       uses: docker://asyncapi/github-action-for-cli:3.0.0
       with:
        command: generate
        language: typescript
        filepath: ./asyncapi.yml
    - name: Generating HTML
      uses: docker://asyncapi/github-action-for-cli:3.0.0
      with:
        command: generate
        filepath: ./asyncapi.yml
        template: @asyncapi/[email protected]
        output: generated-html

so you use the same action for 3 different outputs. You know what I mean? this is the best approach from someone running and debugging pipelines. And to configure anything, you only learn inputs and not inputs with config

also, in the past nobody ever requested to do a config approach.

and great stuff is that if we do above, then we will not do any breaking change except for action name change

below can still work. We can say that by default, if command is not provided, then we assume generate and rest will still work

    - name: Generating HTML from my AsyncAPI document
      uses: docker://asyncapi/github-action-for-generator:2.0.0 #always use latest tag as each is pushed to docker
      with:
        template: '@asyncapi/[email protected]'  #In case of template from npm, because of @ it must be in quotes
        filepath: docs/api/my-asyncapi.yml
        parameters: baseHref=/test-experiment/ sidebarOrganization=byTags #space separated list of key/values
        output: generated-html

and yeah, do not introduce input if it is not really needed, like type for example, if you can use other inputs, like template or language to identify if model or fromTemplate should be run - then do it. Simply validate and throw error when people use template and language at the same time. Also in docs simply clarify what these mean.

CLI version

I think we need to stick to approach that docker contains only one CLI version. With CI/CD pipelines it is all about speed, we cannot make pipeline run longer because CLI installation needs to take place first. So we for sure need to have latest there by default. If you really think cli_version is useful, like for testing pipelines with new cli without bumping version in action - then we need a script that basically removes latest and installs requested CLI version - but it also has to be documented, so people understand how that works


don't feel disappointed with my feedback - it is only design related, but the execution mate - docs and quality are 💯 ❤️

Makefile Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@Shurtu-gal
Copy link
Collaborator Author

I will take out the config approach and keep it simple. Same with cli_version too.

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left few comments, well done 👏🏼

action.yml Outdated Show resolved Hide resolved
action.yml Show resolved Hide resolved
action.yml Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
* remove the verbose input
@Shurtu-gal Shurtu-gal requested a review from derberg December 12, 2023 16:48
@Shurtu-gal
Copy link
Collaborator Author

@derberg README is also updated

package.json Outdated Show resolved Hide resolved
CODEOWNER Show resolved Hide resolved
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments

can you at least add commands: bundle, diff, and convert that have use case to be used in CI?

.github/workflows/test-action.yml Outdated Show resolved Hide resolved
.github/workflows/test-action.yml Outdated Show resolved Hide resolved
.github/workflows/test-action.yml Show resolved Hide resolved
.github/workflows/test-action.yml Show resolved Hide resolved
.github/workflows/test-action.yml Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
.github/workflows/test-action.yml Show resolved Hide resolved
.github/workflows/test-action.yml Outdated Show resolved Hide resolved
@Shurtu-gal
Copy link
Collaborator Author

@derberg The requested changes have been added.
Regarding sonarcloud hotspot, I had made the changes to fix it but it led to permission issues when making docker container for GitHub action as can be seen in the run here

@Shurtu-gal Shurtu-gal requested a review from derberg January 4, 2024 20:40
@derberg
Copy link
Member

derberg commented Jan 8, 2024

@Shurtu-gal please bring back the user settings in dockerfile and simply silent sonar by adding https://github.com/asyncapi/cli/blob/master/.sonarcloud.properties file to this repo, just adjust it to ignore dockerfile, and add comment why we ignore it: that this docker file is for starting containers that should run only in GitHub Actions and no other environments, and running with security violation is ok

@Shurtu-gal
Copy link
Collaborator Author

Done @derberg.

Copy link

sonarqubecloud bot commented Jan 8, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@derberg derberg changed the title feat: refactor action to be CLI based feat!: refactor action to be CLI based Jan 8, 2024
@derberg
Copy link
Member

derberg commented Jan 8, 2024

works well on my side

because we know there is one potential breaking change in case of parameters field, and that -p needs to be used, I added ! to the title so we release this new version as new major

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done 👏🏼

@derberg
Copy link
Member

derberg commented Jan 8, 2024

/rtm

@asyncapi-bot asyncapi-bot merged commit 2c68a25 into asyncapi:master Jan 8, 2024
26 checks passed
@derberg
Copy link
Member

derberg commented Jan 9, 2024

@allcontributors please add @Shurtu-gal for code,test,doc,ideas,maintainance

Copy link
Contributor

@derberg

I've put up a pull request to add @Shurtu-gal! 🎉

github-actions bot pushed a commit to ash17290/github-action-for-cli that referenced this pull request Jan 9, 2024
## 1.0.0 (2024-01-09)

### ⚠ BREAKING CHANGES

* refactor action to be CLI based (asyncapi#348)
* switch to dockerized github action (asyncapi#182)
* use latest generator rc release in the action (#8)

### Features

* add automation of version in action.yml ([31cd450](31cd450))
* init version of the github action ([#2](#2)) ([971bc14](971bc14))
* move automation from workflow to releaserc ([174627f](174627f))
* refactor action to be CLI based ([asyncapi#348](https://github.com/ash17290/github-action-for-cli/issues/348)) ([2c68a25](2c68a25))
* start supporting spec 2.4 by using latest generator version 1.9.5 ([asyncapi#233](https://github.com/ash17290/github-action-for-cli/issues/233)) ([25a6baf](25a6baf))
* switch to dockerized github action ([asyncapi#182](https://github.com/ash17290/github-action-for-cli/issues/182)) ([ba5b4c5](ba5b4c5))
* Update package.json ([1e48b93](1e48b93))
* update versions in action.yml ([c7c1c3e](c7c1c3e))
* use latest generator ([#6](#6)) ([401da6f](401da6f))
* use latest generator rc release in the action ([#8](#8)) ([c648dd3](c648dd3))

### Bug Fixes

* add missing read-package-json-fast ([asyncapi#148](https://github.com/ash17290/github-action-for-cli/issues/148)) ([fdd3702](fdd3702))
* change references to proper organization in package.json ([#4](#4)) ([5a98a74](5a98a74))
* dist should be refreshed after initial installation ([asyncapi#115](https://github.com/ash17290/github-action-for-cli/issues/115)) ([6a7763e](6a7763e))
* move from node 16 to 14 because of failing docker build ([asyncapi#237](https://github.com/ash17290/github-action-for-cli/issues/237)) ([ecf43b0](ecf43b0))
* npmcli run-script separated from bundle as external dep ([asyncapi#117](https://github.com/ash17290/github-action-for-cli/issues/117)) ([95f16ed](95f16ed))
* refresh dist on each release ([asyncapi#105](https://github.com/ash17290/github-action-for-cli/issues/105)) ([19e0d4e](19e0d4e))
* remove ncc packaging ([asyncapi#300](https://github.com/ash17290/github-action-for-cli/issues/300)) ([a80a16e](a80a16e))
* remove semantic-release to fix release 1.0.47 ([asyncapi#158](https://github.com/ash17290/github-action-for-cli/issues/158)) ([da8d19f](da8d19f))
* rename package name to `github-action-for-cli` ([asyncapi#371](https://github.com/ash17290/github-action-for-cli/issues/371)) ([d6da896](d6da896))
* semantic release installed on release ([asyncapi#153](https://github.com/ash17290/github-action-for-cli/issues/153)) ([75e31e5](75e31e5))
* semantic release script ([asyncapi#151](https://github.com/ash17290/github-action-for-cli/issues/151)) ([c0aea69](c0aea69))
* update @asyncapi/generator to 1.1.0 version ([asyncapi#21](https://github.com/ash17290/github-action-for-cli/issues/21)) ([ede258f](ede258f))
* update @asyncapi/generator to 1.1.1 version ([asyncapi#24](https://github.com/ash17290/github-action-for-cli/issues/24)) ([66a60b5](66a60b5))
* update @asyncapi/generator to 1.1.10 version ([asyncapi#47](https://github.com/ash17290/github-action-for-cli/issues/47)) ([92d68b0](92d68b0))
* update @asyncapi/generator to 1.1.11 version ([asyncapi#49](https://github.com/ash17290/github-action-for-cli/issues/49)) ([1b09888](1b09888))
* update @asyncapi/generator to 1.1.2 version ([asyncapi#26](https://github.com/ash17290/github-action-for-cli/issues/26)) ([5630a19](5630a19))
* update @asyncapi/generator to 1.1.3 version ([asyncapi#28](https://github.com/ash17290/github-action-for-cli/issues/28)) ([703e23d](703e23d))
* update @asyncapi/generator to 1.1.4 version ([asyncapi#30](https://github.com/ash17290/github-action-for-cli/issues/30)) ([27b8fe6](27b8fe6))
* update @asyncapi/generator to 1.1.5 version ([asyncapi#32](https://github.com/ash17290/github-action-for-cli/issues/32)) ([12b1a57](12b1a57))
* update @asyncapi/generator to 1.1.8 version ([asyncapi#41](https://github.com/ash17290/github-action-for-cli/issues/41)) ([48c7982](48c7982))
* update @asyncapi/generator to 1.1.9 version ([asyncapi#44](https://github.com/ash17290/github-action-for-cli/issues/44)) ([d697955](d697955))
* update @asyncapi/generator to 1.14.1 version ([asyncapi#337](https://github.com/ash17290/github-action-for-cli/issues/337)) ([57cc944](57cc944))
* update @asyncapi/generator to 1.14.2 version ([asyncapi#342](https://github.com/ash17290/github-action-for-cli/issues/342)) ([62d4540](62d4540))
* update @asyncapi/generator to 1.14.3 version ([asyncapi#344](https://github.com/ash17290/github-action-for-cli/issues/344)) ([2f546de](2f546de))
* update @asyncapi/generator to 1.15.0 version ([asyncapi#346](https://github.com/ash17290/github-action-for-cli/issues/346)) ([dc221a4](dc221a4))
* update @asyncapi/generator to 1.15.1 version ([asyncapi#349](https://github.com/ash17290/github-action-for-cli/issues/349)) ([545b4be](545b4be))
* update @asyncapi/generator to 1.15.2 version ([asyncapi#351](https://github.com/ash17290/github-action-for-cli/issues/351)) ([5034161](5034161))
* update @asyncapi/generator to 1.15.3 version ([asyncapi#353](https://github.com/ash17290/github-action-for-cli/issues/353)) ([147b8dd](147b8dd))
* update @asyncapi/generator to 1.15.4 version ([asyncapi#355](https://github.com/ash17290/github-action-for-cli/issues/355)) ([4e11099](4e11099))
* update @asyncapi/generator to 1.15.5 version ([asyncapi#357](https://github.com/ash17290/github-action-for-cli/issues/357)) ([f8be4d5](f8be4d5))
* update @asyncapi/generator to 1.15.6 version ([asyncapi#359](https://github.com/ash17290/github-action-for-cli/issues/359)) ([e4567f1](e4567f1))
* update @asyncapi/generator to 1.15.7 version ([asyncapi#361](https://github.com/ash17290/github-action-for-cli/issues/361)) ([97847dc](97847dc))
* update @asyncapi/generator to 1.15.8 version ([asyncapi#364](https://github.com/ash17290/github-action-for-cli/issues/364)) ([8a7ce2a](8a7ce2a))
* update @asyncapi/generator to 1.15.9 version ([asyncapi#366](https://github.com/ash17290/github-action-for-cli/issues/366)) ([a0cd7b3](a0cd7b3))
* update @asyncapi/generator to 1.16.0 version ([asyncapi#369](https://github.com/ash17290/github-action-for-cli/issues/369)) ([ffabb9b](ffabb9b))
* update @asyncapi/generator to 1.2.0 version ([asyncapi#51](https://github.com/ash17290/github-action-for-cli/issues/51)) ([c49fd8f](c49fd8f))
* update @asyncapi/generator to 1.3.0 version ([asyncapi#53](https://github.com/ash17290/github-action-for-cli/issues/53)) ([38a09a8](38a09a8))
* update @asyncapi/generator to 1.4.0 version ([asyncapi#55](https://github.com/ash17290/github-action-for-cli/issues/55)) ([305a3ff](305a3ff))
* update @asyncapi/generator to 1.5.0 version ([asyncapi#57](https://github.com/ash17290/github-action-for-cli/issues/57)) ([7d5af75](7d5af75))
* update @asyncapi/generator to 1.6.0 version ([asyncapi#59](https://github.com/ash17290/github-action-for-cli/issues/59)) ([f7d6620](f7d6620))
* update @asyncapi/generator to 1.6.1 version ([asyncapi#61](https://github.com/ash17290/github-action-for-cli/issues/61)) ([29069b1](29069b1))
* update @asyncapi/generator to 1.6.10 version ([255ae5d](255ae5d))
* update @asyncapi/generator to 1.6.13 version ([52a931b](52a931b))
* update @asyncapi/generator to 1.6.14 version ([b5aca7d](b5aca7d))
* update @asyncapi/generator to 1.6.15 version ([8f921a4](8f921a4))
* update @asyncapi/generator to 1.6.2 version ([asyncapi#63](https://github.com/ash17290/github-action-for-cli/issues/63)) ([319d164](319d164))
* update @asyncapi/generator to 1.6.3 version ([asyncapi#65](https://github.com/ash17290/github-action-for-cli/issues/65)) ([dcf0a61](dcf0a61))
* update @asyncapi/generator to 1.6.4 version ([asyncapi#68](https://github.com/ash17290/github-action-for-cli/issues/68)) ([1cd74a1](1cd74a1))
* update @asyncapi/generator to 1.6.5 version ([asyncapi#72](https://github.com/ash17290/github-action-for-cli/issues/72)) ([1b2683a](1b2683a))
* update @asyncapi/generator to 1.6.7 version ([cfbeed9](cfbeed9))
* update @asyncapi/generator to 1.6.8 version ([e56d4a6](e56d4a6))
* update @asyncapi/generator to 1.7.0 version ([365f3c1](365f3c1))
* update @asyncapi/generator to 1.7.1 version ([c1de4b7](c1de4b7))
* update @asyncapi/generator to 1.7.2 version ([08e01e7](08e01e7))
* update @asyncapi/generator to 1.7.3 version ([5f5fd28](5f5fd28))
* update @asyncapi/generator to 1.7.4 version ([52d2f0e](52d2f0e))
* update @asyncapi/generator to 1.8.0 version ([7e3a6f1](7e3a6f1))
* update @asyncapi/generator to 1.8.10 version ([96b4cff](96b4cff))
* update @asyncapi/generator to 1.8.11 version ([98075ce](98075ce))
* update @asyncapi/generator to 1.8.12 version ([316ff43](316ff43))
* update @asyncapi/generator to 1.8.13 version ([f71571f](f71571f))
* update @asyncapi/generator to 1.8.14 version ([09ea025](09ea025))
* update @asyncapi/generator to 1.8.15 version ([8051b3f](8051b3f))
* update @asyncapi/generator to 1.8.17 version ([c1e8fb4](c1e8fb4))
* update @asyncapi/generator to 1.8.18 version ([713e68b](713e68b))
* update @asyncapi/generator to 1.8.19 version ([614c311](614c311))
* update @asyncapi/generator to 1.8.20 version ([f88ad46](f88ad46))
* update @asyncapi/generator to 1.8.21 version ([42f25a3](42f25a3))
* update @asyncapi/generator to 1.8.22 version ([4ce0e87](4ce0e87))
* update @asyncapi/generator to 1.8.24 version ([0b30386](0b30386))
* update @asyncapi/generator to 1.8.25 version ([4e48184](4e48184))
* update @asyncapi/generator to 1.8.4 version ([6068e03](6068e03))
* update @asyncapi/generator to 1.8.5 version ([e2ff97f](e2ff97f))
* update @asyncapi/generator to 1.8.6 version ([0634e69](0634e69))
* update @asyncapi/generator to 1.8.7 version ([2e9bbf6](2e9bbf6))
* update @asyncapi/generator to 1.8.8 version ([b0864ca](b0864ca))
* update @asyncapi/generator to 1.8.9 version ([d589f2e](d589f2e))
* update @asyncapi/generator to 1.9.10 version ([asyncapi#247](https://github.com/ash17290/github-action-for-cli/issues/247)) ([37c1c98](37c1c98))
* update @asyncapi/generator to 1.9.11 version ([asyncapi#253](https://github.com/ash17290/github-action-for-cli/issues/253)) ([51c7668](51c7668))
* update @asyncapi/generator to 1.9.12 version ([asyncapi#258](https://github.com/ash17290/github-action-for-cli/issues/258)) ([19dc010](19dc010))
* update @asyncapi/generator to 1.9.14 version ([asyncapi#272](https://github.com/ash17290/github-action-for-cli/issues/272)) ([f915654](f915654))
* update @asyncapi/generator to 1.9.15 version ([asyncapi#284](https://github.com/ash17290/github-action-for-cli/issues/284)) ([f8c985f](f8c985f))
* update @asyncapi/generator to 1.9.16 version ([asyncapi#290](https://github.com/ash17290/github-action-for-cli/issues/290)) ([95362c0](95362c0))
* update @asyncapi/generator to 1.9.17 version ([asyncapi#292](https://github.com/ash17290/github-action-for-cli/issues/292)) ([9d3a07c](9d3a07c))
* update @asyncapi/generator to 1.9.2 version ([asyncapi#220](https://github.com/ash17290/github-action-for-cli/issues/220)) ([13ed363](13ed363))
* update @asyncapi/generator to 1.9.6 version ([asyncapi#241](https://github.com/ash17290/github-action-for-cli/issues/241)) ([84bcc8a](84bcc8a))
* update @asyncapi/generator to 1.9.7 version ([asyncapi#243](https://github.com/ash17290/github-action-for-cli/issues/243)) ([8b57215](8b57215))
* update @asyncapi/generator to 1.9.9 version ([asyncapi#245](https://github.com/ash17290/github-action-for-cli/issues/245)) ([85c3f72](85c3f72))
* update versions in action.yml ([2a0784a](2a0784a))
* use proper scripts for any platform ([asyncapi#152](https://github.com/ash17290/github-action-for-cli/issues/152)) ([670a8a1](670a8a1))
* windows breaking release ([asyncapi#150](https://github.com/ash17290/github-action-for-cli/issues/150)) ([7abf893](7abf893))
@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty program related label label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty AsyncAPI Bounty program related label
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

Refactor and rename this GH Action to be fully AsyncAPI CLI based
5 participants