-
Notifications
You must be signed in to change notification settings - Fork 47
Migrate from Moment to Luxon #417
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
Migrate from Moment to Luxon #417
Conversation
1a4c75f
to
ee4df3f
Compare
thanks for doing this so fast - we'll get it reviewed asap! |
Hi - thanks for this - swapping out the libraries look good, we've ended up making some changes to the IF on However, when we checkout this branch and run the |
@jmcook1186 hmm, strange. I get
running
I assume there's no automated test for this? All the unit tests pass too. Is there a way to trigger the PR in CI/CD? I'll resolve the conflicts now anyway and then we can see what's going on. |
ee4df3f
to
50ed8c3
Compare
I've now rebased @jmcook1186 and now I get the same behaviour as you. There's some strange interplay between whether padding is necessary, and date formatting being passed in for start-time - all the tests use ISO format (which is why they pass), but when loaded from YAML it comes as I don't quite get all the interplay yet as to why it worked based off 477be28 but doesn't now. I'll have a further dig when I get a moment. |
Hi again - I found some time to look into this and push some fixes - my branch is now processing the manifest file correctly and passing most (not yet all) of the unit tests. I didn't quite get time to finish this off - hoping to get back to it on Monday. My branch is here for reference https://github.com/Green-Software-Foundation/if/tree/luxon-fixes Planning to finish this off on Monday morning, but happy to back off if you want to work on it more. If I don't hear otherwise I'll PR into your branch, and then you can review it, add anything else you like and PR from your branch into |
@jmcook1186 I’m confused - are you saying tests are failing on this branch on your machine? They all passed for me both before & after the rebase, the issues with the manual integration test not withstanding. Is there some other suite of tests not picked up by just ‘npm run test’? Sorry for the runaround, definitely didn't intend to submit something that you're then having to fix up just to get tests passing! Is there a plan to get CI/CD up and running on this repo? I could look to set something up if useful. At least as a new contributor it would have been helpful to have that to be sure my code was at least passing all the expected tests in a controlled environment? |
oh.. sorry if i've interfered where it wasn't necessary! I may have misunderstood the status of the PR. we basically just need to see that the plugin works when invoked from a manifest file, i.e.
should generate the expected output data, while also all the unit tests pass. When I checked out the PR I could get the unit tests passing but not the integration. Then when I got the integration to work, the unit tests all failed. We don't have formal tests outside |
@jmcook1186 gotcha and definitely not interference on your part 😀 just wanted to be clear where I’d gone awry! I’ll take a look at your commits and getting the integration test passing tomorrow and see how it goes, unless it’s blocking other changes in which case feel free to push ahead (end of day here as I’m in Sydney) |
This is prior to replacing moment with luxon. * when dates are invalid, we have relatively undefined behaviour - so documenting this * when timestamps are in another timezone, outputs are always converted to UTC Signed-off-by: James Crowley <[email protected]>
This is mostly a simple translation with a few notes: * momentRange.range and fromDateTimes are both "Inclusive of the start but not the end.". However, when operating on these date time intervals, 'by' includes the end, but 'splitBy' does not * behaviour when dates are invalid continue to be somewhat undefined, until we decide what is preferred Signed-off-by: James Crowley <[email protected]>
Signed-off-by: James Crowley <[email protected]>
Signed-off-by: James Crowley <[email protected]>
d48dd4a
to
b47c182
Compare
Signed-off-by: James Crowley <[email protected]>
b47c182
to
bd1eab6
Compare
Tests passed strings, but the real CLI code path would pass a Date object - unless YAML parser fails to identify as a date. Signed-off-by: James Crowley <[email protected]>
bd1eab6
to
1bd222b
Compare
@jmcook1186 the issues stem from how dates are passed into time-sync. The tests pass strings, in ISO format. When running from the CLI and parsing YAML, we get a JS Date object (when it's a valid date - but it might be a string if the YAML parser doesn't identify it as a date) For now I've made this handle both ISO strings and date objects. Please see the last two commits.
|
Hi - awesome, thank you! The expectation is that timestamps will be passed in as ISO 8061 strings. This should always be the case, so yes, I agree we can validate this outside of the time-sync model. Let's hold off on altering the ModelParams definition for now, as we are doing some substantial refactoring int he background and will likely handle this as part of that. |
@jmcook1186 ok 👍 Just let me know if you need/want anything else on this PR. If you like, I can follow up with a separate PR to consolidate the validation and possibly disable the auto parsing done by the YAML library so we can parse to a tighter spec. |
Signed-off-by: Joseph Cook <[email protected]>
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 looks great - all tests passing and manifest files being processed as expected.
Thanks a lot for your work on this - we appreciate it!
I added a commit to resolve merge conflicts in package.json.
Closes #408
Types of changes
A description of the changes proposed in the Pull Request
This PR removes the moment and moment-range dependency, and replaces the implementation with luxon. This is mostly a simple translation with a few notes:
Some items to discuss:
Let me know any thoughts/concerns.