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

ci: add a script and CI job to validate spec examples #1046

Merged
Merged
Changes from 40 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
178cf39
feat: add new workflow to validate example
AnimeshKumar923 Mar 7, 2024
ce9b567
chore: update checkout action version
AnimeshKumar923 Mar 7, 2024
883b13c
fix: add YAML extension support
AnimeshKumar923 Mar 7, 2024
7fe9564
chore: add current testing branch in workflow
AnimeshKumar923 Mar 11, 2024
1e22e40
chore: update workflow version
AnimeshKumar923 Mar 11, 2024
f5a1a98
chore: update workflow version
AnimeshKumar923 Mar 11, 2024
b7da489
fix: update code to match workflow
AnimeshKumar923 Mar 11, 2024
fb898a4
fix: update code to match workflow
AnimeshKumar923 Mar 11, 2024
65c8f15
chore: update code
AnimeshKumar923 Mar 11, 2024
dacaf85
fix: update code, script in working condition
AnimeshKumar923 Mar 15, 2024
d3427b8
fix: update package.json, workflow file
AnimeshKumar923 Mar 15, 2024
37ba41b
chore: migrate package.json to root
AnimeshKumar923 Mar 15, 2024
9e7f840
fix: update script and yaml file
AnimeshKumar923 Mar 15, 2024
8a34862
chore: add \n for better readability
AnimeshKumar923 Mar 15, 2024
ba7a2a0
fix: update script, add error files information
AnimeshKumar923 Mar 15, 2024
ccc2e93
Merge branch 'master' into script-ci-spec-validation
AnimeshKumar923 Mar 24, 2024
abbda0d
fix: insert `process.exit(1)` at correct place
AnimeshKumar923 Mar 24, 2024
d2e81b1
chore: remove `process.exit(1)`
AnimeshKumar923 Mar 24, 2024
baa7c12
fix: made the script asynchronous
AnimeshKumar923 Mar 24, 2024
b25ea3e
Merge branch 'master' into script-ci-spec-validation
smoya Apr 3, 2024
a60325f
Merge branch 'master' into script-ci-spec-validation
AnimeshKumar923 Apr 5, 2024
20ca1f9
fix: update code, replace JS script with bash
AnimeshKumar923 Apr 5, 2024
450e7e1
fix: update code, runs on ubuntu-latest only
AnimeshKumar923 Apr 5, 2024
8af797a
chore: fix indent
AnimeshKumar923 Apr 5, 2024
6495645
chore: indent fix
AnimeshKumar923 Apr 5, 2024
811dc8f
chore: indent fix
AnimeshKumar923 Apr 5, 2024
c9dd120
chore: minor syntax fix
AnimeshKumar923 Apr 5, 2024
6671c44
chore: minor syntax fix
AnimeshKumar923 Apr 5, 2024
1287c96
chore: minor code update, testing workflow
AnimeshKumar923 Apr 5, 2024
18456f5
chore: minor code update, testing workflow
AnimeshKumar923 Apr 5, 2024
ce9c1d6
chore: minor code update, testing workflow
AnimeshKumar923 Apr 5, 2024
83cb5db
chore: minor code update, testing workflow
AnimeshKumar923 Apr 5, 2024
3c9a830
chore: bash code update, testing workflow
AnimeshKumar923 Apr 5, 2024
6942713
chore: remove previous code, testing
AnimeshKumar923 Apr 5, 2024
3a7b6a1
chore: update workflow code, testing
AnimeshKumar923 Apr 5, 2024
0657542
fix: update code, different approach
AnimeshKumar923 Apr 5, 2024
11a317b
chore: update bash script
AnimeshKumar923 Apr 5, 2024
1edbb60
Delete package-lock.json
AnimeshKumar923 Apr 5, 2024
3a47a66
chore: delete package.json
AnimeshKumar923 Apr 5, 2024
8a18479
chore: delete scripts/validation/validate-examples.js
AnimeshKumar923 Apr 5, 2024
cb7d070
fix: update bash script, pipe `xargs`
AnimeshKumar923 Apr 8, 2024
aef6961
chore: fixing errors
AnimeshKumar923 Apr 8, 2024
1e80279
chore: update code, fixing errors
AnimeshKumar923 Apr 8, 2024
0752a62
chore: update code, fixing errors
AnimeshKumar923 Apr 8, 2024
c3fbc0f
chore: update code, fixing errors
AnimeshKumar923 Apr 8, 2024
a73faaa
chore: bump action versions
AnimeshKumar923 Apr 8, 2024
6ff12cf
chore: testing different arguments
AnimeshKumar923 Apr 8, 2024
41ab956
chore: not much difference in the modified argument, reverting back
AnimeshKumar923 Apr 8, 2024
296f776
Merge branch 'master' into script-ci-spec-validation
AnimeshKumar923 Apr 11, 2024
b49f4a1
fix: remove `on:push:master`
AnimeshKumar923 Apr 11, 2024
adec980
Merge branch 'master' into script-ci-spec-validation
smoya Apr 29, 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
27 changes: 27 additions & 0 deletions .github/workflows/validate-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Validate AsyncAPI Examples

