-
-
Notifications
You must be signed in to change notification settings - Fork 25
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(#596) fix issue with semver validation for latest versions #597
Conversation
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.
Can you please add a test to capture this scenario clearly?
@@ -39,7 +39,7 @@ async function augmentDeclarativeWithNoolsBoilerplate(appSettings) { | |||
} | |||
|
|||
const actualCoreVersion = await getValidApiVersion(appSettings); | |||
const addNoolsBoilerplate = semver.lt(actualCoreVersion, '4.2.0-dev'); | |||
const addNoolsBoilerplate = actualCoreVersion && semver.lt(actualCoreVersion, '4.2.0-dev'); |
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.
I'm unclear on when actualCoreVersion
would be falsy... Why?
It may not be safe to default to nools... for example: a partner using 3rd party library which isn't nools compatible upgrades to a cht-core verison with non-semver version. Now their config is broken when they redeploy...
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.
Even though coerce tries to parse versions correctly, it'd be falsy when a custom version like tag number or branch number is being used on production. What do you suggest in this case to avoid scenarios like you mentioned? One option is to use base_Version
which is only available in latest CHT versions and ensure this doesn't get changed. This issue was also caused because the way version was written was changed.
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.
Can you share the specific tags you're having trouble with please? I'm testing with coerce and not clear on what tags are failing. Maybe capture them in the test scenarios if they are special considerations that we need to think through?
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.
This issue fix was needed for regular CHT versions as well like 4.5.0.6922454971
, hence I introduced coerce for that fix. actualCoreVersion
could still be falsy if production instances are running on versions like this (private). We won't need falsy check after introducing coerce. I don't see recent instances with unusual versioning though. I am not sure what coreVersion
would've returned for particular versions like that since api/deploy-info
endpoint has changed frequently.
@@ -20,6 +20,10 @@ describe('upload-app-settings', () => { | |||
|
|||
// case when testing on dev | |||
{ coreVersion: '4.2.0-dev.1682192676689', isDeclarative: true, expectNools: false }, | |||
// https://github.com/medic/cht-conf/issues/596 | |||
{ coreVersion: '4.5.0.6922454971', isDeclarative: false, expectNools: 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.
can you add the case for isDeclarative: true, expectNools: false
with this weird build version? isn't that the case that crashed for you?
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.
It was failing with version 4.5.0.6922454971
, if we pass weird build version, it'd faill.
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.
If I revert your changes in src
, all these tests are still passing... This means that you have not sufficiently captured the scenario you care about in these tests.
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.
That's right, because the fix was on getValidApiVersion()
and in this example, we're mocking what getValidApiVersion() returns. Previously it was failing on getValidApiVersion() and failing upload-app-settings
. I can add unit test for getApiVersion()
method if that makes it more useful.
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.
This isn't a super obvious requirement, so if you want it to not break in the future - it is typically nice to have a test which captures the requirement. Ya - that can be a unit test for getApiVersion
or an integration test here (change what is mocked to be deeper).
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.
I have nothing to add on top of what Kenn has said! Approving this preemptively so you can merge as soon as Kenn's concerns are resolved!
Hi @kennsippell , I've added few more scenarios for unit test. The original inetnt of this issue was to fix the scenarios where valid CHT core versions like 4.5.0.xxxx were not being parsed properly and an error was being thrown. Before this fix, if you were running Even after adding coerce, I added check on if const addNoolsBoilerplate = actualCoreVersion && semver.lt(actualCoreVersion, '4.2.0-dev'); However, if you think we should still crash the app and prevent users from running If you're looking for previous isntances where CHT version was not a valid semver, you can see these on this (pvt) scraper output. |
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.
Leave it to you to decide whether to add the last automated tests.
@@ -20,6 +20,10 @@ describe('upload-app-settings', () => { | |||
|
|||
// case when testing on dev | |||
{ coreVersion: '4.2.0-dev.1682192676689', isDeclarative: true, expectNools: false }, | |||
// https://github.com/medic/cht-conf/issues/596 | |||
{ coreVersion: '4.5.0.6922454971', isDeclarative: false, expectNools: 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.
This isn't a super obvious requirement, so if you want it to not break in the future - it is typically nice to have a test which captures the requirement. Ya - that can be a unit test for getApiVersion
or an integration test here (change what is mocked to be deeper).
Oops, missed a colon again while merging, sending another PR to release @kennsippell , @jkuester |
🎉 This PR is included in version 3.21.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
[description]
#596
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.