Skip to content

Commit

Permalink
bogus change (#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
olydis authored and amarzavery committed Jul 11, 2017
1 parent f6d4869 commit 18262a5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parameters": {
"namespaceName": "sdk-Namespace-5849",
"resourceGroupName": "South Central US",
"resourceGroupName": "SouthCentralUS",
"api-version": "2017-04-01",
"subscriptionId": "5f750a97-50d9-4e36-8081-c9ee4c0210d4"
},
Expand Down
10 changes: 5 additions & 5 deletions test/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ var _ = require('lodash'),
utils = require('./util/utils');

describe('AutoRest Linter validation:', function () {
let swaggersToProcess = utils.getFilesChangedInPR();
let configsToProcess = utils.getConfigFilesChangedInPR();
// 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) {
// configsToProcess = configsToProcess.filter(function(item) {
// return (item.match(/.Microsoft.ContainerRegistry.*2017-03-01.*/ig) !== null);
// });
_(swaggersToProcess).each(function (swagger) {
it(swagger + ' should honor linter validation rules.', function (done) {
var cmd = 'autorest --azure-validator=true --input-file=' + swagger + ' --message-format=json';
_(configsToProcess).each(function (config) {
it(config + ' should honor linter validation rules.', function (done) {
var cmd = `autorest --azure-validator ${config} --message-format=json`;
console.log(`Executing: ${cmd}`);
let result;
try {
Expand Down
50 changes: 48 additions & 2 deletions test/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports.prOnly = undefined !== process.env['PR_ONLY'] ? process.env['PR_ONLY'] :

exports.globPath = path.join(__dirname, '../', '../', '/specification/**/*.json');
exports.swaggers = _(glob.sync(exports.globPath, { ignore: ['**/examples/**/*.json', '**/quickstart-templates/*.json', '**/schema/*.json'] }));
exports.exampleGlobPath = path.join(__dirname, '../', '../', '/**/examples/**/*.json');
exports.exampleGlobPath = path.join(__dirname, '../', '../', '/specification/**/examples/**/*.json');
exports.examples = _(glob.sync(exports.exampleGlobPath));

// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
Expand Down Expand Up @@ -144,6 +144,51 @@ exports.getTimeStamp = function getTimeStamp() {
+ pad(now.getSeconds());
}

/**
* Retrieves list of swagger files to be processed for linting
* @returns {Array} list of files to be processed for linting
*/
exports.getConfigFilesChangedInPR = function getConfigFilesChangedInPR() {
if (exports.prOnly === 'true') {
let targetBranch, cmd, filesChanged, swaggerFilesInPR;
try {
targetBranch = exports.getTargetBranch();
execSync(`git fetch origin ${targetBranch}`);
cmd = `git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD)`;
filesChanged = execSync(cmd, { encoding: 'utf8' }).split('\n');
console.log('>>>>> Files changed in this PR are as follows:');
console.log(filesChanged);

// traverse up to readme.md files
const configFiles = new Set();
for (let fileChanged of filesChanged) {
while (fileChanged.startsWith("specification")) {
if (fileChanged.toLowerCase().endsWith("readme.md") && fs.existsSync(fileChanged)) {
configFiles.add(fileChanged);
break;
}
// select parent readme
const parts = fileChanged.split('/');
parts.pop();
parts.pop();
parts.push("readme.md");
fileChanged = parts.join('/');
}
}
filesChanged = [...configFiles.values()];

console.log('>>>>> Affected configuration files:');
console.log(filesChanged);

return filesChanged;
} catch (err) {
throw err;
}
} else {
return exports.swaggers;
}
};

/**
* Retrieves list of swagger files to be processed for linting
* @returns {Array} list of files to be processed for linting
Expand All @@ -154,7 +199,8 @@ exports.getFilesChangedInPR = function getFilesChangedInPR() {
let targetBranch, cmd, filesChanged, swaggerFilesInPR;
try {
targetBranch = exports.getTargetBranch();
cmd = `git diff --name-only HEAD $(git merge-base HEAD ${targetBranch})`;
execSync(`git fetch origin ${targetBranch}`);
cmd = `git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD)`;
filesChanged = execSync(cmd, { encoding: 'utf8' });
console.log('>>>>> Files changed in this PR are as follows:')
console.log(filesChanged);
Expand Down

0 comments on commit 18262a5

Please sign in to comment.