Skip to content

Commit

Permalink
Rebased master to monthly network branch (#3687)
Browse files Browse the repository at this point in the history
* Swagger Coverage/Completeness- for operation CheckNameAvailability (#3663)

* Update service.json

* CheckNameAvailability

* FIxed Parameter name

fixed couple of parameters name

* Update dns management Node.js version number to 3.0.0 (#3675)

* Update batchai Node.js package version to 2.0.2 (#3664)

* Update nofiticationhubs management Node.js package version to 2.0.0 (#3665)

* WebApps - Add BackupName to backup API models (#3560)

* WebApps - Add BackupName to replace non-ARM-compliant Name property on Backup API models

* Revert breaking change to BackupItem. BackupItemName property will be fine in place of BackupName for now.

* Update authorization management Node.js package version to 5.0.1 (#3676)

* Update storagesync management Node.js package version to 1.0.0 (#3677)

* add checknameavailability (#3608)

* add checknameavailability

* move checkname parameter to definition section

* fix brackets

* fix parameter name in checknameavailability exanple

* update code owners for PowerBIDedicated

* New Batch data plane API version 2018-08-01.7.0 (#3657)

* Add new batch version 2018-08-01.7.0

* Update the new API

* Fix up output from OAD, it does not output valid JSON

* update OAV (#3678)

* Update storage management Node.js package version to 5.2.0 (#3679)

* Update compute.json and disk.json for some issues and add zone and rolling upgrade. (#3642)

* Breaking change tool correctly handles multiple files with same name

* Fix to breaking changes table generation

* Trusted Root certificate (#3668)
  • Loading branch information
MikhailTryakhov authored and sergey-shandar committed Aug 21, 2018
1 parent 3ff4b52 commit aafc3d8
Show file tree
Hide file tree
Showing 161 changed files with 20,266 additions and 141 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
/specification/operationsmanagement/ @dashimi16
/specification/policyinsights/ @bulentelmaci
/specification/postgresql/ @qingqingyuan
/specification/powerbidedicated/ @tarostok
/specification/provisioningservices/ @kvish
/specification/recoveryservices/ @dragonfly91 @sonathan
/specification/recoveryservicesbackup/ @dheerendrarathor
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"json-schema-ref-parser": "^3.1.2",
"mocha": "*",
"oad": "^0.1.11",
"oav": "^0.4.57",
"oav": "^0.5.1",
"request": "^2.61.0",
"request-promise-native": "^1.0.5",
"z-schema": "^3.16.1"
Expand Down
80 changes: 38 additions & 42 deletions scripts/breaking-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT License. See License in the project root for license information.

'use strict';
var utils = require('../test/util/utils'),
const utils = require('../test/util/utils'),
path = require('path'),
fs = require('fs'),
fs = require('fs-extra'),
os = require('os'),
execSync = require('child_process').execSync,
exec = require('util').promisify(require('child_process').exec),
oad = require('oad');

// This map is used to store the mapping between files resolved and stored location
Expand Down Expand Up @@ -65,13 +65,16 @@ async function runOad(oldSpec, newSpec) {
console.log(`New Spec: "${newSpec}"`);
console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`);

const result = await oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true });
let result = await oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true });
console.log(result);

if (!result) {
return;
}

// fix up output from OAD, it does not output valid JSON
result = '[' + result.replace(/}\s+{/gi,"},{") + ']'

return JSON.parse(result);
}

Expand All @@ -80,57 +83,53 @@ async function runOad(oldSpec, newSpec) {
*
* @param {string} swaggerPath Path to the swagger specification file.
*/
function processViaAutoRest(swaggerPath) {
async function processViaAutoRest(swaggerPath) {
if (swaggerPath === null || swaggerPath === undefined || typeof swaggerPath.valueOf() !== 'string' || !swaggerPath.trim().length) {
return Promise.reject(new Error('swaggerPath is a required parameter of type "string" and it cannot be an empty string.'));
throw new Error('swaggerPath is a required parameter of type "string" and it cannot be an empty string.');
}

console.log(`Processing via AutoRest...`);

let outputFileNameWithExt = path.basename(swaggerPath);
let outputFileNameWithoutExt = path.basename(swaggerPath, '.json');
let autoRestCmd = `autorest --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileNameWithoutExt} --output-folder=${outputFolder}`;
const swaggerOutputFolder = path.join(outputFolder, path.dirname(swaggerPath));
const swaggerOutputFileNameWithoutExt = path.basename(swaggerPath, '.json');
const autoRestCmd = `autorest --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${swaggerOutputFileNameWithoutExt} --output-folder=${swaggerOutputFolder}`;

console.log(`Executing : ${autoRestCmd}`);

try {
let result = execSync(`${autoRestCmd}`, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 });
resolvedMapForNewSpecs[outputFileNameWithExt] = path.join(outputFolder, outputFileNameWithExt);
await fs.ensureDir(swaggerOutputFolder);
await exec(`${autoRestCmd}`, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 });
resolvedMapForNewSpecs[swaggerPath] = path.join(swaggerOutputFolder, swaggerOutputFileNameWithoutExt + '.json');
} catch (err) {
// Do not update map in case of errors.
console.log(`Error processing via AutoRest: ${err}`);
}

return Promise.resolve();
}

//main function
async function runScript() {
// See whether script is in Travis CI context
console.log(`isRunningInTravisCI: ${isRunningInTravisCI}`);

// Create directory to store the processed & resolved swaggers
if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
}

let targetBranch = utils.getTargetBranch();
let swaggersToProcess = utils.getFilesChangedInPR();

console.log('Processing swaggers:');
console.log(swaggersToProcess);

for (const swagger of swaggersToProcess) {
await processViaAutoRest(swagger);
}

console.log('Finding new swaggers...')
let newSwaggers = [];
if (isRunningInTravisCI && swaggersToProcess.length > 0) {
newSwaggers = await utils.doOnBranch(utils.getTargetBranch(), async () => {
return swaggersToProcess.filter(s => !fs.existsSync(s))
});
}

console.log(`Resolved map for the new specification is:`);
console.log('Processing via AutoRest...');
for (const swagger of swaggersToProcess) {
if (!newSwaggers.includes(swagger)) {
await processViaAutoRest(swagger);
}
}

console.log(`Resolved map for the new specifications:`);
console.dir(resolvedMapForNewSpecs);

let errors = 0, warnings = 0;
Expand All @@ -145,23 +144,20 @@ async function runScript() {
continue;
}

let outputFileNameWithExt = path.basename(swagger);
console.log(outputFileNameWithExt);
if (resolvedMapForNewSpecs[outputFileNameWithExt]) {
const diff = await runOad(swagger, resolvedMapForNewSpecs[outputFileNameWithExt]);
if (diff) {
if (!diffFiles[swagger]) {
diffFiles[swagger] = [];
}
diffFiles[swagger].push(diff);
if (diff['type'] === 'Error') {
if (errors === 0) {
console.log(`There are potential breaking changes in this PR. Please review before moving forward. Thanks!`);
process.exitCode = 1;
if (resolvedMapForNewSpecs[swagger]) {
const diffs = await runOad(swagger, resolvedMapForNewSpecs[swagger]);
if (diffs) {
diffFiles[swagger] = diffs;
for (const diff of diffs) {
if (diff['type'] === 'Error') {
if (errors === 0) {
console.log(`There are potential breaking changes in this PR. Please review before moving forward. Thanks!`);
process.exitCode = 1;
}
errors += 1;
} else if (diff['type'] === 'Warning') {
warnings += 1;
}
errors += 1;
} else if (diff['type'] === 'Warning') {
warnings += 1;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please also specify `--node-sdks-folder=<path to root folder of your azure-sdk-f
nodejs:
azure-arm: true
package-name: azure-arm-authorization
package-version: 4.1.0
package-version: 5.0.1
output-folder: $(node-sdks-folder)/lib/services/authorizationManagement
payload-flattening-threshold: 1
generate-license-txt: true
Expand Down
Loading

0 comments on commit aafc3d8

Please sign in to comment.