-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
[messages - elixir] Convert proto-based messages to json schema based messages #1952
Conversation
…. Just forward to default json encoder
…ew messages. Still runtime issues considering some struct values are by default nil instead of empty list
Attempted a makefile adjustment, but seems that there's a problem with the messages generation. (based on the log)
|
…e's no longer a "synchronization" script in place)
Not that familiar with the whole monorepo build, but I've managed to make it work with adjusting the Makefile. Would love some pointers / reviews on the integration, specifically for
|
alias CucumberMessages.GherkinDocument.Feature.TableRow.TableCell, as: TableCellMessage | ||
alias CucumberMessages.GherkinDocument.Tag, as: MessageTag | ||
alias CucumberMessages.GherkinDocument.Scenario, as: MessageScenario | ||
alias CucumberMessages.GherkinDocument.Step, as: StepMessage |
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.
@WannesFransen1994 is this document manually maintained? I see an inconsistency here: StepMessage
where all the others are called Message*
?
@@ -58,7 +58,15 @@ defmodule CucumberGherkin.AstBuilder do | |||
Comment -> | |||
loc = Token.get_location(token) | |||
comment_message = %CommentMessage{location: loc, text: token.line.content} | |||
# TODO: Normally your struct should default to an empty list instead of nil. | |||
# Due to the limited converter in the messages library, we make a case clause and "catch" this unexpected `nil` value. |
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.
Is there an option to make the converter smarter? It's nice not to have to maintain this workaround "forever".
# case feature_message_acc.children do | ||
# nil -> %{feature_message_acc | children: [child]} | ||
# list -> %{feature_message_acc | children: list ++ [child]} | ||
# end |
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 actually not seeing the case statement; I'm not all that great at elixir, but the code you describe really isn't there?
alias CucumberMessages.GherkinDocument.Feature.TableRow, as: TableRowMessage | ||
alias CucumberMessages.GherkinDocument.Scenario, as: ScenarioMessage | ||
alias CucumberMessages.GherkinDocument.Step, as: StepMessage | ||
alias CucumberMessages.GherkinDocument.TableRow, as: TableRowMessage |
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.
These are inconsistent with ast_builder.ex
where you use Message
as a prefix. I think it's easier to understand the code base if you stick to the same naming rules. Or is there a specific reason to deviate here?
|
||
# {:scenario, s} -> | ||
# compile_scenario(m_acc, s, :feature_backgr_steps) | ||
# end |
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.
What's the value of this comment block? It looks like it's preserving the old code, but once we're moved over, we have the old code in Git for historic reference. No need to keep a copy?
rm -rf lib/cucumber_messages/generated/* | ||
|
||
.deps: setup_mix_and_get_dependencies update_proto_file compile_messages revert_proto_file | ||
# .deps: setup_mix_and_get_dependencies update_proto_file compile_messages revert_proto_file |
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.
Remnant can be removed?
cat $<.bak | sed "s/package io.cucumber.messages/package cucumber_messages/" > $< | ||
# update_proto_file: messages.proto | ||
# mv $< $<.bak | ||
# cat $<.bak | sed "s/package io.cucumber.messages/package cucumber_messages/" > $< |
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.
Remnant can be removed?
.PHONY: revert_proto_file | ||
# revert_proto_file: messages.proto.bak | ||
# mv messages.proto.bak messages.proto | ||
# .PHONY: revert_proto_file |
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.
Remnant can be removed?
# metadata = %{definitions: nil, full_decoded: decoded, modules: [], parent: nil} | ||
# list_of_modules = create_moduledata_structs(metadata, decoded) | ||
# textual_modules = output_module(list_of_modules, []) | ||
# write_files(textual_modules) |
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.
Remnant that can be removed?
# case create_moduledata_structs(empty_metadata, {name, child_member}) do | ||
# %ModuleData{} = submodule -> submodule | ||
# other -> raise "unexpected" | ||
# end |
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.
Was this a remnant?
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.
We pair today with @WannesFransen1994 to review the PR.
We noticed the following:
- Please join the generated code for messages as part of the repo
- We usually use the CCK as part of the messages high-level validation to make sure they serialize and deserialize as expected (you can take inspiration from ruby, perl, php, java or js implementation for that)
- If you want to comply with request from Erik, you can copy the good/bad test data using make but keeping those ignored in the repo
Beside that: great job @WannesFransen1994! 👍Thanks a lot!
# update_proto_file: messages.proto | ||
# mv $< $<.bak | ||
# cat $<.bak | sed "s/package io.cucumber.messages/package cucumber_messages/" > $< |
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.
# update_proto_file: messages.proto | |
# mv $< $<.bak | |
# cat $<.bak | sed "s/package io.cucumber.messages/package cucumber_messages/" > $< |
PR now available in the dedicated repo here: cucumber/messages#29 |
Summary
Remove protobuf dependency and create modules based on json schema (manual parser). No validation of data in messages, that's done through acceptance testing.
Checklist: