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

chore: migrate github-action to cli #1487

Merged
merged 25 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b37bbbc
New Github action added for cli
akshatnema Jul 28, 2024
1ddf001
Added new files in the github-action
akshatnema Aug 17, 2024
1877382
Merge branch 'master' into gh-action-for-cli
asyncapi-bot Sep 14, 2024
5fe96e3
removed monorepo style for github action
akshatnema Sep 28, 2024
31ba171
Updated github action with Dockerfile changes
akshatnema Sep 29, 2024
362652a
added command to pack cli for linux, docker build command
akshatnema Sep 29, 2024
e7829a8
Merge branch 'master' into gh-action-for-cli
asyncapi-bot Oct 4, 2024
95cfe27
added test-workflow for github-action
akshatnema Oct 5, 2024
215b477
chore: fix docker context
Shurtu-gal Oct 5, 2024
778dcb2
chore: change docker context
Shurtu-gal Oct 5, 2024
07f1647
fix: dockerfile
Shurtu-gal Oct 5, 2024
7dfd122
changed dockerfile
akshatnema Oct 5, 2024
bc8f651
fix: dockerfile
Shurtu-gal Oct 5, 2024
12ff5b9
Converted Dockerfile into multi stages
akshatnema Oct 5, 2024
e33cc64
added github-action folder
akshatnema Oct 5, 2024
b8e694c
added assets folder to github action image
akshatnema Oct 5, 2024
116d025
deleted act file script
akshatnema Oct 5, 2024
04a2ed5
removed asyncapi.yaml file from .gitignore
akshatnema Oct 5, 2024
3d01213
corrected output file for workflow
akshatnema Oct 5, 2024
eee73a5
Merge branch 'master' into gh-action-for-cli
Shurtu-gal Oct 6, 2024
b33dc47
updated Dockerfile
akshatnema Oct 6, 2024
cc6425d
added bundle file
akshatnema Oct 6, 2024
4de437a
changed bundle files
akshatnema Oct 6, 2024
6934b22
Updated README
akshatnema Oct 6, 2024
16388bb
updated output bundle directory
akshatnema Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions github-action/.all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "derberg",
"name": "Lukasz Gornicki",
"avatar_url": "https://avatars.githubusercontent.com/u/6995927?v=4",
"profile": "https://www.brainfart.dev/",
"contributions": [
"code",
"maintenance",
"infra",
"review"
]
},
{
"login": "magicmatatjahu",
"name": "Maciej Urbańczyk",
"avatar_url": "https://avatars.githubusercontent.com/u/20404945?v=4",
"profile": "https://github.com/magicmatatjahu",
"contributions": [
"review"
]
},
{
"login": "victormartingarcia",
"name": "Victor",
"avatar_url": "https://avatars.githubusercontent.com/u/659832?v=4",
"profile": "https://www.victormartingarcia.com",
"contributions": [
"code"
]
},
{
"login": "HUTCHHUTCHHUTCH",
"name": "HUTCHHUTCHHUTCH",
"avatar_url": "https://avatars.githubusercontent.com/u/55915170?v=4",
"profile": "https://github.com/HUTCHHUTCHHUTCH",
"contributions": [
"infra"
]
},
{
"login": "pioneer2k",
"name": "Thomas Heyer",
"avatar_url": "https://avatars.githubusercontent.com/u/32297829?v=4",
"profile": "https://github.com/pioneer2k",
"contributions": [
"infra"
]
}
],
"contributorsPerLine": 7,
"projectName": "github-action-for-generator",
"projectOwner": "asyncapi",
"repoType": "github",
"repoHost": "https://github.com",
"commitConvention": "none"
}
6 changes: 6 additions & 0 deletions github-action/.asyncapi-tool
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
2 changes: 2 additions & 0 deletions github-action/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
output
node_modules
95 changes: 95 additions & 0 deletions github-action/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
env:
node: true
es6: true

plugins:
- sonarjs

extends:
- plugin:sonarjs/recommended

parserOptions:
ecmaVersion: 2018

rules:
# Ignore Rules
strict: 0
no-underscore-dangle: 0
no-mixed-requires: 0
no-process-exit: 0
no-warning-comments: 0
curly: 0
no-multi-spaces: 0
no-alert: 0
consistent-return: 0
consistent-this: [0, self]
func-style: 0
max-nested-callbacks: 0

# Warnings
no-debugger: 1
no-empty: 1
no-invalid-regexp: 1
no-unused-expressions: 1
no-native-reassign: 1
no-fallthrough: 1
camelcase: 0

# Errors
eqeqeq: 2
no-undef: 2
no-dupe-keys: 2
no-empty-character-class: 2
no-self-compare: 2
valid-typeof: 2
no-unused-vars: [2, { "args": "none" }]
handle-callback-err: 2
no-shadow-restricted-names: 2
no-new-require: 2
no-mixed-spaces-and-tabs: 2
block-scoped-var: 2
no-else-return: 2
no-throw-literal: 2
no-void: 2
radix: 2
wrap-iife: [2, outside]
no-shadow: 0
no-use-before-define: [2, nofunc]
no-path-concat: 2
valid-jsdoc: [0, {requireReturn: false, requireParamDescription: false, requireReturnDescription: false}]

# stylistic errors
no-spaced-func: 2
semi-spacing: 2
quotes: [2, 'single']
key-spacing: [2, { beforeColon: false, afterColon: true }]
indent: [2, 2]
no-lonely-if: 2
no-floating-decimal: 2
brace-style: [2, 1tbs, { allowSingleLine: true }]
comma-style: [2, last]
no-multiple-empty-lines: [2, {max: 1}]
no-nested-ternary: 2
operator-assignment: [2, always]
padded-blocks: [2, never]
quote-props: [2, as-needed]
keyword-spacing: [2, {'before': true, 'after': true, 'overrides': {}}]
space-before-blocks: [2, always]
array-bracket-spacing: [2, never]
computed-property-spacing: [2, never]
space-in-parens: [2, never]
space-unary-ops: [2, {words: true, nonwords: false}]
wrap-regex: 2
linebreak-style: 0
semi: [2, always]
arrow-spacing: [2, {before: true, after: true}]
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
no-var: 2
object-shorthand: [2, always]
prefer-arrow-callback: 2
prefer-const: 2
prefer-spread: 2
prefer-template: 2
5 changes: 5 additions & 0 deletions github-action/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage
.DS_Store
output
node_modules
dist
20 changes: 20 additions & 0 deletions github-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:18-alpine

# Create a non-root user
RUN addgroup -S myuser && adduser -S myuser -G myuser

RUN apk add --no-cache bash>5.1.16 git>2.42.0 chromium
Fixed Show fixed Hide fixed

# Environment variables for Puppeteer for PDF generation by HTML Template
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Installing latest released npm package
RUN npm install --ignore-scripts -g @asyncapi/cli

COPY entrypoint.sh /entrypoint.sh

# Make the bash file executable
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
61 changes: 61 additions & 0 deletions github-action/Makefile
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/markdown-template@0.10.0'
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)
Loading
Loading