Skip to content
12 changes: 12 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ jobs:
- script: 'node scripts/modelValidation.js'
displayName: 'Model Validation'

- job: "Avocado"
pool:
vmImage: 'Ubuntu 16.04'
continueOnError: true
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
- script: './node_modules/.bin/ts-node scripts/avocado.ts'
displayName: 'Avocado'

- job: "BreakingChange"
condition: "not(variables['PRIVATE'])"
pool:
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
"description": "Tests for Azure REST API Specifications",
"license": "MIT",
"devDependencies": {
"@azure/avocado": "^0.2.0",
"@azure/oad": "^0.2.1",
"@microsoft.azure/async-io": "^1.0.21",
"@microsoft.azure/literate": "^1.0.21",
"@microsoft.azure/polyfill": "^1.0.17",
"@ts-common/commonmark-to-markdown": "^1.1.10",
"@ts-common/fs": "0.1.0",
"@ts-common/fs": "0.1.1",
"@types/js-yaml": "^3.12.0",
"fs-extra": "^3.0.1",
"glob": "^5.0.14",
"js-yaml": "^3.12.2",
"js-yaml": "^3.13.0",
"json-schema-ref-parser": "^3.1.2",
"mocha": "*",
"@azure/oad": "^0.2.1",
"oav": "^0.14.5",
"oav": "^0.14.8",
"request": "^2.61.0",
"request-promise-native": "^1.0.5",
"ts-node": "^8.0.3",
"typescript": "^3.2.4",
"z-schema": "^3.25.1",
"ts-node": "^8.0.3"
"z-schema": "^3.25.1"
},
"dependencies": {
"@octokit/rest": "^15.2.6"
Expand Down
44 changes: 44 additions & 0 deletions scripts/avocado.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const utils = require('../test/util/utils')
import * as path from "path"
import * as avocado from "@azure/avocado"
import * as openApiMarkDown from "@azure/openapi-markdown"
import * as yaml from "js-yaml"

async function main() {
const swaggersToProcess = utils.getFilesChangedInPR();
let errorNumbers = 0
const set = new Set<string>()
for (const swagger of swaggersToProcess) {
const rm = await openApiMarkDown.findReadMe(path.dirname(swagger))
if (rm === undefined) {
console.error(`No readme.md for ${swagger}`)
++errorNumbers
} else {
const dir = path.dirname(rm)
if (dir.includes("specification")) {
set.add(dir)
} else {
console.error(`No readme.md for ${swagger}`)
++errorNumbers
}
}
}
for (const swagger of set) {
try {
console.log(swagger)
const errors = avocado.avocado(swagger)
for await (const e of errors) {
console.error(yaml.safeDump(e))
++errorNumbers
}
} catch (e) {
console.error("fatal error:")
console.error(e)
++errorNumbers
}
}
console.log(`errors: ${errorNumbers}`)
return errorNumbers === 0 ? 0 : 1
}

main().then(process.exit)
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"monitorConditionResolvedDateTime": "2018-09-13T15:51:02Z"
},
"egressConfig": {},
"context": {}
"context": {}
},
"id":"/subscriptions/9e261de7-c804-4b9d-9ebf-6f50fe350a9a/providers/Microsoft.AlertsManagement/alerts/66114d64-d9d9-478b-95c9-b789d6502100",
"type":"Microsoft.AlertsManagement/alerts",
"name":"cpu alert"
}
}
}
}
}