asyncapi / github-action-for-cli

GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
Apache License 2.0
50 stars 19 forks source link

github-action-for-generator: Error: Found non-callable @@iterator #368

Closed serkmen closed 10 months ago

serkmen commented 11 months ago

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

image

How to Reproduce

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/asyncapi-github-action@v0.0.10
      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/html-template@2.0.0'  #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/github-pages-deploy-action@4.0.0
      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
github-actions[bot] commented 11 months ago

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup 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.

serkmen commented 11 months ago

Please also note that error disappears when switching back to html-template@1.0.0 version. This time blank html case occurs in the generated index.html:

`<!DOCTYPE html>

Streetlights API 1.0.0 documentation
` Probably same issue here: [https://github.com/asyncapi/html-template/issues/456]
derberg commented 10 months ago

Hey there, we just released completely new version of this action, it now uses AsyncAPI CLI under the hood

please try to use docker://asyncapi/github-action-for-cli:3.0.1 and let us know if issue is still there

pioneer2k commented 10 months ago

@derberg

I just tried to use the docker://asyncapi/github-action-for-cli:3.0.1 I get the following error: /entrypoint.sh: line 19: $1: unbound variable

I also tried to provide "cli_version: latest" but that makes no difference.

derberg commented 10 months ago

@Shurtu-gal please have a look

Shurtu-gal commented 10 months ago

@serkmen Couple of things to note :-

Shurtu-gal commented 10 months ago

@derberg Should I update the README to do the same instead of docker://?

The problem with our docker image is that our GitHub is not passing any parameters to the docker image as can be seen here.

Earlier it using octokit it could pull params from context of workflow.

derberg commented 10 months ago

@Shurtu-gal best would be to enable our docker image to work as before, otherwise our action will not be very handy as it will always be delayed by the fact that image will have to be build as part of workflow run. Advantage of docker is that image is already there, so workflow run is much faster

Shurtu-gal commented 10 months ago

Yeah, I was looking into how others were solving it, got an idea what to do from here

pioneer2k commented 10 months ago

@Shurtu-gal @derberg

I switched everything to your new GitHub Action asyncapi/github-action-for-cli@v3.1.1 but the original error of this issue is still the same.

My action:

       - name: Generating HTML from CheckoutOrders AsyncAPI document
         uses: asyncapi/github-action-for-cli@v3.1.1
         with:
           template: '@asyncapi/html-template@2.0.0'
           filepath: src/main/resources/asyncapi_checkoutOrders.yml
           parameters: --force-write -p baseHref=/checkout-orders-asyncapi-generated-html/ sidebarOrganization=byTags
           output: asyncapi/checkout-orders-asyncapi-generated-html

The output:

AsyncAPI CLI version: @asyncapi/cli/1.3.0 linux-x64 node-v18.19.0 Executing AsyncAPI CLI... Debug information Generating from AsyncAPI file... Debug information Executing command: asyncapi generate fromTemplate /github/workspace/src/main/resources/asyncapi_checkoutOrders.yml @asyncapi/html-template@2.0.0 -o /github/workspace/asyncapi/checkout-orders-asyncapi-generated-html --force-write -p baseHref=/checkout-orders-asyncapi-generated-html/ sidebarOrganization=byTags Generation in progress. Keep calm and wait a bit... done

[BABEL] Note: The code generator has deoptimised the styling of /usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template/template/js/asyncapi-ui.min.js as it exceeds the max of 500KB. Generator Error: Found non-callable @@iterator

Shurtu-gal commented 10 months ago

I will look into this. Can you send the AsyncAPI spec as well as workflow run? @pioneer2k

pioneer2k commented 10 months ago

@Shurtu-gal I am not able to send that, as the workflow run is on a GitHub repository of a private organization and the AsyncAPI spec contains confidential information. Maybe I can provide some other information that can help?

Shurtu-gal commented 10 months ago

@pioneer2k Was able to reproduce, and from what I could see its a problem with html-template.

  1. It's working with version 0.9.0 as can be seen here
  2. But not with 2.0.0 here
pioneer2k commented 10 months ago

@Shurtu-gal yes, I know. That was the reason why this issue originally was opened by @serkmen Migration from html-template 0.28.4 (in my case) to 1.0.0 and 2.0.0 is not working.

Shurtu-gal commented 10 months ago

image

As can be seen, the 2.0.0 version works with sidebarOrganization as byTagsNoRoot or undefined. Maybe you don't have tags at the root level.

PS:- For further info https://github.com/asyncapi/html-template/#supported-parameters

pioneer2k commented 10 months ago

Yes, you are right. Without the parameter 'sidebarOrganization' it works for me.

jonaslagoni commented 10 months ago

This should be solved by a fix to the underlying react components: https://github.com/asyncapi/asyncapi-react/pull/885