asyncapi / github-action-for-cli Goto Github PK
View Code? Open in Web Editor NEWGitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
License: Apache License 2.0
GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
License: Apache License 2.0
Context
We want to make sure we have healthy community and people respec each other in GitHub. We want to monitor all comments in every repository and analyze sentiments to identify negative ones and get proper notification. Idea is to use GitHub Actions for it, to check sentiments with Google Natural Language API and post negative comments to Slack for review.
We manage community files in global .github
repo, and we have GitHub Funding config file there too. As a result we need to cleanup all the repos to remove .github/FUNDING.yml
Start supporting new GitHub pull request event that allows gives access to GITHUB_TOKEN
with write access. Fix welcome contributors workflow is needed.
We want to automatically merge Pull Requests that are submitted by Dependanbot. New workflow needs to be added, or if already existins it needs to be modified
Description
sentiment-analysis.yml
to .github/workflows
(create it if it doesn't exist yet) directory: https://gist.github.com/derberg/ab362e4b37f542e7e1813e67b7cb11ee.github/FUNDING.yml
if it existspull_request
from line 4 to pull_request_target
in .github/workflows/welcome-first-time-contrib.yml
fileautomerge.yml
with the following content: https://gist.github.com/derberg/024814a26959d54f683e7bd68d68f007automerge-release-pr-bump.yml
than rename it and adjust if
statements to check github.actor == 'asyncapi-bot' || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
instead of github.actor == 'asyncapi-bot'
๏ปฟBug Description:
Following error occurs when generating HTML from my AsyncAPI document with the latest versions of github-action-for-generator and html-template in my GitHub Actions
[BABEL] Note: The code generator has deoptimised the styling of /node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB.
Error: Found non-callable @@iterator
Please see source files and steps to produce as GitHub Action definition file.
Complete GitHub Action:
name: AsyncAPI documents processing
on: push
permissions:
contents: write
jobs:
generate:
runs-on: ubuntu-latest
steps:
#"standard step" where repo needs to be checked-out first
- name: Checkout repo
uses: actions/checkout@v2
#Using another action for AsyncAPI for validation
- name: Validating AsyncAPI document
uses: WaleedAshraf/[email protected]
with:
filepath: docs/api/my-asyncapi.yml
#In case you do not want to use defaults, you for example want to use different template
- name: Generating HTML from my AsyncAPI document
uses: docker://asyncapi/github-action-for-generator:latest #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
#Using another action that takes generated HTML and pushes it to GH Pages
- name: Deploy GH page
uses: JamesIves/[email protected]
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: feature/asyncapi-integration
FOLDER: generated-html
API Description Used:
asyncapi: 2.0.0
info:
title: Account Service
version: '1.0.0'
description: |
Manages user accounts in the system.
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0
servers:
production:
url: mqtt://test.mosquitto.org
protocol: mqtt
description: Test MQTT broker
channels:
user/signedup:
subscribe:
operationId: emitUserSignUpEvent
message:
$ref : '#/components/messages/UserSignedUp'
components:
messages:
UserSignedUp:
name: userSignedUp
title: User signed up event
summary: Inform about a new user registration in the system
contentType: application/json
payload:
$ref: '#/components/schemas/userSignedUpPayload'
schemas:
userSignedUpPayload:
type: object
properties:
firstName:
type: string
description: "foo"
lastName:
type: string
description: "bar"
email:
type: string
format: email
description: "baz"
createdAt:
type: string
format: date-time
When using the html-template 0.22.x (maybe earlier) I get the following error in GitHub Actions:
Error: This template is not compatible with the current version of the generator (1.0.1). This template is compatible with the following version range: >=1.7.3 <2.0.0.
With html-template 0.20.1 everything is working.
use the github-action with html-template 0.22.3 like this
- name: Generating HTML from AsyncAPI document
uses: asyncapi/[email protected]
with:
template: '@asyncapi/[email protected]'
filepath: src/main/resources/asyncapi.yml
parameters: baseHref=/customer-context-asyncapi-generated-html/
output: asyncapi/customer-context-asyncapi-generated-html
no error
Java --javaIncludeComments --javaJackson leads to Compilationfailure
Generating the models normally
jobs:
package-and-upload:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout repo
- name: Checkout repo
uses: actions/checkout@v2
# Generating models from my AsyncAPI document
- name: Generating models from my AsyncAPI document
uses: asyncapi/[email protected]
with:
command: generate
filepath: docs/asyncapi.yaml
language: java
parameters: --packageName=com.example --javaIncludeComments --javaJackson
output: generated-models
None
No, someone else can work on it
apparently 2.5.0 either.
The step to generate the HTML from the AsyncAPI document does not work with version 2.4.0
Github action step:
#In case you do not want to use defaults, you for example want to use different template
- name: Generating HTML from my AsyncAPI document
uses: docker://asyncapi/github-action-for-generator:2.0.3
with:
template: '@asyncapi/[email protected]' #In case of template from npm, because of @ it must be in quotes
filepath: CORE.yaml
output: generated-html
AsyncAPI yaml file:
asyncapi: '2.4.0'
info:
title: My service
version: 0.0.1
description: Service description
This issue defines a list of tasks that need to be performed in this repo to make sure it's ci/cd automation works long term without any issues.
It is up to maintainers to decide if it must be addressed in one or multiple PRs.
Below are 3 different sections describing 3 different important ci/cd changes.
IMPORTANT-START
For GitHub workflows that contain This workflow is centrally managed in https://github.com/asyncapi/.github/
you do not have to perform any work. These workflows were already updated through the update in .github
. The only exception is the workflows related to nodejs release. More details in Upgrade Release pipeline - in case of nodejs projects section
IMPORTANT-END
Every single GitHub Action workflow that has echo "::set-output name={name}::{value}"
need to be updated to follow echo "{name}={value}" >> $GITHUB_OUTPUT
We do not yet know when set-output
will stop working. Previous disable date was 31.05 but now then say community needs more time.
For more details read official article from GitHub
2nd bullet point is still relevant for you even if your projects in not nodejs project
v3
version of this action, and make sure minimum node 14 is usednode12
is that node-based GitHub Actions were using it in majority as a runtime environment. Look for example at this action.yaml file for setup-node action v2. So the job that you have to do is go through all the workflows, and verify every single action that you use, make sure you are using the latest version that is not based on node12
. I already did review a lot of actions as part of this PR so maybe you will find some actions there and can copy from me. For example action/checkout
needs to be updated to v3.Node12 end of support in action is probably September 27th.
For more details read official article from GitHub
ignore this section if your project is not nodejs project
You have 2 options. You can:
A. choose to switch to new release pipeline using instruction from asyncapi/.github#205
B. stay with old release pipeline, and manually update GitHub workflows and actions used in it, you can inspire a lot from this PR asyncapi/.github#226
I definitely recommend going with A
Workflows related to release:
A clear and concise description of what the bug is:
ts-node
throws error when following github-action-for-generator
documentation and copy-pasted the workflow file for a hello world example.
Run docker://asyncapi/github-action-for-generator:2.1.9
with:
template: @asyncapi/[email protected]
filepath: docs/api/my-asyncapi.yml
parameters: baseHref=/test-experiment/ sidebarOrganization=byTags
output: generated-html
/usr/bin/docker run --name asyncapigithubactionforgenerator219_717785 --label ea425b --workdir /github/workspace --rm -e "INPUT_TEMPLATE" -e "INPUT_FILEPATH" -e "INPUT_PARAMETERS" -e "INPUT_OUTPUT" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/asyncapi-test/asyncapi-test":"/github/workspace" asyncapi/github-action-for-generator:2.1.9
/dist/index.js:268478
throw new Error('Custom transpiler can only be used when transpileOnly is enabled.');
^
Error: Custom transpiler can only be used when transpileOnly is enabled.
at initializeTranspilerFactory (/dist/index.js:268478:23)
at createFromPreloadedConfig (/dist/index.js:268473:28)
at create (/dist/index.js:268385:12)
at register (/dist/index.js:268365:19)
at utils.registerTypeScript (/dist/index.js:13043:3)
at Object.56814 (/webpack:/github-action-for-generator/node_modules/@asyncapi/generator/lib/generator.js:64:1)
at __nccwpck_require__ (/webpack:/github-action-for-generator/webpack/bootstrap:21:1)
at /webpack:/github-action-for-generator/lib/index.js:2:1
at /dist/index.js:297843:3
at Object.<anonymous> (/dist/index.js:297846:12)
Steps to reproduce the issue. Attach all resources that can help us understand the issue:
Here is a hello world repo that exhibits the error:
https://github.com/perdue/asyncapi-test
docs/api/my-asyncapi.yml:
asyncapi: 2.4.0
info:
title: Hello world application
version: '0.1.0'
channels:
hello:
publish:
message:
payload:
type: string
pattern: '^hello .+$'
.github/workflows/generate.yml:
name: AsyncAPI documents processing
on:
push:
branches: [ main ]
jobs:
generate:
runs-on: ubuntu-latest
steps:
#"standard step" where repo needs to be checked-out first
- name: Checkout repo
uses: actions/checkout@v2
#Using another action for AsyncAPI for validation
- name: Validating AsyncAPI document
uses: WaleedAshraf/[email protected]
with:
filepath: docs/api/my-asyncapi.yml
#In case you do not want to use defaults, you for example want to use different template
- name: Generating HTML from my AsyncAPI document
uses: docker://asyncapi/github-action-for-generator:2.1.9
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
#Using another action that takes generated HTML and pushes it to GH Pages
- name: Deploy GH page
uses: JamesIves/[email protected]
with:
ACCESS_TOKEN: ${{ secrets.DEPLOY_TO_GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: generated-html
A clear and concise description of what you expected to happen:
I expected the generator to produce the correct output considering I was following the README.
When I worked on this action some time ago, my main motivation was:
Now times are different ๐
I think it would be better:
Generator for AsyncAPI documents
to Generator, validator, converter and others - all in one for your AsyncAPI docs
github-action-for-generator
to github-action-for-asyncapi-cli
Or:
Or we just archive this repo and create action directly in AsyncAPI CLI - example how a friend does it (CLI and GH action for it in one repo) https://github.com/mszostok/codeowners-validator. I think it makes sense, especially that in ourcase GH Action would anyway always reflect the CLI version. Current action we would just archive, set as deprecated and link to the new one.
Thoughts?
Got Error: Version 2.2.0 is not supported.
when setting GH actions job.
Logs:
Run asyncapi/github-action-for-generator@v1
with:
template: @asyncapi/[email protected]
filepath: backend/docs/asyncapi.yml
parameters: baseHref=/test-experiment/ sidebarOrganization=byTags
output: generated-html
(node:2002) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Error: Version 2.2.0 is not supported.
GH actions configuration:
name: AsyncAPI documents processing
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Generating HTML from my AsyncAPI document
uses: asyncapi/github-action-for-generator@v1
with:
template: '@asyncapi/[email protected]' # latest
filepath: backend/docs/asyncapi.yml
parameters: baseHref=/test-experiment/ sidebarOrganization=byTags
output: generated-html
Currently, if you use the GH action on 2.3 documents it throws Error: Version 2.3.0 is not supported.
This is part of version 1.9.0 of the generator, which does not seem to have been updated here ๐ค
To fix this, the dependencies need to be updated, or rather inspected, why the dependency was not automatically updated.
Parser-JS requires now Node.js 14 and npm7 or higher.
This means package-lock.json
version should be always set to 2
.
In order to unify development requirements, I suggest all repositories to stick with that requirements. In order to do that, the following is needed:
package-lock.json
to version 2
. This is automatically done when running npm install
if the npm version used is 7 or higher.Related:
Generator fails to create asyncapi pdf
Using the following step:
- name: Generating HTML from my AsyncAPI document
uses: docker://asyncapi/github-action-for-generator:2.1.12
with:
template: '@asyncapi/[email protected]'
filepath: api/src/main/resources/docs/api/my_asyncapi.yml
parameters: pdf=true
output: wiki/diagrams
Github Actions Log:
PDF is generating...
Error: Failed to launch the browser process! spawn /node_modules/@asyncapi/generator/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/node_modules/@asyncapi/generator/node_modules/puppeteer/src/node/BrowserRunner.ts:304:[9](https://github.com/XXX/XYZ/actions/runs/6024020451/job/16341900878#step:7:10))
at ChildProcess.<anonymous> (/node_modules/@asyncapi/generator/node_modules/puppeteer/src/node/BrowserRunner.ts:296:16)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:[12](https://github.com/XXX/XYZ/actions/runs/6024020451/job/16341900878#step:7:13))
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
at onErrorNT (node:internal/child_process:485:[16](https://github.com/XXX/XYZ/actions/runs/6024020451/job/16341900878#step:7:17))
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Should create a beautiful pdf of my asyncapi.
Describe the bug
When using the asyncapi/[email protected] (and 1.0.36 as well) I get the following error in GitHub Actions:
Error: Cannot find module 'read-package-json-fast'
Require stack:
How to Reproduce
use the github-action with v1.0.37 like this
Had a use case where a dependency for a template needed >= v14 however this action runs with v12, making them incompatible.
Would be great if it offered a way to use different node versions for the generation.
Describe the bug
When using the asyncapi/[email protected] (maybe 1.0.32 as well) I get the following error in GitHub Actions:
Error: Cannot find module '@npmcli/run-script'
Require stack:
With v1.0.31 everything is working. But we need the new version for fixing the issue 103.
How to Reproduce
use the github-action with v1.0.33 like this
- name: Generating HTML from AsyncAPI document
uses: asyncapi/[email protected]
with:
template: '@asyncapi/[email protected]'
filepath: src/main/resources/asyncapi.yml
parameters: baseHref=/customer-context-asyncapi-generated-html/
output: asyncapi/customer-context-asyncapi-generated-html
Expected behavior
no error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.