Skip to content

Commit

Permalink
Technical/Update gem development dependencies (#154)
Browse files Browse the repository at this point in the history
* Updated gem development dependencies
* Updated simplecov/CircleCi config
* Fix coverage issues, refactor tests
* Updated gem version, changelog, documentation
  • Loading branch information
bestwebua authored May 13, 2021
1 parent 6643121 commit 363736d
Show file tree
Hide file tree
Showing 19 changed files with 175 additions and 101 deletions.
56 changes: 37 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ version: 2.1
defaults: &defaults
working_directory: ~/truemail
docker:
- image: circleci/ruby:2.5.0-node
- image: cimg/ruby:<< parameters.ruby-version >>
environment:
CC_TEST_REPORTER_ID: 693272a1328521f6f7c09d7ffd419b21c00410da26e98e94c687fdd38b26e2cb

orbs:
ruby: circleci/[email protected].2
ruby: circleci/[email protected].3

references:
install_bundler: &install_bundler
run:
name: Installing Bundler
command: gem i bundler -v $(tail -1 Gemfile.lock | tr -d ' ')

restore_bundle_cache: &restore_bundle_cache
restore_cache:
keys:
Expand All @@ -29,63 +34,71 @@ references:

install_codeclimate_reporter: &install_codeclimate_reporter
run:
name: Install Code Climate Test Reporter
name: Installing CodeClimate test reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
jobs:
linters:
linters-ruby:
parameters:
ruby-version:
type: string

<<: *defaults

steps:
- checkout

- <<: *install_bundler
- <<: *restore_bundle_cache
- <<: *bundle_install
- <<: *save_bundle_cache

- run:
name: Running overcommit
name: Running Overcommit
command: |
bundle exec overcommit -s
SKIP=AuthorEmail,AuthorName bundle exec overcommit -r
tests:
tests-ruby:
parameters:
ruby-version:
type: string

<<: *defaults

steps:
- checkout

- <<: *install_bundler
- <<: *restore_bundle_cache
- <<: *bundle_install
- <<: *save_bundle_cache
- <<: *install_codeclimate_reporter

- run:
name: Running tests
name: Running RSpec
command: |
mkdir /tmp/test-results
./cc-test-reporter before-build
bundle exec rspec
- run:
name: Code Climate Test Coverage
name: Creating CodeClimate test coverage report
command: |
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- store_test_results:
path: /tmp/test-results

- store_artifacts:
path: /tmp/test-results
destination: test-results
name: Saving Simplecov coverage artifacts
path: ~/truemail/coverage
destination: coverage

- deploy:
name: Uploading CodeClimate test coverage report
command: |
./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
compatibility-with-ruby:
compatibility-ruby:
parameters:
ruby-version:
type: string
Expand All @@ -94,7 +107,6 @@ jobs:
steps:
- checkout
- ruby/install-deps:
bundler-version: '1.16.6'
with-cache: false
path: './vendor/custom_bundle'
- run:
Expand All @@ -104,9 +116,15 @@ jobs:
workflows:
build_and_test:
jobs:
- linters
- tests
- compatibility-with-ruby:
- linters-ruby:
matrix:
parameters:
ruby-version: ["2.5"]
- tests-ruby:
matrix:
parameters:
ruby-version: ["2.5"]
- compatibility-ruby:
matrix:
parameters:
ruby-version: ["2.6", "2.7", "3.0"]
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.4.2] - 2021.05.13

### Fixed

