Skip to content

Commit

Permalink
Run separate instance of OAV (#5026)
Browse files Browse the repository at this point in the history
* run separate instance of OAV

* MODEL PR_ONLY=false

* Don't run model validation for PR_ONLY = false

* Update modelValidation.js
  • Loading branch information
sergey-shandar authored Jan 31, 2019
1 parent eaf5e5c commit e44239a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
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()

0 comments on commit e44239a

Please sign in to comment.