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
48 stars 19 forks source link

Error: Custom transpiler can only be used when transpileOnly is enabled #286

Closed perdue closed 1 year ago

perdue commented 1 year ago

Describe the bug

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/html-template@0.28.1
    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)

How to Reproduce

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/asyncapi-github-action@v0.0.9
      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/html-template@0.28.1'  #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@3.4.2
      with:
        ACCESS_TOKEN: ${{ secrets.DEPLOY_TO_GITHUB_TOKEN }}
        BRANCH: gh-pages
        FOLDER: generated-html

Expected behavior

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.

github-actions[bot] commented 1 year 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.

ferdinandfrank commented 1 year ago

@perdue

I had the same issue and were able to solve it by using the @asyncapi/generator directly like this:

name: Publish Docs

on:
  push:
    branches:
      - develop

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v2

      - name: Generating HTML from AsyncAPI file
        run: |
          npx @asyncapi/generator docs.yml @asyncapi/html-template -o docs-html

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@3.4.2
        with:
          ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: docs-html
perdue commented 1 year ago

@ferdinandfrank

Thanks for the tip! I also started using the generator directly in a shell script.

It just bugs me (pun intended?) that the getting started documentation results in an error. I spent so much time trying to figure out what I had done wrong.

ferdinandfrank commented 1 year ago

@perdue

Great! I also didn't get it to work with the getting started documentation and didn't find the reason for it. It would be great if the maintainers could take a look at it.

derberg commented 1 year ago

Hey folks, sorry for not responding for so long. I just opened a PR that fixes the issue https://github.com/asyncapi/github-action-for-generator/pull/300

if you want to go npx @asyncapi/generator direction I strongly recommend to using it like npx @asyncapi/generator@1.9.17 or even @asyncapi/generator@e8002b414c176baf6ef21d98a7513acb91841943` to use specific version as we plan to remove Generator CLI as 98% of functionality is already in AsyncAPI CLI. So if you will not lock yourself to specific generator version, your pipelines will start failing at some point of time

best to use AsyncAPI CLI as we also plan to use it in https://github.com/asyncapi/github-action-for-generator/issues/281

derberg commented 1 year ago

just tested latest docker docker://asyncapi/github-action-for-generator:2.1.12 in my private repo and worked like a charm