-
Notifications
You must be signed in to change notification settings - Fork 240
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. #159
Conversation
index.js
Outdated
@@ -224,7 +224,7 @@ async function run() { | |||
} | |||
|
|||
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || false; | |||
const forceNewDeployment = forceNewDeployInput != undefined && (forceNewDeployInput.toLowerCase === 'true' || forceNewDeployInput); | |||
const forceNewDeployment = forceNewDeployInput != undefined && (forceNewDeployInput.toLowerCase() === 'true' || forceNewDeployInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I'd keep it simple and only accept boolean values here. This is what AWS SDK does and would be consistent with wait-for-service-stability param management. If a non boolean value is used, the AWS SDK validation will fail in meaningful way.
What do you think ?
const forceNewDeployment = forceNewDeployInput != undefined && (forceNewDeployInput.toLowerCase() === 'true' || forceNewDeployInput); | |
const forceNewDeployment = core.getInput('force-new-deployment', { required: false }) || false |
index.js
Outdated
@@ -224,7 +224,7 @@ async function run() { | |||
} | |||
|
|||
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || false; | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yehuda-elementryx Thank you for fixing this issue, could you please try switching the conditions like
( forceNewDeployInput || forceNewDeployInput.toLowerCase() === 'true' ) and see if the build succeeds?
I'm neither a JS ninja nor a fan 😆 but this should work. We would accept every string values though Is it really wortwhile to add that That said, thanks again for looking into this @yehuda-elementryx |
761c9c8
to
c36a5f7
Compare
Hi all, apparently I hadn't packaged the code in the previous pull request. cleaned it up slightly, fixed failing unit tests and pushed. Should be good to go now. Tested from a separate repo to ensure everything was working as expected. |
Github actions and boolean properties don't play nicely together. Take a look at this: actions/toolkit#361 |
@yehudacohen I looked at your code and your input.test.js file also sends only string values. I'm still wondering how your code will take care of boolean values? When I tried running your code, my tests fail as I send actual boolean instead of string. |
@paragbhingre there are no boolean values that can be returned from the Per that issue, all boolean values will be returned as strings. |
@@ -388,8 +388,8 @@ async function run() { | |||
waitForMinutes = MAX_WAIT_MINUTES; | |||
} | |||
|
|||
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || false; | |||
const forceNewDeployment = forceNewDeployInput != undefined && (forceNewDeployInput.toLowerCase === 'true' || forceNewDeployInput); | |||
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false }) || 'false'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need || 'false'
condition? Can't we just have the same logic as it is done for the wait-for-service-stability parameter?
const forceNewDeployInput = core.getInput('force-new-deployment', { required: false });
const forceNewDeployment = forceNewDeployInput.toLowerCase() === 'true';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it's not necessary, @paragbhingre , but I find it easier to read. This is because core.getInput('force-new-deployment', { required: false})
returns an empty string if it's not defined. To a reader who isn't familiar with the API, this makes sure they understand that if it isn't defined, the response should still be handled as a string rather than as an undefined
or null
value.
If you need it removed to merge the PR I'll remove it, but I find an explicit string value of 'false'
cleaner than an expectation that the core.getInput()
function returns an empty string when the input is not provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yehudacohen Great. I guess that extra condition works for me. Thank you for fixing the issue.
Thanks for the clarification @yehudacohen. I just have one last question that why do we have
Thank you for your clarification @yehudacohen, I just have one last question that I have asked in the above comment. |
Bumps [eslint](https://github.com/eslint/eslint) from 8.11.0 to 8.12.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v8.11.0...v8.12.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
*Issue #
Fixes: #157
Description of changes:
This issue was occurring due to incorrect data type of the forceNewDeployment parameter which got fixed by changing adding extra checks.