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

fix: forceNewDeployment to be a boolean #140

Merged
merged 3 commits into from
Nov 12, 2020

Conversation

paragbhingre
Copy link
Contributor

@paragbhingre paragbhingre commented Nov 10, 2020

This PR fix the Issue #133

Description of changes:
This issue was occurring due to incorrect data type of the forceNewDeployment parameter.
In order to fix this issue need to type caste the value of the forceNewDeployment parameter from string to boolean.

@paragbhingre paragbhingre force-pushed the forceNewDeploymentIssueFinal branch from 3457c02 to de201af Compare November 11, 2020 18:21
index.js Outdated

const forceNewDeployInput = core.getInput('force-new-deployment', { required: false })
Copy link
Contributor

Choose a reason for hiding this comment

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

this line appears to be missing a terminal ;

index.test.js Outdated
@@ -755,7 +755,7 @@ describe('Deploy to ECS', () => {
cluster: 'cluster-789',
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: true
forceNewDeployment: false
Copy link
Contributor

Choose a reason for hiding this comment

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

the name of this test is force new deployment, but you're giving it a value of false (shouldn't this be false by default/wouldn't you want to test true?)

index.js Outdated

const forceNewDeployInput = core.getInput('force-new-deployment', { required: false })
const forceNewDeployment = forceNewDeployInput != undefined && forceNewDeployInput.toLocaleLowerCase === "true" ? true : false;
Copy link
Contributor

@piradeepk piradeepk Nov 11, 2020

Choose a reason for hiding this comment

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

nit since your conditional returns a boolean, do you need to explicitly define ? true : false?

index.js Outdated

const forceNewDeployInput = core.getInput('force-new-deployment', { required: false })
const forceNewDeployment = forceNewDeployInput != undefined && forceNewDeployInput.toLocaleLowerCase === "true" ? true : false;
Copy link
Contributor

@allisaurus allisaurus Nov 11, 2020

Choose a reason for hiding this comment

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

let's use .toLowerCase() instead, since we're not passing in a locale value

Copy link
Contributor

@allisaurus allisaurus Nov 11, 2020

Choose a reason for hiding this comment

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

also, nit: I'd prefer we wrap the 2 conditions of the ternary operator in parenthesis to make it clear they're being evaluated together to determine the return condition EDIT: @piradeepk 's suggestion is better

index.test.js Outdated
@@ -755,7 +755,7 @@ describe('Deploy to ECS', () => {
cluster: 'cluster-789',
service: 'service-456',
taskDefinition: 'task:def:arn',
forceNewDeployment: true
forceNewDeployment: false
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition is not correct - this test is meant to test the success of passing in forceNewDeployment, so we would expect ecs:update-service to be called with this param set as true. If this is not occurring, either the setup of the test is wrong or the change is not behaving as we expect.

index.js Outdated

const forceNewDeployInput = core.getInput('force-new-deployment', { required: false })
const forceNewDeployment = forceNewDeployInput != undefined && forceNewDeployInput.toLocaleLowerCase === "true" ? true : false;
Copy link
Contributor

@allisaurus allisaurus Nov 11, 2020

Choose a reason for hiding this comment

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

also, nit: I'd prefer we wrap the 2 conditions of the ternary operator in parenthesis to make it clear they're being evaluated together to determine the return condition EDIT: @piradeepk 's suggestion is better


const forceNewDeployInput = core.getInput('force-new-deployment', { required: false });
const forceNewDeployment = forceNewDeployInput != undefined && (forceNewDeployInput.toLowerCase === 'true' || forceNewDeployInput);
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why you're adding the || forceNewDeployInput as a condition here?

Copy link
Contributor Author

@paragbhingre paragbhingre Nov 12, 2020

Choose a reason for hiding this comment

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

forceNewDeployInput was coming as a string which was the main issue that we solved with the following condition forceNewDeployInput != undefined && forceNewDeployInput.toLowerCase === 'true' but the test case sends an actual boolean value which was not taken care by the above condition.
Now, we have added extra condition of || forceNewDeployInput that takes care of the boolean value of the forceNewDeploy as well.
How does that sound to you @piradeepk ?

Copy link
Contributor

@piradeepk piradeepk left a comment

Choose a reason for hiding this comment

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

Ship it! 💯 Thanks for fixing this so quickly @paragbhingre!

@mergify mergify bot merged commit 9407da9 into aws-actions:master Nov 12, 2020
@ltamrazov
Copy link

hi, thank you for this fix!

@piradeepk When can we expect a release with this revision?

Thank you!

s3cube pushed a commit that referenced this pull request Jul 16, 2024
Bumps [jest](https://github.com/facebook/jest) from 27.4.2 to 27.4.3.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](jestjs/jest@v27.4.2...v27.4.3)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

4 participants