Skip to content

Commit

Permalink
fix: add ci workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimeshKumar923 committed Jun 16, 2024
1 parent 9c82ffa commit 46f32a5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/validate-embedded-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate Embedded Examples in asyncapi.md

on:
# temporarily added for testing purposes
push:
branches:
- embedded-examples-validation
# pull_request_target:
# types: [opened, reopened, synchronize, edited, ready_for_review]

jobs:
validate-examples:
name: Validate Examples
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm install
- name: Validate AsyncAPI documents
run: npm run validate:examples
6 changes: 4 additions & 2 deletions scripts/validation/embedded-examples-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ combinedData.forEach((item, index) => {
fs.mkdirSync(outputDir, { recursive: true });
}

const outputPath = path.join(outputDir, `updated-doc-${index + 1}.json`);
const processedExampleName = item.name.replace(/[^\w\s-]/g, '').replace(/\s+/g, '-');
const outputPath = path.join(outputDir, `${processedExampleName}.json`);
// const outputPath = `./updated-docs/updated-doc-${index + 1}.json`;
// console.log(`\n${combinedData[num-1].name} = ${currentExample}`);

// Apply updates and save the document
applyUpdatesAndSave([item], baseDocPath, outputPath);
Expand Down Expand Up @@ -259,7 +261,7 @@ console.log(`\nNumber of examples extracted: ${combinedData.length}`);
let num = 43;
const currentExample = JSON.stringify(combinedData[num-1], null, 2);
console.log(`\nexample ${num} = ${currentExample} `)
// console.log(`\n${combinedData[num-1].name} = ${currentExample} `)
// console.log(`\n${combinedData[num-1].name} = ${currentExample}`);

// Wait for all validation promises to resolve
Promise.all(validationPromises)
Expand Down
6 changes: 3 additions & 3 deletions scripts/validation/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "validation",
"version": "1.0.0",
"description": "for example validation files",
"main": "validate-embedded-examples.js",
"description": "for validation of embedded examples in asyncapi.md file",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"validate:examples": "node embedded-examples-validation.js"
},
"author": "Animesh Kumar",
"license": "ISC",
Expand Down

0 comments on commit 46f32a5

Please sign in to comment.