[messages - elixir] Convert proto-based messages to json schema based messages#1952
[messages - elixir] Convert proto-based messages to json schema based messages#1952WannesFransen1994 wants to merge 14 commits into
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.
@WannesFransen1994 is this document manually maintained? I see an inconsistency here: StepMessage where all the others are called Message*?
| 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.
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.
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.
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.
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.
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.
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.
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.
Remnant that can be removed?
| # case create_moduledata_structs(empty_metadata, {name, child_member}) do | ||
| # %ModuleData{} = submodule -> submodule | ||
| # other -> raise "unexpected" | ||
| # end |
aurelien-reeves
left a comment
There was a problem hiding this comment.
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.
| # 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: