Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
- MODE=semantic PR_ONLY=true CHECK_NAME="Semantic Validator"
- MODE=semantic PR_ONLY=false
- MODE=model PR_ONLY=true CHECK_NAME="Model Validator"
# - MODE=model PR_ONLY=false
- MODE=BreakingChange PR_ONLY=true CHECK_NAME="Breaking Changes"
- MODE=lintdiff PR_ONLY=true CHECK_NAME="Linter Diff"
matrix:
Expand All @@ -27,6 +28,7 @@ matrix:
- env: MODE=java CHECK_NAME="SDK Generation - Java"
- env: MODE=go CHECK_NAME="SDK Generation - Go"
- env: MODE=semantic PR_ONLY=false
- env: MODE=model PR_ONLY=false
- env: MODE=model PR_ONLY=true CHECK_NAME="Model Validator"
- env: MODE=BreakingChange PR_ONLY=true CHECK_NAME="Breaking Changes"
install: true
Expand Down
32 changes: 23 additions & 9 deletions scripts/modelValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,38 @@
'use strict';

const utils = require('../test/util/utils')
const oav = require('oav');
const cp = require("child_process")

const exec = (cmd, options) => {
const result = cp.spawnSync(
cmd,
{
...options,
shell: true,
stdio: [process.stdin, process.stdout, process.stderr]
}
)
return result.status
}

async function main() {
const swaggersToProcess = utils.getFilesChangedInPR();
// Useful when debugging a test for a particular swagger.
// Just update the regex. That will return an array of filtered items.
// swaggersToProcess = swaggersToProcess.filter(function(item) {
// return (item.match(/.*Microsoft.Logic.*2016-06-01.*/ig) !== null);
// });
let result = 0
for (const swagger of swaggersToProcess) {
try {
await oav.validateExamples(swagger, null, {consoleLogLevel: 'error', pretty: true});
oav.clearCache();
// await oav.validateExamples(swagger, null, {consoleLogLevel: 'error', pretty: true});
// run OAV as a separate process to avoid memory issues.
const r = exec(`node node_modules/oav/dist/cli.js validate-example ${swagger} --pretty`)
if (result === 0) {
result = r
}
} catch (e) {
console.error("error: ")
console.error(e)
result = 1
}
}
return result
}

main()
main()