Skip to content
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

[elixir] Convert proto-based messages to json schema based messages #29

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
902a012
[messages - elixir] create proof of concept writer for module generation
WannesFransen1994 Apr 14, 2022
0e3ca9b
[messages - elixir] remove unused dependencies in
WannesFransen1994 Apr 14, 2022
58a1342
Merge branch 'main' into messages-elixir-proto-to-jsonschema
WannesFransen1994 Apr 14, 2022
3977a94
[messages - elixir] remove unnecessary compile time struct dependency…
WannesFransen1994 Apr 14, 2022
0bc4b32
[messages-elixir + gherkin-elixir] resolve compile-time issues with n…
WannesFransen1994 May 13, 2022
d664e56
adjusted gherkin parser so that tests pass
WannesFransen1994 May 19, 2022
cbfa63c
[elixir] Makefile + circleci conf attempt
WannesFransen1994 May 20, 2022
0c32335
Merge branch 'main' into messages-elixir-proto-to-jsonschema
WannesFransen1994 May 20, 2022
9d15c6c
[elixir messages] manually copy json schema files (assuming that ther…
WannesFransen1994 May 23, 2022
5600630
[elixir] attempt to avoid rsync conflict
WannesFransen1994 May 23, 2022
7433c74
Merge branch 'main' into messages-elixir-proto-to-jsonschema
WannesFransen1994 May 23, 2022
438e201
Merge branch 'main' into messages-elixir-proto-to-jsonschema
aurelien-reeves Jun 17, 2022
9f86654
Merge remote-tracking branch 'origin/main' into messages-elixir-proto…
aurelien-reeves Aug 17, 2022
19946e7
Unignore generated messages
aurelien-reeves Aug 17, 2022
7ceaa9f
Update code generation and makefile to match new repository
aurelien-reeves Aug 17, 2022
fa49894
Add generated code to the repo
aurelien-reeves Aug 17, 2022
64f526d
Update test-elixir workflow
aurelien-reeves Aug 17, 2022
38f8684
Update root Makefile and test-codegen workflow
aurelien-reeves Aug 17, 2022
82045d7
Fix test-codegen/Set-up elixir job
aurelien-reeves Aug 17, 2022
d272709
Merge branch 'main' into messages-elixir-proto-to-jsonschema
mattwynne Sep 22, 2022
5f2b261
[elixir messages] changed codegen to ruby script + add test for messa…
WannesFransen1994 Oct 20, 2022
a73599a
[elixir] add elixir template
WannesFransen1994 Oct 20, 2022
eb650e7
[messages - elixir] fixed tests and generated code. Corrected makefil…
WannesFransen1994 Oct 27, 2022
637d157
resolve merge conflict
WannesFransen1994 Nov 17, 2022
70ad748
[elixir messages] - resolve elixir version workflow
WannesFransen1994 Nov 17, 2022
7445619
[elixir messages] - resolve elixir version workflow
WannesFransen1994 Nov 17, 2022
5319ab9
[elixir messages] resolve bug
WannesFransen1994 Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/test-codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ jobs:
- run: composer install
working-directory: php


- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: '22.2'
elixir-version: '1.10.x'

- name: Install Protoc
uses: arduino/setup-protoc@v1


- name: generate code for all languages
run: |
make clean-all
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ jobs:
mix deps.get
working-directory: elixir

- name: compile messages
run: MIX_ENV=prod mix protox.generate --multiple-files --output-path=lib/cucumber_messages/generated messages.proto
working-directory: elixir

- run: mix test
working-directory: elixir
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ schemas = \
./jsonschema/UndefinedParameterType.json \
./jsonschema/Envelope.json

languages = go java javascript perl php ruby
languages = go java javascript perl php ruby elixir

.DEFAULT_GOAL = help

Expand Down
32 changes: 13 additions & 19 deletions elixir/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
include default.mk
schemas = $(shell find ../jsonschema -name "*.json")

clean:
rm -rf _build deps .deps .tested
rm -rf lib/cucumber_messages/generated/*
.DEFAULT_GOAL = help

.deps: setup_mix_and_get_dependencies update_proto_file compile_messages revert_proto_file
touch .deps
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nWhere <target> is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

setup_mix_and_get_dependencies:
mix local.hex --force
mix deps.get
.PHONY: setup_mix_and_get_dependencies
generate: require .generate-messages ## Generate elixir code based on the schemas found in ../jsonschema and using `mix generate_json_structs` for the generation

update_proto_file: messages.proto
mv $< $<.bak
cat $<.bak | sed "s/package io.cucumber.messages/package cucumber_messages/" > $<
require: ## Check requirements for the code generation (elixir/mix is required)
@mix --version >/dev/null 2>&1 || (echo "ERROR: elixir/mix is required."; exit 1)

compile_messages:
MIX_ENV=prod mix protox.generate --multiple-files --output-path=lib/cucumber_messages/generated messages.proto
.PHONY: compile_messages
clean: ## Remove automatically generated files and related artifacts
rm -rf lib/cucumber_messages/generated/*

revert_proto_file: messages.proto.bak
mv messages.proto.bak messages.proto
.PHONY: revert_proto_file
.generate-messages: $(schemas) lib/cucumber_messages/mix/tasks/generate_json_structs.ex
mix local.hex --force
mix deps.get
mix generate_json_structs
79 changes: 0 additions & 79 deletions elixir/default.mk

This file was deleted.

1 change: 0 additions & 1 deletion elixir/lib/cucumber_message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ defmodule CucumberMessages do
"""
def convert_envelopes_to(envelopes, :ndjson) do
Enum.map(envelopes, &CucumberMessages.Writer.envelope_to_ndjson!/1)
|> Enum.map(&Jason.encode!(&1))
|> Enum.join("\n")
|> case do
"" -> ""
Expand Down
1 change: 0 additions & 1 deletion elixir/lib/cucumber_messages/generated/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/attachment.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Attachment do
defstruct [body: nil, content_encoding: nil, file_name: nil, media_type: nil, source: nil, test_case_started_id: nil, test_step_id: nil, url: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/duration.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Duration do
defstruct [nanos: nil, seconds: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/envelope.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Envelope do
defstruct [attachment: nil, gherkin_document: nil, hook: nil, meta: nil, parameter_type: nil, parse_error: nil, pickle: nil, source: nil, step_definition: nil, test_case: nil, test_case_finished: nil, test_case_started: nil, test_run_finished: nil, test_run_started: nil, test_step_finished: nil, test_step_started: nil, undefined_parameter_type: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/gherkin_document.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument do
defstruct [comments: [], feature: nil, uri: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Background do
defstruct [description: nil, id: nil, keyword: nil, location: nil, name: nil, steps: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Comment do
defstruct [location: nil, text: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.DataTable do
defstruct [location: nil, rows: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.DocString do
defstruct [content: nil, delimiter: nil, location: nil, media_type: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Examples do
defstruct [description: nil, id: nil, keyword: nil, location: nil, name: nil, table_body: [], table_header: nil, tags: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Feature do
defstruct [children: [], description: nil, keyword: nil, language: nil, location: nil, name: nil, tags: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.FeatureChild do
defstruct [background: nil, rule: nil, scenario: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Rule do
defstruct [children: [], description: nil, id: nil, keyword: nil, location: nil, name: nil, tags: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.RuleChild do
defstruct [background: nil, scenario: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Scenario do
defstruct [description: nil, examples: [], id: nil, keyword: nil, location: nil, name: nil, steps: [], tags: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Step do
defstruct [data_table: nil, doc_string: nil, id: nil, keyword: nil, keyword_type: nil, location: nil, text: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.TableCell do
defstruct [location: nil, value: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.TableRow do
defstruct [cells: [], id: nil, location: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.GherkinDocument.Tag do
defstruct [id: nil, location: nil, name: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/hook.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Hook do
defstruct [id: nil, name: nil, source_reference: nil, tag_expression: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/location.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Location do
defstruct [column: nil, line: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/meta.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Meta do
defstruct [ci: nil, cpu: nil, implementation: nil, os: nil, protocol_version: nil, runtime: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/meta_ci.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Meta.Ci do
defstruct [build_number: nil, git: nil, name: nil, url: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/meta_git.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Meta.Git do
defstruct [branch: nil, remote: nil, revision: nil, tag: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/meta_product.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Meta.Product do
defstruct [name: nil, version: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/parameter_type.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.ParameterType do
defstruct [id: nil, name: nil, prefer_for_regular_expression_match: nil, regular_expressions: [], use_for_snippets: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/parse_error.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.ParseError do
defstruct [message: nil, source: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/pickle.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle do
defstruct [ast_node_ids: [], id: nil, language: nil, name: nil, steps: [], tags: [], uri: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleDocString do
defstruct [content: nil, media_type: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/pickle_pickle_step.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleStep do
defstruct [argument: nil, ast_node_ids: [], id: nil, text: nil, type: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleStepArgument do
defstruct [data_table: nil, doc_string: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/pickle_pickle_table.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleTable do
defstruct [rows: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleTableCell do
defstruct [value: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleTableRow do
defstruct [cells: []]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/pickle_pickle_tag.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Pickle.PickleTag do
defstruct [ast_node_id: nil, name: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/source.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Source do
defstruct [data: nil, media_type: nil, uri: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/source_reference.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.SourceReference do
defstruct [java_method: nil, java_stack_trace_element: nil, location: nil, uri: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.SourceReference.JavaMethod do
defstruct [class_name: nil, method_name: nil, method_parameter_types: []]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.SourceReference.JavaStackTraceElement do
defstruct [class_name: nil, file_name: nil, method_name: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/step_definition.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.StepDefinition do
defstruct [id: nil, pattern: nil, source_reference: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.StepDefinition.StepDefinitionPattern do
defstruct [source: nil, type: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_case.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCase do
defstruct [id: nil, pickle_id: nil, test_steps: []]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_case_finished.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCaseFinished do
defstruct [test_case_started_id: nil, timestamp: nil, will_be_retried: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_case_group.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCase.Group do
defstruct [children: [], start: nil, value: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_case_started.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCaseStarted do
defstruct [attempt: nil, id: nil, test_case_id: nil, timestamp: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCase.StepMatchArgument do
defstruct [group: nil, parameter_type_name: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCase.StepMatchArgumentsList do
defstruct [step_match_arguments: []]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_case_test_step.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestCase.TestStep do
defstruct [hook_id: nil, id: nil, pickle_step_id: nil, step_definition_ids: [], step_match_arguments_lists: []]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_run_finished.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestRunFinished do
defstruct [message: nil, success: nil, timestamp: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_run_started.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestRunStarted do
defstruct [timestamp: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_step_finished.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestStepFinished do
defstruct [test_case_started_id: nil, test_step_id: nil, test_step_result: nil, timestamp: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestStepFinished.TestStepResult do
defstruct [duration: nil, message: nil, status: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/test_step_started.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.TestStepStarted do
defstruct [test_case_started_id: nil, test_step_id: nil, timestamp: nil]
end
3 changes: 3 additions & 0 deletions elixir/lib/cucumber_messages/generated/timestamp.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.Timestamp do
defstruct [nanos: nil, seconds: nil]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule CucumberMessages.UndefinedParameterType do
defstruct [expression: nil, name: nil]
end
Loading