-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
chore: migrate github-action to cli #1487
Merged
Merged
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b37bbbc
New Github action added for cli
akshatnema 1ddf001
Added new files in the github-action
akshatnema 1877382
Merge branch 'master' into gh-action-for-cli
asyncapi-bot 5fe96e3
removed monorepo style for github action
akshatnema 31ba171
Updated github action with Dockerfile changes
akshatnema 362652a
added command to pack cli for linux, docker build command
akshatnema e7829a8
Merge branch 'master' into gh-action-for-cli
asyncapi-bot 95cfe27
added test-workflow for github-action
akshatnema 215b477
chore: fix docker context
Shurtu-gal 778dcb2
chore: change docker context
Shurtu-gal 07f1647
fix: dockerfile
Shurtu-gal 7dfd122
changed dockerfile
akshatnema bc8f651
fix: dockerfile
Shurtu-gal 12ff5b9
Converted Dockerfile into multi stages
akshatnema e33cc64
added github-action folder
akshatnema b8e694c
added assets folder to github action image
akshatnema 116d025
deleted act file script
akshatnema 04a2ed5
removed asyncapi.yaml file from .gitignore
akshatnema 3d01213
corrected output file for workflow
akshatnema eee73a5
Merge branch 'master' into gh-action-for-cli
Shurtu-gal b33dc47
updated Dockerfile
akshatnema cc6425d
added bundle file
akshatnema 4de437a
changed bundle files
akshatnema 6934b22
Updated README
akshatnema 16388bb
updated output bundle directory
akshatnema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: 'Generator, Validator, Converter and others - all in one for your AsyncAPI docs' | ||
description: 'Use this action to generate docs or code from your AsyncAPI document. Use default templates or provide your custom ones.' | ||
inputs: | ||
cli_version: | ||
description: 'Version of AsyncAPI CLI to be used. This is only needed if you want to test with a specific version of AsyncAPI CLI. Default is latest which is also the recommended option.' | ||
required: false | ||
default: '' | ||
command: | ||
description: 'Command to run. Available commands in action :- generate, validate, convert, optimize and custom. Default is generate. For custom command, provide the whole command as input. List of available commands can be found in https://www.asyncapi.com/docs/tools/cli/usage.' | ||
required: false | ||
default: 'generate' | ||
filepath: | ||
description: 'Path to AsyncAPI document. This input is required if command is set to generate, validate, convert or optimize. Default is ./asyncapi.yaml' | ||
required: false | ||
default: 'asyncapi.yml' | ||
template: | ||
description: 'Template for the generator. Official templates are listed here https://github.com/search?q=topic%3Aasyncapi+topic%3Agenerator+topic%3Atemplate. You can pass template as npm package, url to git repository, link to tar file or local template.' | ||
default: '@asyncapi/[email protected]' | ||
required: false | ||
language: | ||
description: 'Language of the generated code. This input is required if you want to generate models. List of available languages can be found in https://www.asyncapi.com/docs/tools/cli/usage#asyncapi-generate-models-language-file' | ||
required: false | ||
default: '' | ||
output: | ||
description: 'Directory where to put the generated files. Can be used only with generate or convert commands. Default is output.' | ||
required: false | ||
default: 'output' | ||
parameters: | ||
description: 'The command that you use might support and even require specific parameters to be passed to the CLI for the generation. Template parameters should be preceded by -p' | ||
required: false | ||
default: '' | ||
custom_command: | ||
description: 'Custom command to be run. This input is required if command is set to custom.' | ||
required: false | ||
default: '' | ||
|
||
runs: | ||
using: 'docker' | ||
# This is the image that will be used to run the action. | ||
# IMPORTANT: The version has to be changed manually in your PRs. | ||
image: 'docker://asyncapi/github-action-for-cli:3.1.2' | ||
args: | ||
- ${{ inputs.cli_version }} | ||
- ${{ inputs.command }} | ||
- ${{ inputs.filepath }} | ||
- ${{ inputs.template }} | ||
- ${{ inputs.language }} | ||
- ${{ inputs.output }} | ||
- ${{ inputs.parameters }} | ||
- ${{ inputs.custom_command }} | ||
|
||
branding: | ||
icon: 'file-text' | ||
color: purple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
title: GitHub Action for Generator | ||
filters: | ||
technology: | ||
- AsyncAPI Generator | ||
categories: | ||
- github-actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM node:18-alpine | ||
|
||
# Create a non-root user | ||
RUN addgroup -S myuser && adduser -S myuser -G myuser | ||
|
||
# Install necessary packages | ||
RUN apk add --no-cache bash git chromium | ||
|
||
# Environment variables for Puppeteer | ||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | ||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser | ||
|
||
FROM ubuntu:latest | ||
|
||
# Copy the asyncapi directory | ||
COPY tmp/asyncapi/ /asyncapi | ||
|
||
# Create a script that runs the desired command | ||
RUN echo "#!/bin/bash\n/asyncapi/bin/run" > /usr/local/bin/asyncapi | ||
|
||
# Make the script executable | ||
RUN chmod +x /usr/local/bin/asyncapi | ||
|
||
RUN ls -l /usr/local/bin/asyncapi | ||
|
||
# Change ownership to non-root user | ||
RUN chown -R myuser:myuser /asyncapi /usr/local/bin/asyncapi || echo "Failed to change ownership" | ||
|
||
# Copy the entrypoint script | ||
COPY github-action/entrypoint.sh /entrypoint.sh | ||
|
||
# Make the entrypoint script executable | ||
RUN chmod +x /entrypoint.sh | ||
|
||
FROM node:18-alpine | ||
|
||
# Set the entrypoint | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
DEFAULT_VERSION = 'latest' | ||
DEFAULT_COMMAND = 'generate' | ||
TEST_FILEPATH = 'test/asyncapi.yml' | ||
DEFAULT_TEMPLATE = '@asyncapi/[email protected]' | ||
DEFAULT_LANGUAGE = '' | ||
DEFAULT_OUTPUT = 'output' | ||
DEFAULT_PARAMETERS = '' | ||
DEFAULT_CUSTOM_COMMANDS = '' | ||
CUSTOM_COMMANDS = 'validate test/asyncapi.yml' | ||
|
||
# Add env variables to the shell | ||
export GITHUB_WORKSPACE = $(shell pwd) | ||
|
||
run: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
test: test-default test-validate-success test-custom-output test-custom-commands test-optimize test-bundle test-convert test-action-bump | ||
|
||
# Test cases | ||
|
||
# Tests if the action has been bumped greater than the latest release | ||
test-action-bump: | ||
@bash bump-test.sh | ||
|
||
# Tests the default configuration without any inputs | ||
test-default: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests the validate command with a valid specification | ||
test-validate-success: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) 'validate' $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests the validate command with an invalid specification | ||
test-validate-fail: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) 'validate' './test/specification-invalid.yml' $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests if the generator can output to a custom directory | ||
test-custom-output: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) 'typescript' './output/custom-output' $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests if the action prefers custom commands over the default command | ||
test-custom-commands: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) $(DEFAULT_TEMPLATE) 'typescript' './output/custom-output' $(DEFAULT_PARAMETERS) $(CUSTOM_COMMANDS) | ||
|
||
# Tests if the action fails when the input is invalid (e.g. invalid template as is the case here) | ||
fail-test: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) $(DEFAULT_COMMAND) $(TEST_FILEPATH) '' $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) $(DEFAULT_PARAMETERS) $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests if the action optimizes the specification | ||
test-optimize: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) 'optimize' 'test/unoptimized.yml' $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) '-o new-file --no-tty' $(DEFAULT_CUSTOM_COMMANDS) | ||
|
||
# Tests if the action can bundle the specification with custom commands | ||
BUNDLE_COMMAND='bundle ./test/bundle/asyncapi.yaml ./test/bundle/features.yaml --base ./test/bundle/asyncapi.yaml -o ./output/bundle/asyncapi.yaml' | ||
test-bundle: | ||
mkdir -p ./output/bundle | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) 'bundle' 'test/bundle/asyncapi.yaml' $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) $(DEFAULT_OUTPUT) '-o output/bundle/asyncapi.yaml' $(BUNDLE_COMMAND) | ||
|
||
# Tests if the action can convert the specification with custom commands | ||
test-convert: | ||
@bash ./entrypoint.sh $(DEFAULT_VERSION) 'convert' 'test/asyncapi.yml' $(DEFAULT_TEMPLATE) $(DEFAULT_LANGUAGE) 'output/convert/asyncapi.yaml' '' $(DEFAULT_CUSTOM_COMMANDS) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / SonarCloud
Arguments in long RUN instructions should be sorted Low