Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
# TODO: Wait for supporting Ruby 3.0 in simplecov-cobertura.
# See https://github.com/dashingrocket/simplecov-cobertura/pull/16
# ruby: [ 2.5, 2.6, 2.7, 3.0 ]
ruby: [ 2.5, 2.6, 2.7 ]
ruby: [ '3.0', '3.1', '3.2', '3.3' ]
exclude:
- { os: macos-latest, ruby: '2.5' }
Copy link
Contributor Author

@hiraokashi hiraokashi Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macos-latestの2.5はもうサポートされていなかったので、
excludeを使ってみようとすると、Expected — Waiting for status to be reported なってしまいCIが
終わらない。

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch Protection Rule で、Status checks that are required からも消す必要があります(わかりづらいですよね... 自分も前にハマりました)

https://github.com/wantedly/pb-serializer/settings/branch_protection_rules/15047227

CleanShot 2025-09-11 at 17 37 53@2x

Copy link
Member

@stomk stomk Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI で動かしている Ruby のバージョン、[ 2.5, 2.6, 2.7 ] だと古すぎるので、3.0 以降とかにしてしまっていいと思いますね。
gemspec にある Rails (activerecord)のバージョン指定が、rails_versions = [">= 5.2", "< 6.1"] になっているので、Rails バージョンも一緒に上げてしまいたいですね。

差分多くなりそうなので、別PRでやりましょう。

runs-on: ${{ matrix.os }}

steps:
Expand Down
6 changes: 3 additions & 3 deletions lib/pb/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class Configuration
# @return [Logger]
attr_accessor :logger
# @!attribute [r] missing_field_behavior
# @return [:raise, :warn, :ignore] default: `:raise`
# @return [:raise, :warn, :ignore] default: `:ignore`
attr_reader :missing_field_behavior

def initialize
self.missing_field_behavior = :raise
self.missing_field_behavior = :ignore
self.logger = Logger.new(STDOUT)
end

Expand Down Expand Up @@ -70,7 +70,7 @@ def build_default_mask(descriptor)
case fd.type
when :message
case fd.submsg_name
when "google.protobuf.Timestamp",
when "google.protobuf.Timestamp",
"google.protobuf.StringValue",
"google.protobuf.Int32Value" ,
"google.protobuf.Int64Value" ,
Expand Down
5 changes: 3 additions & 2 deletions pb-serializer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "0.67.2" # for onkcop
spec.add_development_dependency "sqlite3", "~> 1.4"
spec.add_development_dependency "simplecov", "~> 0.18.5"
spec.add_development_dependency "simplecov-cobertura", "~> 1.3"
spec.add_development_dependency "simplecov", "~> 0.19"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Gemspec/OrderedDependencies: Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency simplecov should appear before sqlite3.

spec.add_development_dependency "simplecov-cobertura", "~> 3.1"
spec.add_development_dependency "concurrent-ruby", "1.3.4"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Gemspec/OrderedDependencies: Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency concurrent-ruby should appear before simplecov-cobertura.

end
25 changes: 24 additions & 1 deletion spec/examples/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
allow(Pb::Serializer).to receive(:configuration).and_return(config)

Pb::Serializer.configure do |c|
c.missing_field_behavior = missing_field_behavior
c.missing_field_behavior = missing_field_behavior if missing_field_behavior
c.logger = Logger.new(log_buffer)
end
end
Expand Down Expand Up @@ -72,6 +72,29 @@
it { expect(log_buffer.string).to be_empty }
it { is_expected.to be_a TestFixture::Simple::Message }
end

context 'when missing_field_behavior is not configured (default behavior)' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

before do
# Reset configuration to test default behavior
Pb::Serializer.instance_variable_set(:@configuraiton, nil)
allow(Pb::Serializer).to receive(:configuration).and_call_original

# Don't configure missing_field_behavior to test default
Pb::Serializer.configure do |c|
c.logger = Logger.new(log_buffer)
end
end

# Override the parent's before block to avoid setting missing_field_behavior
let(:missing_field_behavior) { nil }

it 'uses default value :ignore' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

expect(Pb::Serializer.configuration.missing_field_behavior).to eq(:ignore)
end

it { expect(log_buffer.string).to be_empty }
it { is_expected.to be_a TestFixture::Simple::Message }
end
end

it 'raises when set invalid param to missing_field_behavior config' do
Expand Down