Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Travis-CI] Run breaking change tool in the CI #1456

Merged
merged 9 commits into from
Aug 1, 2017

Conversation

vishrutshah
Copy link
Contributor

@vishrutshah vishrutshah commented Jul 21, 2017

Running breaking change tool in the CI on the changed swagger json files.

Issue: Azure/openapi-diff#51
Successful Build: https://travis-ci.org/Azure/azure-rest-api-specs/jobs/256216203#L688

TODO:

  • Disabling the other CI modes to speedup the build for test
  • Updating the storage files to test
  • Enable the other CI modes
  • Make sure to NOT check-in the swagger changes
  • Revert the test changes

getFilesChangedInPR should not return package.json
@vishrutshah vishrutshah changed the title [WIP] [Travis-CI] Run breaking change tool in the CI [Travis-CI] Run breaking change tool in the CI Jul 21, 2017
@vishrutshah
Copy link
Contributor Author

@amarzavery @veronicagg Feel free to review this PR as you get chance. Thanks!

@@ -73,6 +73,22 @@ exports.getTargetBranch = function getTargetBranch() {
};

/**
* Checkouts targetBranch
*
* @param {string} swaggerPath Path to the swagger specification file.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasta ? 😳

Copy link
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left couple of comments, generally looks good to me.

}

let swaggersToProcess = utils.getFilesChangedInPR();
if (!isRunningInTraviCI) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this is applicable only for a local test and would need to be modified (as paths are pointing to your repo), I'd recommend commenting the whole section with a comment like "For debugging in your repo, un-comment the following section and....."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -203,7 +219,7 @@ exports.getFilesChangedInPR = function getFilesChangedInPR() {
console.log('>>>>> Files changed in this PR are as follows:')
console.log(filesChanged);
swaggerFilesInPR = filesChanged.split('\n').filter(function (item) {
if (item.match(/.*json$/ig) == null) {
if (item.match(/.*json$/ig) == null || item.match(/package.json$/ig) != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the purpose of the addition to the condition here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in this PR I've changed package.json it is coming into array of changed swaggers in PR but it should not. So I added that condition but now i think i may have better condition.

Look for files those have specification into their path instead looking for all .json & then ignoring.

Copy link
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry meant to indicate "request changes" before :)

@vishrutshah
Copy link
Contributor Author

@veronicagg I've incorporated the review feedback. Feel free to re-review as you get chance. Thanks!

@azuresdkciprbot
Copy link

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/network/resource-manager/readme.md
Before the PR: Warning(s): 151 Error(s): 84
After the PR: Warning(s): 151 Error(s): 84

File: specification/storage/resource-manager/readme.md
Before the PR: Warning(s): 11 Error(s): 1
After the PR: Warning(s): 11 Error(s): 1

AutoRest Linter Guidelines | AutoRest Linter Issues

Send feedback and make AutoRest Linter Azure Bot smarter day by day!

Thanks for your co-operation.

@@ -1711,11 +1711,6 @@
"type": "string",
"x-ms-client-name": "ContentLanguage",
"description": "The response header override for content language."
},
"rsct": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have this change in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to just make sure that tool runs and outputs things in CI. I'll be reverting that commit as soon as review completes :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please, let's make sure changes to the spec do not get merged.

@@ -583,7 +583,7 @@
},
"capacity": {
"type": "integer",
"format": "int32",
"format": "int64",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have this change in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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

let outputFileNameWithExt = swaggerPath.split('/').pop();
let outputFileNameWithoutExt = outputFileNameWithExt.split('.')[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using the logic on line 53-54, please use the path module available in node.js.

  • path.basename()
  • path.dirname()
  • path.extname()

should be useful for you.

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

try {
let result = execSync(`${autoRestCmd}`, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this value for maxBuffer: 1024 * 1024 * 64 be sufficient enough ? Wanted to know how you came up with this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure as I derived it from linter https://github.com/Azure/azure-rest-api-specs/blob/current/test/linter.js#L20

I think idea was to keep something to make sure we see when things goes over some number.

}

//main function
async function runScript() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by using this functionality you are expecting everyone to use the v8.x (an unstable version) on their box. Make sure that travis ci also picks up 8.x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it's moved to 8.0 already as we used async before :)

console.dir(resolvedMapForNewSpecs);

for (const swagger of swaggersToProcess) {
let outputFileNameWithExt = swagger.split('/').pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using the path module will be a better option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated to let outputFileNameWithExt = path.basename(swagger)

@azuresdkciprbot
Copy link

Hi There,

I am the AutoRest Linter Azure bot. I am here to help. My task is to analyze the situation from the AutoRest linter perspective. Please review the below analysis result:

File: specification/network/resource-manager/readme.md
Before the PR: Warning(s): 148 Error(s): 83
After the PR: Warning(s): 148 Error(s): 83

File: specification/storage/resource-manager/readme.md
Before the PR: Warning(s): 11 Error(s): 1
After the PR: Warning(s): 11 Error(s): 1

AutoRest Linter Guidelines | AutoRest Linter Issues

Send feedback and make AutoRest Linter Azure Bot smarter day by day!

Thanks for your co-operation.

Copy link
Contributor

@veronicagg veronicagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, please make sure not to commit changes to the storage spec.

let result = execSync(`${autoRestCmd}`, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 });
resolvedMapForNewSpecs[outputFileNameWithExt] = path.join(outputFolder, outputFileNameWithExt);
} catch (err) {
// Do not updage map in case of errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo in comment... "update"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. typo fixed

@@ -1711,11 +1711,6 @@
"type": "string",
"x-ms-client-name": "ContentLanguage",
"description": "The response header override for content language."
},
"rsct": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please, let's make sure changes to the spec do not get merged.

Adding some differentiator for CI output
@vishrutshah
Copy link
Contributor Author

Thanks everyone for the review!!

@vishrutshah vishrutshah merged commit 521c0e6 into Azure:current Aug 1, 2017
@AutorestCI
Copy link

No modification for AutorestCI/azure-sdk-for-python

@AutorestCI
Copy link

No modification for AutorestCI/azure-sdk-for-ruby

@AutorestCI
Copy link

No modification for AutorestCI/azure-sdk-for-node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants