Skip to content

logging upcoming breaking changes#3217

Merged
pmuens merged 4 commits into
masterfrom
breaking-changes-warning
Feb 10, 2017
Merged

logging upcoming breaking changes#3217
pmuens merged 4 commits into
masterfrom
breaking-changes-warning

Conversation

@eahefnawy

Copy link
Copy Markdown
Contributor

What did you implement:

Closes #3211

Added functionality for listing all the upcoming breaking changes in the CLI. This is going to be one of each release steps.

How did you implement it:

Added a method to the CLI that logs all the breaking changes. User can opt-out by setting the SLS_IGNORE_WARNING env var. I've also updated the release checklist to include a step where we update the upcoming breaking changes list on every release.

How can we verify it:

  • open the CLI class file and add some strings to the breakingChanges array.
  • run any serverless command and you should see the list.
  • opt out by setting the SLS_IGNORE_WARNING env var

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@eahefnawy eahefnawy added this to the 1.7 milestone Feb 9, 2017
@eahefnawy eahefnawy self-assigned this Feb 9, 2017
@eahefnawy eahefnawy changed the title logging up coming breaking changes logging upcoming breaking changes Feb 9, 2017

@pmuens pmuens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Just pushed some minor fixes so that the list of messages are indented.

Just added one comment about a test for this method.

Comment thread lib/classes/CLI.js Outdated
console.log(message); // eslint-disable-line no-console
}

logBreakingChanges() {

@pmuens pmuens Feb 9, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should have a basic test (something like that here might be sufficient:

it('should display general service info', () => {
let expectedMessage = '';
expectedMessage += `${chalk.yellow.underline('Service Information')}\n`;
expectedMessage += `${chalk.yellow('service:')} my-first\n`;
expectedMessage += `${chalk.yellow('stage:')} dev\n`;
expectedMessage += `${chalk.yellow('region:')} eu-west-1`;
expectedMessage += `\n${chalk.yellow('api keys:')}`;
expectedMessage += '\n None';
expectedMessage += `\n${chalk.yellow('endpoints:')}`;
expectedMessage += '\n None';
expectedMessage += `\n${chalk.yellow('functions:')}`;
expectedMessage += '\n None';
const message = awsInfo.display();
expect(consoleLogStub.calledOnce).to.equal(true);
expect(message).to.equal(expectedMessage);
});
).

@eahefnawy

Copy link
Copy Markdown
Contributor Author

Thanks @pmuens 🙌 ... I've definitely thought about that too, but it got too challenging for it to be worth it. The main challenge is that by default there are no breaking changes and so the CLI doesn't log anything. The only way to change that is in the code (not env var, not serverless.yml..etc). So adding that test would require changing the actual logic. Furthermore, the output is different on every release depending on the breaking changes. It's a manual step that we have to do to make sure it's accurate, which is why I added it to the release checklist.

Generally speaking, covering tests for CLI outputs is not that worthwhile and too hard to maintain, otherwise, we'd have to add tests for every error message we display too.

@pmuens

pmuens commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

@eahefnawy yes, I agree. Testing the CLI is hard and not always worth the effort.

I've pushed some convenience changes (so that you don't have to scroll to the end of the CLI file to add the breaking changes). Furthermore I've restructured the code a little bit and added tests so that all the different cases are captured by unit tests.

Feel free to merge if it's GTM from your side!

Comment thread lib/classes/CLI.test.js
expectedMessage += chalk.yellow(' - x is broken\n');
expectedMessage += chalk.yellow(' - y will be updated\n');
expectedMessage += '\n';
expectedMessage += chalk.yellow(' You can opt-out from these warnings by setting the "SLS_IGNORE_WARNING=*" environment variable.\n'); //eslint-disable-line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pmuens Really appreciate your dedication to test coverage and high quality code 🥇 , but I'm still worried about maintaining those kinda tests, especially the "expected messages" above. If we for some reason change an irrelevant character, those tests would fail and we'll need to spend considerable amount of time looking very closely at the message diff, while at the very end it doesn't really matter much. Doing that for every message we log would be hell, especially error messages.

But let's merge this anyway. It doesn't deserve anymore time.

Thanks @pmuens 🙌

@pmuens pmuens Feb 10, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I agree. checking everything in detail might be too detailed 👍 🙌

Maybe for future situations like this we can check that the error / warning message contains the Breaking change items etc. (and not the full message) so that we don't have to go through hell when we change the message itself 👹

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hehe I like that! 💯

@pmuens
pmuens merged commit 0a818af into master Feb 10, 2017
@pmuens
pmuens deleted the breaking-changes-warning branch February 10, 2017 14:31
@pmuens pmuens mentioned this pull request Mar 29, 2017
6 tasks
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.

2 participants