on:
push:
AnimeshKumar923 marked this conversation as resolved.
Show resolved Hide resolved
branches:
- script-ci-spec-validation # added temporarily for testing purpose
# - master

pull_request_target:
AnimeshKumar923 marked this conversation as resolved.
Show resolved Hide resolved
types: [opened, reopened, synchronize, edited, ready_for_review]

jobs:
validate-examples:
name: Validate Spec Examples
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install AsyncAPI CLI
run: npm install -g @asyncapi/cli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bo it uses latest CLI - advantage is that all latest features will be used but obvious disadvantage is randomly failing CI cause of some breaking change in validation, or some new validation enabled.

yeah, not so obvious in this case 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so should be use a specific version of the CLI? 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I can give my opinion here, I think using latest is a good option. We are always testing on the last version, supporting last spec schemas, etc + if something is wrong with the CLI, we are gonna be one of the first who notice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @derberg 👋

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no strong opinion really, there are pros and cons for using latest and not using latest. We just need to be aware that if we decide to use latest - then on PRs we can have random fails from time to time and we need to support contributors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I suggest then we can try with this but opened to change if needed at any time.

- name: Validate AsyncAPI documents
run: |
find examples/ \( -path 'examples/social-media/*' -prune \) -o -type f \( -name "*.yml" -o -name "*.yaml" \) -exec asyncapi validate {} \;
Copy link
Member

@smoya smoya Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice oneliner 👏 👏

There is only a couple of issues here:

  1. The path to skip should be 'examples/social-media/common.
  2. I don't find prune option to be very readable. Instead, you can use the -not operator. E.g. -not -path 'examples/social-media/common'
  3. With -exec option you can't parallelise the work, so everything will run sequentially.
    Instead, try piping the find output to xargs and the -P arg.

Applying that, will look like:

find examples -type f \( -name "*.yml" -o -name "*.yaml" \) -not -path 'examples/social-media/common' | xargs -P 10 -L 1 asyncapi validate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, please add a comment on top of the command explaining why we are skipping that dir.

Copy link
Contributor Author

@AnimeshKumar923 AnimeshKumar923 Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice oneliner 👏 👏

Thank you! 😁 To be honest, I'm still learning bash so somethings may take time to understand 😅 and many things are new like the usage of xargs. Will learn along the way, thanks to you... 😊

There is only a couple of issues here:

1. The path to skip should be `'examples/social-media/common`.

2. I don't find `prune` option to be very readable. Instead, you can use the `-not` operator. E.g. `-not -path 'examples/social-media/common'`

3. With `-exec` option you can't parallelise the work, so everything will run sequentially.
   Instead, try piping the find output to `xargs` and the `-P` arg.

Applying that, will look like:

find examples -type f \( -name "*.yml" -o -name "*.yaml" \) -not -path 'examples/social-media/common' | xargs -P 10 -L 1 asyncapi validate

Thank you for the suggestions, will try to understand and implement the same. 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, please add a comment on top of the command explaining why we are skipping that dir.

Sure, I'll do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied through cb7d070

Loading