Skip to content

Commit

Permalink
Added lint workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong committed Apr 12, 2024
1 parent 0b6fd46 commit d766fcf
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Validate spec folder

on:
push:
branches: ['**']
paths:
- 'spec/**'
- 'tools/linter/**'
pull_request:
branches: ['**']
paths:
- 'spec/**'
- 'tools/linter/**'

jobs:
lint-spec:
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.10.0
- run: npm install
- run: npm run lint -- ../spec
15 changes: 12 additions & 3 deletions tools/linter/lint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import SpecValidator from "./SpecValidator";


const validator = new SpecValidator('../spec');
const root_folder = process.argv[2] || '../spec';
const validator = new SpecValidator(root_folder);
const errors = validator.validate();
errors.forEach(e => console.error(e));
console.log('\nTotal errors:', errors.length)

if(errors.length === 0) {
console.log('No errors found.');
process.exit(0);
} else {
console.log('Errors found:\n');
errors.forEach(e => console.error(e));
console.log('\nTotal errors:', errors.length)
process.exit(1);
}
12 changes: 4 additions & 8 deletions tools/merger/merge.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import OpenApiMerger from "./OpenApiMerger";


async function main() {
const root_path: string = process.argv[2]; // '../spec/opensearch-openapi.yaml'
const output_path: string = process.argv[3]; // '../build/opensearch-openapi.yaml'
const merger = new OpenApiMerger(root_path);
merger.merge(output_path);
}

main();
const root_path: string = process.argv[2] || '../spec/opensearch-openapi.yaml'
const output_path: string = process.argv[3] || '../opensearch-openapi.yaml'
const merger = new OpenApiMerger(root_path);
merger.merge(output_path);

0 comments on commit d766fcf

Please sign in to comment.