Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Upgrade messages and gherkin to bring new 'jsonschema messages' #1544

Merged
merged 15 commits into from
Jul 9, 2021

Conversation

aurelien-reeves
Copy link
Contributor

No description provided.

@mattwynne
Copy link
Member

mattwynne commented May 21, 2021

@aslakhellesoy I hadn't noticed that the change to the messages library had changed to exposing the messages as hashes instead of objects. It strikes me that it might be better to use wrap the bare message hashes in POROs, to give us an isolation layer so we don't need to make sweeping changes like this. Classes would also make it easier to document the messages with RDoc, and make the message protocol a bit more discoverable - hashes don't give good error messages if you typo a field name.

It also might help prevent confusion like cucumber/common#1559.

What do you think? Was the decision to use hashes over objects just a pragmatic one to get something released, or was there some more intent behind it?

@aslakhellesoy
Copy link
Contributor

I like that suggestion @mattwynne. To make it a reality, someone would have to build a code generator for ruby, similar to the one we have for go and typescript.

The reason I went with hashes? It didn’t occur to me that we’d need classes. My main motivation for doing code generation have been:

  • TypeScript: type safety and default values in deserialisation
  • Go: Required for JSON output

@aslakhellesoy
Copy link
Contributor

There is additional complexity with classes. If you want to maintain backwards compatibility with the Ruby API, all attributes would have to be snake_case, but the JSON representation needs to be camelCase.

I’m not convinced adding classes is worth it for ruby messages, because there are so few libs depending on it (AFAIK).

@aurelien-reeves
Copy link
Contributor Author

I would be in favor of DTOs to bring a more consistent public API over time, and to be more ruby-friendly too.

Also, messages are consumed directly by formatters, so they may be used more than we could think of as I think custom formatters may be the first way to extend cucumber?

@mattwynne
Copy link
Member

I've created a ticket in the common repo about this: cucumber/common#1574

@luke-hill
Copy link
Contributor

@aurelien-reeves this might be a blocker on getting my PR complete (As I would need a patched version of messages to the new 19.0.3 (Not yet created). Which seems from this PR to require lots of changes.

@aurelien-reeves
Copy link
Contributor Author

@aurelien-reeves this might be a blocker on getting my PR complete (As I would need a patched version of messages to the new 19.0.3 (Not yet created). Which seems from this PR to require lots of changes.

In conjuction with cucumber-ruby-core and cucumber-ruby-wire, this PR is actually ready. If you execute the tests using cucumber/cucumber-ruby-core#219, they are passing.

So the question is:

  1. do we agree with releasing a cucumber-ruby with messages represented as plain ruby hashes with camelCase keys to release the fixes for rules asap?
  2. do we wait for messages with DTOs instead of hashes and delay fixes for rules for some time?
  3. do we fix Gherkin@18.1 which rely on messages@15 to release the fix for rules more quickly, but make us deploy a fix for a past version which we are not use to?

I must say that I don't really have a favorite. If we go for 2. waiting for messages to have a release with DTOs, I can organize myself to be super-focus on that next week to try releasing it as quickly as possible.

@luke-hill
Copy link
Contributor

My vote is for number1. But at the same time I'm now going to be out of action until basically next weeks meeting. So I don't necessarily want to push urgently for something.

At the same time it would be good to think about a timeline for getting my PR merged (As it enables a reasonable chunk of functionality, even though it's small). So ideally some time before end of june would be preferred.

@mattwynne
Copy link
Member

If we can get the DTOs done, most of the changes in this PR would not be necessary. I think it's probably better to delay merging this change until we have the DTOs done, to minimise churn in the code.

@aurelien-reeves aurelien-reeves marked this pull request as ready for review July 9, 2021 11:38
@aurelien-reeves
Copy link
Contributor Author

Once cucumber/cucumber-ruby-wire#44 is merged, we can come back to the use of cucumber-ruby-wire main branch.

@aurelien-reeves
Copy link
Contributor Author

I have to merge this in order to be able to release wire because wire depends on the main github branch.

But I won't release cucumber-ruby without proper review

@aurelien-reeves aurelien-reeves merged commit 2a20bfd into main Jul 9, 2021
@luke-hill luke-hill deleted the upgrade-messages-and-gherkin branch July 14, 2021 08:00
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants