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
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,36 @@ The structure of the directory should strictly follow these rules:
The structure should appear like so:
```bash
.
+---automation
| \---resource-manager
| \---Microsoft.Automation
| \---2015-10-31
| \---examples
+---batch
| +---data-plane
| | \---Microsoft.Batch
| | +---2015-12-01.2.2
| | +---2016-02-01.3.0
| | +---2016-07-01.3.1
| | +---2017-01-01.4.0
| | | \---examples
| | \---2017-05-01.5.0
| \---resource-manager
| \---Microsoft.Batch
| +---2015-12-01
| +---2017-01-01
| | \---examples
| \---2017-05-01
| \---examples
+---billing
| \---resource-manager
| \---Microsoft.Billing
| +---2017-02-27-preview
| | \---examples
| \---2017-04-24-preview
| \---examples
└── readme.md
\---specification
| +---automation
| | \---resource-manager
| | \---Microsoft.Automation
| | \---2015-10-31
| | \---examples
| +---batch
| | +---data-plane
| | | \---Microsoft.Batch
| | | +---2015-12-01.2.2
| | | +---2016-02-01.3.0
| | | +---2016-07-01.3.1
| | | +---2017-01-01.4.0
| | | | \---examples
| | | \---2017-05-01.5.0
| | \---resource-manager
| | \---Microsoft.Batch
| | +---2015-12-01
| | +---2017-01-01
| | | \---examples
| | \---2017-05-01
| | \---examples
| +---billing
| \---resource-manager
| \---Microsoft.Billing
| +---2017-02-27-preview
| | \---examples
| \---2017-04-24-preview
| \---examples
\--- readme.md
```

Currently, the specifications are expected to be in Swagger JSON format
Expand All @@ -77,4 +78,3 @@ The next step in the process after a spec is completed is to generate SDKs and A

---
_This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments._

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@microsoft.azure/literate":"^1.0.21",
"@microsoft.azure/async-io":"^1.0.21",
"@microsoft.azure/polyfill":"^1.0.17",
"oad": "^0.1.6"
"oad": "^0.1.7"
},
"homepage": "https://github.com/azure/azure-rest-api-specs",
"repository": {
Expand Down
23 changes: 19 additions & 4 deletions scripts/breaking-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ function runOad(oldSpec, newSpec) {
console.log(`New Spec: "${newSpec}"`);
console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`);

return Promise.resolve(oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true }));
return oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true }).then((result) => {
console.log(result);
if (result !== undefined && typeof result.valueOf() === 'string' && result.indexOf(`"type": "Error"`) > -1) {
console.log(`There are potential breaking changes in this PR. Please review before moving forward. Thanks!`);
process.exitCode = 1;
}
return Promise.resolve();
}).catch(err => {
console.log(err);
});
}

/**
Expand Down Expand Up @@ -99,8 +108,13 @@ async function runScript() {
console.dir(resolvedMapForNewSpecs);

for (const swagger of swaggersToProcess) {
let outputFileNameWithExt = path.basename(swagger);
// If file does not exists in the previous commits then we ignore it as it's new file
if (!fs.existsSync(swagger)) {
console.log(`File: "${swagger}" looks to be newly added in this PR.`);
continue;
}

let outputFileNameWithExt = path.basename(swagger);
console.log(outputFileNameWithExt);
if (resolvedMapForNewSpecs[outputFileNameWithExt]) {
await runOad(swagger, resolvedMapForNewSpecs[outputFileNameWithExt]);
Expand All @@ -110,8 +124,9 @@ async function runScript() {

// magic starts here
runScript().then(success => {
process.exit(0);
console.log(`Thanks for using breaking change tool to review.`);
console.log(`If you encounter any issue(s), please open issue(s) at https://github.com/Azure/openapi-diff/issues .`);
}).catch(err => {
console.log(err);
process.exit(1);
process.exitCode = 1;
})
45 changes: 27 additions & 18 deletions scripts/getStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var exec = require('child_process').exec,
utils = require("../test/util/utils");

