From e44239a68ca7a91233c6ec5373977d5aeb3a307c Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Thu, 31 Jan 2019 15:00:59 -0800 Subject: [PATCH] Run separate instance of OAV (#5026) * run separate instance of OAV * MODEL PR_ONLY=false * Don't run model validation for PR_ONLY = false * Update modelValidation.js --- .travis.yml | 2 ++ scripts/modelValidation.js | 32 +++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2d65c0736b5..cb6367eb768b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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 diff --git a/scripts/modelValidation.js b/scripts/modelValidation.js index 6f46505fe92a..a2b0d89fa624 100644 --- a/scripts/modelValidation.js +++ b/scripts/modelValidation.js @@ -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() \ No newline at end of file +main()