- Fixed security vulnerability for bundler ([CVE-2019-3881](https://github.com/advisories/GHSA-g98m-96g9-wfjq))
- Fixed test coverage issues

### Updated

- Updated gem development dependencies
- Updated simplecov/CircleCi config
- Updated gem documentation, version

## [2.4.1] - 2021.05.05

### Updated
Expand Down
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
truemail (2.4.1)
truemail (2.4.2)
simpleidn (~> 0.2.1)

GEM
Expand All @@ -21,8 +21,8 @@ GEM
crack (0.4.5)
rexml
diff-lcs (1.4.4)
dns_mock (1.2.1)
docile (1.3.5)
dns_mock (1.2.3)
docile (1.4.0)
faker (2.17.0)
i18n (>= 1.6, < 2)
fasterer (0.9.0)
Expand Down Expand Up @@ -85,7 +85,7 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
parser (>= 3.0.1.1)
rubocop-performance (1.11.2)
rubocop-performance (1.11.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rspec (2.3.0)
Expand All @@ -103,10 +103,10 @@ GEM
simpleidn (0.2.1)
unf (~> 0.1.4)
thor (1.1.0)
truemail-rspec (0.5.0)
truemail-rspec (0.6.0)
faker (~> 2.17)
rspec (~> 3.10)
truemail (>= 2.3)
truemail (>= 2.4)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
Expand All @@ -117,12 +117,12 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
ruby
x86_64-darwin-19

DEPENDENCIES
bundler (~> 1.16)
bundler (~> 2.2, >= 2.2.17)
bundler-audit (~> 0.8.0)
dns_mock (~> 1.2, >= 1.2.1)
dns_mock (~> 1.2, >= 1.2.3)
faker (~> 2.17)
fasterer (~> 0.9.0)
json_matchers (~> 0.11.1)
Expand All @@ -132,12 +132,12 @@ DEPENDENCIES
reek (~> 6.0, >= 6.0.4)
rspec (~> 3.10)
rubocop (~> 1.14)
rubocop-performance (~> 1.11, >= 1.11.2)
rubocop-performance (~> 1.11, >= 1.11.3)
rubocop-rspec (~> 2.3)
simplecov (~> 0.17.1)
truemail!
truemail-rspec (~> 0.5)
truemail-rspec (~> 0.6)
webmock (~> 3.12, >= 3.12.2)

BUNDLED WITH
1.16.6
2.2.17
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,12 @@ Truemail.configure do |config|

# Optional parameter. You can predefine default validation type for
# Truemail.validate('[email protected]') call without with-parameter
# Available validation types: :regex, :mx, :smtp
# Available validation types: :regex, :mx, :mx_blacklist, :smtp
config.default_validation_type = :mx

# Optional parameter. You can predefine which type of validation will be used for domains.
# Also you can skip validation by domain. Available validation types: :regex, :mx, :smtp
# Also you can skip validation by domain.
# Available validation types: :regex, :mx, :mx_blacklist, :smtp
# This configuration will be used over current or default validation type parameter
# All of validations for 'somedomain.com' will be processed with regex validation only.
# And all of validations for 'otherdomain.com' will be processed with mx validation only.
Expand Down Expand Up @@ -222,7 +223,7 @@ Truemail.configure do |config|
config.not_rfc_mx_lookup_flow = true

# Optional parameter. This option will provide to use smtp fail fast behaviour. When
# smtp_fail_fast = true it means that truemail ends smtp validation session after first
# smtp_fail_fast = true it means that Truemail ends smtp validation session after first
# attempt on the first mx server in any fail cases (network connection/timeout error,
# smtp validation error). This feature helps to reduce total time of SMTP validation
# session up to 1 second. By default this option is disabled.
Expand Down
12 changes: 6 additions & 6 deletions lib/truemail/log/serializer/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ def errors(executor_result_target)

Truemail::Log::Serializer::Base::CONFIGURATION_ARRAY_ATTRS.each do |method|
define_method(method) do
value = executor_configuration.public_send(method)
return if value.empty?
value
executor_configuration_attr = executor_configuration.public_send(method)
return if executor_configuration_attr.empty?
executor_configuration_attr
end
end

Truemail::Log::Serializer::Base::CONFIGURATION_REGEX_ATTRS.each do |method|
define_method(method) do
value = executor_configuration.public_send(method)
executor_configuration_attr = executor_configuration.public_send(method)
default_pattern = Truemail::RegexConstant.const_get(
(method.eql?(:email_pattern) ? :regex_email_pattern : :regex_smtp_error_body_pattern).upcase
)
return Truemail::Log::Serializer::Base::DEFAULT_GEM_VALUE if value.eql?(default_pattern)
value
return Truemail::Log::Serializer::Base::DEFAULT_GEM_VALUE if executor_configuration_attr.eql?(default_pattern)
executor_configuration_attr
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Truemail
VERSION = '2.4.1'
VERSION = '2.4.2'
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'bundler/setup'
require_relative 'support/config/simplecov'
require_relative '../lib/truemail'

rspec_custom = ::File.join(::File.dirname(__FILE__), 'support/**/*.rb')
Expand Down
7 changes: 5 additions & 2 deletions spec/support/config/simplecov.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'simplecov'
if ::RUBY_VERSION[/\A2\.5.+\z/]
require 'simplecov'

SimpleCov.start
SimpleCov.minimum_coverage(100)
SimpleCov.start { add_filter(%r{\A/spec/}) }
end
10 changes: 10 additions & 0 deletions spec/support/schemas/validator.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@
"target host(s) not found"
]
},
"mx_blacklist": {
"$id": "#/properties/errors/properties/mx_blacklist",
"type": "string",
"title": "The mx_blacklist schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"blacklisted mx server ip address"
]
},
"smtp": {
"$id": "#/properties/errors/properties/smtp",
"type": "string",
Expand Down
9 changes: 2 additions & 7 deletions spec/truemail/audit/dns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
RSpec.describe Truemail::Audit::Dns do
let(:configuration_instance) { create_configuration(dns: ["127.0.0.1:#{dns_mock_server.port}"]) }
let(:verifier_domain) { configuration_instance.verifier_domain }
let(:result_instance) { Truemail::Auditor::Result.new(configuration: configuration_instance) }
let(:current_host_ip) { random_ip_address }
let(:result_instance) { create_auditor(current_host_ip: current_host_ip, configuration: configuration_instance).result }

describe 'defined constants' do
specify { expect(described_class).to be_const_defined(:VERIFIER_DOMAIN_NOT_REFER) }
Expand All @@ -30,12 +31,8 @@

let(:dns_auditor_instance) { described_class.new(result_instance) }

before { allow(dns_auditor_instance).to receive(:current_host_ip).and_return(current_host_ip) }

describe 'Success' do
context 'when a record found and refers to current host ip' do
let(:current_host_ip) { random_ip_address }

before { dns_mock_server.assign_mocks(verifier_domain => { a: [current_host_ip] }) }

it 'not changes warnings' do
Expand All @@ -46,8 +43,6 @@
end

describe 'Fails' do
let(:current_host_ip) { random_ip_address }

shared_examples 'addes verifier domain not refer warning to result instance' do
it 'addes verifier domain not refer warning to result instance' do
expect { dns_auditor }
Expand Down
5 changes: 2 additions & 3 deletions spec/truemail/audit/ip_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

RSpec.describe Truemail::Audit::Ip do
let(:configuration_instance) { create_configuration }
let(:result_instance) { Truemail::Auditor::Result.new(configuration: configuration_instance) }
let(:result_instance) { create_auditor(success: nil, warnings: {}).result }

describe 'defined constants' do
specify { expect(described_class).to be_const_defined(:GET_MY_IP_URL) }
Expand Down Expand Up @@ -79,7 +78,7 @@
end

context 'if network error' do
let(:expectation) { expect(ip_auditor_instance).to receive(:detect_ip_via_ipify).and_raise(IPAddr::InvalidAddressError) }
let(:expectation) { expect(ip_auditor_instance).to receive(:detect_ip_via_ipify).and_raise(::IPAddr::InvalidAddressError) }

include_examples 'addes ipify warning to result instance'
end
Expand Down
6 changes: 2 additions & 4 deletions spec/truemail/audit/ptr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
RSpec.describe Truemail::Audit::Ptr do
let(:configuration_instance) { create_configuration(dns: ["127.0.0.1:#{dns_mock_server.port}"]) }
let(:verifier_domain) { configuration_instance.verifier_domain }
let(:result_instance) { Truemail::Auditor::Result.new(configuration: configuration_instance) }
let(:current_host_ip) { random_ip_address }
let(:result_instance) { create_auditor(current_host_ip: current_host_ip, configuration: configuration_instance).result }

describe 'defined constants' do
specify { expect(described_class).to be_const_defined(:PTR_NOT_FOUND) }
Expand All @@ -30,9 +31,6 @@
subject(:ptr_auditor) { ptr_auditor_instance.run }

let(:ptr_auditor_instance) { described_class.new(result_instance) }
let(:current_host_ip) { random_ip_address }

before { allow(ptr_auditor_instance).to receive(:current_host_ip).and_return(current_host_ip) }

describe 'Success' do
context 'when ptr record exists and refereces to verifier domain' do
Expand Down
Loading

0 comments on commit 363736d

Please sign in to comment.