var swaggersToProcess = utils.swaggers;
var readmesToProcess = utils.readmes;
var finalResult = {};
var filename = `log_${utils.getTimeStamp()}.log`;
var logFilepath = path.join(getLogDir(), filename);
Expand Down Expand Up @@ -50,9 +51,9 @@ function writeContent(content) {
}

//runs the linter on a given swagger spec.
async function runLinter(swagger) {
// TODO: update to use config file... but report grouping is by Swagger right now
let cmd = 'autorest --validation --azure-validator --input-file=' + swagger + ' --message-format=json';
async function runLinter(readme) {
let cmd = 'autorest ' + readme + ' --azure-validator=true --message-format=json';
console.log(cmd);
console.log(`\t- Running Linter.`);
const {err, stdout, stderr } = await new Promise(res => exec(cmd, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 },
(err, stdout, stderr) => res({ err: err, stdout: stdout, stderr: stderr })));
Expand All @@ -69,7 +70,7 @@ async function runLinter(swagger) {
//console.log('>>>>>> Parsed Result...');
//console.dir(resultObject, {depth: null, colors: true});
} catch (e) {
console.log(`An error occurred while executing JSON.parse() on the linter output for ${swagger}:`);
console.log(`An error occurred while executing JSON.parse() on the linter output for ${readme}:`);
console.dir(resultString);
console.dir(e, { depth: null, colors: true });
}
Expand All @@ -88,27 +89,35 @@ function runSemanticValidator(swagger) {
});
}

//runs the validation and linting tools on all the swaggers in the repo.
async function runTools(swagger) {
console.log(`Processing "${swagger}":`);
const validationErrors = await runSemanticValidator(swagger);
updateResult(swagger, validationErrors, true);
const linterErrors = await runLinter(swagger);
updateResult(swagger, linterErrors, true);
}

//main function
async function runScript() {
// 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(/.*arm-network/ig) !== null);
// });
// swaggersToProcess = swaggersToProcess.filter(function (item) {
// return (item.match(/.*Microsoft.network/ig) !== null);
// });
// readmesToProcess = readmesToProcess.filter(function (item) {
// return (item.match(/.*.network/ig) !== null);
// });
createLogFile();
console.log(`The results will be logged here: "${logFilepath}".`);
for (const swagger of swaggersToProcess) {
await runTools(swagger);

for (let swagger of swaggersToProcess) {
const validationErrors = await runSemanticValidator(swagger);
swagger = swagger.split(/\/Microsoft\./gi)[0] + "/readme.md";
console.log(`File Name: "${swagger}"`);
if (validationErrors != null)
{
updateResult(swagger, validationErrors, true);
}
}

for (let readme of readmesToProcess) {
console.log(`Configuration file: "${readme}"`);
const linterErrors = await runLinter(readme);
updateResult(readme, linterErrors, true);
}

//console.dir(finalResult, { depth: null, colors: true });
return finalResult;
}
Expand Down
5 changes: 3 additions & 2 deletions scripts/momentOfTruth.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ async function runScript() {
for (const configFile of configsToProcess) {
await runTools(configFile, 'after');
}
execSync(`${gitCheckoutCmd}`, { encoding: 'utf8' });
execSync(`${gitLogCmd}`, { encoding: 'utf8' });

utils.checkoutTargetBranch();

for (const configFile of configsToProcess) {
await runTools(configFile, 'before');
}
Expand Down
30 changes: 30 additions & 0 deletions specification/cognitiveservices/data-plane/Face/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cognitive Services Face SDK

> see https://aka.ms/autorest

Configuration for generating Face SDK.

The current release is `release_1_0`.

``` yaml

tag: release_1_0
```
# Releases

### Release 1.0
These settings apply only when `--tag=release_1_0` is specified on the command line.

``` yaml $(tag) == 'release_1_0'
input-file: v1.0/Face.json
log-file: logs/log.txt
```

## CSharp Settings
These settings apply only when `--csharp` is specified on the command line.
``` yaml $(csharp)
csharp:
namespace: Microsoft.CognitiveServices.Face
output-folder: out/csharp
```

Loading