Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
73a0b6e
Set minimum ruby to 2.7 and minimum rubygems to 3.2.3
luke-hill Apr 5, 2024
3459e1e
Remove ruby 2.6 and 2.7 from workflows - Add in ruby 3.3
luke-hill Apr 5, 2024
cd768fe
Update target rubocop version
luke-hill Apr 5, 2024
d5c47c1
Update misc files
luke-hill Apr 5, 2024
9b421bb
Update to use latest CCK in testing
luke-hill Apr 5, 2024
12e3e94
Remove some gitignore files
luke-hill Apr 19, 2024
9d322bc
Spike of non-working code
luke-hill Apr 23, 2024
a186589
Spike of using both private and public methods
luke-hill Apr 23, 2024
e540d43
Compare / contrast the two ways of performing the new cck path reference
luke-hill Apr 23, 2024
d9fcb9a
Working example for iterative checks on each item
luke-hill Apr 23, 2024
e28745c
Use file exist to simplify code - Remove wildcards
luke-hill Apr 23, 2024
98ff9a1
Update minimum deps for rake / rspec
luke-hill Apr 25, 2024
4f793e4
Merge branch 'main' into refactor/gem_bump_bump
luke-hill Apr 25, 2024
15b961e
Fix up all gemspec cops
luke-hill Apr 25, 2024
6a4ff32
Move towards a spec support structure to remove any oddities flagged …
luke-hill Apr 25, 2024
e8e5c89
Remove duplicate dummy messages
luke-hill Apr 25, 2024
133b80b
Split up composiite dummy message class into individual items
luke-hill Apr 25, 2024
3da9e69
Remove top level leaked fake class for utils testing
luke-hill Apr 25, 2024
9a967c9
Fix up some minor simple offenses for utils spec
luke-hill Apr 25, 2024
941cbb1
Slight update to check rubocop works and then regenerate autogenconfig
luke-hill Apr 26, 2024
79df9e6
Bump rubocop performance and rubocop rake to latest. Slight bump to r…
luke-hill Apr 26, 2024
24c308a
Fix up issue whereby error was being rescued incorrectly and was bein…
luke-hill Apr 26, 2024
70b56d2
Tidy up serialization formatting
luke-hill Apr 26, 2024
9492ad2
Ignore line length cop as it's un-enforceable
luke-hill Apr 26, 2024
0d80d4d
Attempt to distinguish what are the actual objects in the acceptance …
luke-hill Apr 26, 2024
e4a67fc
Re-gen the autogen config using bundler to ensure correct version (Fo…
luke-hill Apr 26, 2024
ccda8a3
Set minimum ruby to 3.0
luke-hill May 3, 2024
4a89fee
Reduce line count of spec for acceptance as we just want a wrap/unwra…
luke-hill May 3, 2024
afbdeb0
Fix up typos and named subject issue in serialization spec
luke-hill May 3, 2024
f4f68b0
Fix up a couple of spec support Lint/MissingSuper calls
luke-hill May 3, 2024
c713902
Simplify deserialization protocol into just a single class method whi…
luke-hill May 3, 2024
61b2458
underscore as a method isn't used in the utils implementation
luke-hill May 3, 2024
b37a796
Remove underscore tests
luke-hill May 3, 2024
5c46127
Simplify Utils to just be extended as class methods
luke-hill May 3, 2024
f48e1b0
Utils aren't used in the deserialization protocol
luke-hill May 3, 2024
14907d5
Move all serialization into the message proper as it's just a single …
luke-hill May 3, 2024
9941d0e
Move the deserialization spec tests into message proper
luke-hill May 3, 2024
9988d7d
Remove utils class and place camelize inside the message proper
luke-hill May 3, 2024
7756ab1
Don't create an extra object
luke-hill May 3, 2024
4032c7e
Split id generator into individual class files
luke-hill May 3, 2024
f5103a7
AF: Style/SpecialGlobalVars
luke-hill May 3, 2024
abed109
Simplify serialization spec by not creating 10 different subjects
luke-hill May 7, 2024
313b6f3
AF: Gemspec/OrderedDependencies
luke-hill May 7, 2024
caa4818
AF: Layout/EmptyLineAfterMagicComment
luke-hill May 7, 2024
5927487
Partial fix for the Layout/FirstArrayElementIndentation cop offenses
luke-hill May 7, 2024
b89174c
AF: Layout/LeadingEmptyLines
luke-hill May 7, 2024
b816cb3
Re-generate todo file with May's marker - 50 offenses cleared with th…
luke-hill May 7, 2024
de5ad94
Fix rubocop error
luke-hill May 7, 2024
278e62b
Alter UUID test to just check for a securerandom uuid and simplify th…
luke-hill May 7, 2024
d1aa8e8
Alter incrementing spec to only have 1 assertion line
luke-hill May 7, 2024
57dc121
Move serialization into message model proper
luke-hill May 9, 2024
ce7d005
Fix up Layout cops after copying over serialization messages
luke-hill May 9, 2024
19eedc1
AF: Lint/ToJSON should allow optional discarded args
luke-hill May 9, 2024
cfa7dbe
In ruby 2.6+ #to_h permits a block assign so we can refine this code …
luke-hill May 9, 2024
715f737
Refine the compacting of the resultant hash in the message adhering t…
luke-hill May 9, 2024
a8db987
AF: Style/SlicingWithRange
luke-hill May 9, 2024
de6bf28
Update tests to remove redundant failing ones and fix up some legacy …
luke-hill May 9, 2024
bce5c98
Re-order and tidy up messages class
luke-hill May 14, 2024
49f16bc
Add super() call to each message generation - Should remedy Lint/Miss…
luke-hill May 14, 2024
87e6e60
Re-generate config
luke-hill May 14, 2024
d8b0d14
Fix up args to JSONSchema generation to use Ruby 3.0+ idioms
luke-hill May 16, 2024
14d3f78
Fix up the Trailing Whitespace cop by fixing a generation bug
luke-hill May 16, 2024
cd9848e
AF: Lint/AmbiguousOperatorPrecedence
luke-hill May 16, 2024
507619c
Fix up RSpec/DescribedClass issue with ndjson spec
luke-hill May 16, 2024
a710372
Partial fix of RSpec/ExampleLength
luke-hill May 16, 2024
86ebbc9
Alter the Enum generator enabling us to autofix Style/ClassAndModuleC…
luke-hill May 16, 2024
1e50779
AF: FrozenStringLiteral
luke-hill May 16, 2024
b1df726
Remove redundant spec
luke-hill May 16, 2024
f7aca69
Configure and permit AllowedNames to also include as a name and Excl…
luke-hill May 16, 2024
304a7f6
Disable Style/AccessorGrouping
luke-hill May 16, 2024
d620b0b
Fix up namespacing issues when migrating tests
luke-hill May 17, 2024
a7b32b0
Move some logic out into let/subject blocks
luke-hill May 17, 2024
3aad91d
Fix up auto-fix offenses in rubocop
luke-hill May 17, 2024
a6ee6e8
Remove frozen string literal pragma's whilst we haven't fixed up autogen
luke-hill May 17, 2024
f810d22
Add new requirements pending migration to one class per file logic li…
luke-hill May 23, 2024
7581d3d
Fix up line spacing in generic ruby file and begin to split file into…
luke-hill May 23, 2024
38beba7
Move all helpers to helpers namespace
luke-hill May 28, 2024
d6b85b0
Fix up tests and require path
luke-hill May 28, 2024
18a3389
Rename confusingly named make targets
luke-hill May 28, 2024
e40724e
Generate files in new way
luke-hill May 28, 2024
de1f552
Leave leakage item on dtos file for now as it will serve well when we…
luke-hill May 28, 2024
6826207
Add new generation logic to .generate-messages
luke-hill May 28, 2024
d631325
add new clean command
luke-hill May 28, 2024
aabef11
Add new filename checking for template
luke-hill May 28, 2024
32d4fd9
Alter generation to use snake cased names
luke-hill May 28, 2024
927810d
Re-generate files
luke-hill May 28, 2024
cf06db1
Remove extra line that's not needed
luke-hill May 28, 2024
e5ac6e7
Make inheritance from message simpler
luke-hill May 28, 2024
5fb3178
Alter enum generation to also make new unique files
luke-hill May 28, 2024
2b0934c
Add .from_h method to ruby.rb.erb template to begin process of removi…
luke-hill May 28, 2024
a4daceb
Add enum generation to the generator script
luke-hill May 28, 2024
1423648
Remove all trace to referencing the .dtos.rb file including using the…
luke-hill May 28, 2024
1688567
Remove all trace to referencing the .deserializers.rb file
luke-hill May 28, 2024
2d7706d
Fix up namespace for UUID
luke-hill May 28, 2024
2e69d5b
Require all new messages when requiring one message
luke-hill May 28, 2024
f8828a5
Only add comma after properties that aren't final
luke-hill May 28, 2024
214a182
Remove un-required requirement now we are recursively loading items in
luke-hill May 28, 2024
151d044
Re-generate messages using new templates
luke-hill May 28, 2024
1afa10e
Remove duplicate comma on the if/elsif/else statement
luke-hill May 28, 2024
de216f1
Add comma into correct spot in template
luke-hill May 29, 2024
4db2dde
Fixed mismatched comment style from template
luke-hill May 30, 2024
accb582
Fix frozen string literal pragmas in templates
luke-hill May 30, 2024
f9b4fbc
Enum template was assigning an un-needed index during iteration
luke-hill May 30, 2024
c0b4fa9
Re-generated messages
luke-hill May 30, 2024
63797bb
Re-generate TODO file after minor fixes in templates
luke-hill May 30, 2024
a9b85aa
AF: Style/StringConcatenation
luke-hill May 30, 2024
c15b80d
Manual fix for RSpec/ExampleLength
luke-hill May 30, 2024
e0e1b5a
AF: RSpec/DescribedClass£
luke-hill May 30, 2024
158521e
AF: Layout/SpaceInsideBlockBraces
luke-hill May 30, 2024
cf5b9fb
Merge branch 'main' into refactor/split_large_file
luke-hill May 31, 2024
42c39b6
Remove duplicate files missed by bad merge conflict
luke-hill May 31, 2024
3aae948
Re-generate TODO file owing to conflict clash
luke-hill May 31, 2024
8e3205a
Fix up RSpec/MultipleExpectations
luke-hill May 31, 2024
83c8be9
Disable ParameterLists cop as most messages will have 5+ properties
luke-hill May 31, 2024
3e8a550
Fix up RSpec/NestedGroups
luke-hill May 31, 2024
dd5e41b
Ignore method length for same reason as parameter lists
luke-hill May 31, 2024
c655f4c
AF: Layout/EmptyLineAfterGuardClause
luke-hill May 31, 2024
11f5eeb
Remove TODO file as we have < 10 offenses to fix now
luke-hill May 31, 2024
8b696d0
Ignore all generated files
luke-hill May 31, 2024
48f3c09
Switch from metric blanket overrides to generated code overrides
luke-hill May 31, 2024
12b575c
Only ignore Metrics and Layout/LineLength for generated messages
luke-hill May 31, 2024
903644a
Fix up line length offenses in message class proper
luke-hill May 31, 2024
0a84254
Fix up all remaining line length issues in the specs
luke-hill May 31, 2024
1bc39f0
Fix up LineLength offenses by moving extraction of message out to a p…
luke-hill May 31, 2024
f95d9f4
Update changelogs
luke-hill Jun 3, 2024
11a67cf
Slight update to some rubocop gems that don't affect signoff of ruboc…
luke-hill Jun 3, 2024
1ebcbc8
Accessor grouping should only be unenforceable in generated messages
luke-hill Jun 3, 2024
e611a6a
Update docs
luke-hill Jun 3, 2024
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- [Ruby] **Breaking change** Messages are now altered to be 1 message class per file ([#225](https://github.com/cucumber/messages/pull/225) [luke-hill](https://github.com/luke-hill))
- [Ruby] Updated minimum Ruby version to 3.0 ([#216](https://github.com/cucumber/messages/pull/216) [luke-hill](https://github.com/luke-hill))
- [Ruby] Use latest CCK conformance for signing off message releases ([#216](https://github.com/cucumber/messages/pull/216) [luke-hill](https://github.com/luke-hill))
- [Ruby] Tidied up around 80% of all of the rubocop `Layout` offenses (This included 2 minor alterations to the generator code) ([#217](https://github.com/cucumber/messages/pull/217) [luke-hill](https://github.com/luke-hill))
- [Ruby] Tidied up all remaining rubocop offenses (This included 2 minor alterations to the generator code) ([#217](https://github.com/cucumber/messages/pull/217) [#225](https://github.com/cucumber/messages/pull/225) [luke-hill](https://github.com/luke-hill))
- [Php] Permit both PHPUnit 10 and PHPUnit 11 ([#200](https://github.com/cucumber/messages/pull/200) [ciaranmcnulty](https://github.com/ciaranmcnulty))

### Fixed
Expand Down
23 changes: 11 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Some guidelines for making schema changes:
- Use the most appropriate data type
- Follow existing naming conventions (camelCase)
- Add new fields last to minimise impact on consuming code
- Probably don't add a new field as `required` - this will make the new code unable to read existing messages
- Don't add a new field as `required` - this will make the new code unable to read existing messages
- Ideally add a description to any new fields

If you need some advice, drop into the `#committers` channel on the [Cucumber Slack](https://cucumber.io/community#slack) and ask.
Expand All @@ -20,24 +20,23 @@ The code for various languages is generated from the JSON files. You can clean a
make clean-all generate-all
```

This requires various tooling to be installed on your computer, including Ruby and Node.js. If you're missing some of it, you might find it easier to run a Docker container that has everything:
Or you can alternative clean and generate code for just one language by cd'ing into that languages directory
and then running the following commands

```shell
docker run --volume $PWD:/app --user 1000 -it cucumber/cucumber-build:latest bash
cd ruby # Or another alternative
make clean generate
```

For Windows (Powershell):

```shell
docker run --volume ${PWD}:/app --user 1000 -it cucumber/cucumber-build:latest bash
```

You can then run the same command as noted previously.
This requires various tooling to be installed on your computer, including Ruby and Node.js.

### New files

If you're adding a new file to the `jsonschema` directory, you'll need to add a reference to it near the top of the `Makefile` at the root in order for it to be included in the code generation.
If you're adding a new file to the `jsonschema` directory, you'll need to add a reference to it near the top of the `Makefile`
at the root in order for it to be included in the code generation.

## Tests

Some of the language-specific directories contain some smoke tests to ensure (de)serialization, validation etc are working right. If you happen to change one of the messages that's constructed by these tests, you may need to update them. If you're not sure, raise a draft PR and see what happens in CI.
Some of the language-specific directories contain some smoke tests to ensure (de)serialization, validation etc
are working right. If you happen to change one of the messages that's constructed by these tests, you may
need to update them. If you're not sure, raise a draft PR and see what happens in CI.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Cucumber needs to produce results in a machine-readable format so that other too

![messages-stream.svg](messages-stream.svg)

Historically, Cucumber has done this with the `json` and `junit` formatters.
These formats have several shortcomings that are addressed by Cucumber Messages.
Historically, Cucumber did this with the `json` and `junit` formatters.
These formats however, have several shortcomings that are now addressed by using Cucumber Messages.

The `json` formatter is now in maintenance mode for these implementations, and Messages is the preferred standard.
See [utilities](#utilities) for a list of tools that may help with backward and forward compatibility
Expand All @@ -78,15 +78,14 @@ of results.

### Lack of a schema

The JSON report does not have a formal schema. This has led to slightly inconsistent implementations
The JSON reporter does not have a formal schema. This has led to slightly inconsistent implementations
of the JSON formatter in various Cucumber implementations. Consumers of the JSON format have
to anticipate and detect these inconsistencies and try to cope with them.

### Limited information

The `junit` XML format can only contain very limited information such as test case name and status.
While there isn't an official schema for JUnit XML, there are a few defacto ones around, and they
are very limited.
While there isn't an official schema for JUnit XML, there are a few defacto ones around which are very limited.

The `json` format represents the following information:

Expand Down
10 changes: 6 additions & 4 deletions jsonschema/scripts/templates/ruby.enum.rb.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<%- @enums.each do |enum| -%>
<%= underscore(enum[:name]) %>.rb
# frozen_string_literal: true

<% @enums.each do |enum| -%>
# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb]
module Cucumber
module Messages
class <%= enum[:name] %>
<%- enum[:values].each_with_index do |value, index| -%>
<%- enum[:values].each do |value| -%>
<%= enum_constant(value) %> = '<%= value %>'
<%- end -%>
end
end
end
<%= "\n" unless enum == @enums.last -%>
<%- end -%>
<% end -%>
39 changes: 33 additions & 6 deletions jsonschema/scripts/templates/ruby.rb.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'cucumber/messages/message'
<%- @schemas.each do |key, schema| -%>
<%= underscore(class_name(key)) %>.rb
# frozen_string_literal: true

# The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/jsonschema/scripts/codegen.rb]
#

module Cucumber
module Messages
<%- @schemas.each do |key, schema| %>
##
# Represents the <%= class_name(key) %> message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
##
<%= "#\n " if schema['description'] %><%= format_description(schema['description']) %>
class <%= class_name(key) %> < ::Cucumber::Messages::Message
class <%= class_name(key) %> < Message
<%- schema['properties'].each do |property_name, property| -%>
<%- if property['description'] -%>
##
Expand All @@ -30,7 +30,34 @@ module Cucumber
<%- end -%>
super()
end

##
# Returns a new <%= class_name(key) %> from the given hash.
# If the hash keys are camelCased, they are properly assigned to the
# corresponding snake_cased attributes.
#
# Cucumber::Messages::<%= class_name(key) %>.from_h(some_hash) # => #<Cucumber::Messages::<%= class_name(key) %>:0x... ...>
##
def self.from_h(hash)
return nil if hash.nil?

new(
<%-
schema['properties'].each do |property_name, property|
ref = property['$ref']
items_ref = property.dig('items', '$ref')
-%>
<%- final_key = property_name == schema['properties'].keys.last -%>
<%- comma = final_key ? '' : ',' -%>
<%= "#{underscore(property_name)}: " -%>
<%- if items_ref -%>hash[:<%= property_name -%>]&.map { |item| <%= class_name(items_ref) %>.from_h(item) }<%= comma %>
<%- elsif ref -%><%= class_name(ref) %>.from_h(hash[:<%= property_name %>])<%= comma %>
<%- else -%>hash[:<%= property_name %>]<%= comma %>
<%- end -%>
<%- end -%>
)
end
end
<%- end -%>
end
end
<% end -%>
40 changes: 0 additions & 40 deletions jsonschema/scripts/templates/ruby_deserializers.rb.erb

This file was deleted.

16 changes: 11 additions & 5 deletions ruby/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
inherit_from: .rubocop_todo.yml

inherit_mode:
merge:
- Exclude
Expand All @@ -17,9 +15,16 @@ AllCops:
Gemspec/RequireMFA:
Enabled: false

# Some long comments in the JSON Schema cause this to be un-enforceable
# Generated messages (including the Envelope) aren't tested by the Metrics department because they have many
# input properties for #initialize and .from_h which are generated 1-per-line. This renders most Metrics redundant
Metrics:
Exclude:
- lib/cucumber/messages/*.rb

# Long comments in the generated messages from the JSON Schemas cause this to be un-enforceable
Layout/LineLength:
Max: 1000
Exclude:
- lib/cucumber/messages/*.rb

Naming/MethodParameterName:
AllowedNames:
Expand All @@ -31,7 +36,8 @@ RSpec/MessageSpies:
# Because of the nature of large amounts of Accessors, we disable this cop
# This is because many of them will have custom documentation which are auto-generated from the jsonschema
Style/AccessorGrouping:
Enabled: false
Exclude:
- lib/cucumber/messages/*.rb

Style/Documentation:
Enabled: false
Expand Down
145 changes: 0 additions & 145 deletions ruby/.rubocop_todo.yml

This file was deleted.

Loading