Skip to content

Commit

Permalink
Upgrade minimum required Ruby to v3.1.2
Browse files Browse the repository at this point in the history
I am considering this the correct minimum Ruby because it is the Ruby
which is available in Debian 12 (bookworm), which is current in January
2025.

* https://www.debian.org/releases/
* https://packages.debian.org/bookworm/ruby/

Most critically this drops support for v2.2, allowing use of the
standard library Bundler (i.e 2.x) and using the latests Rubocop.

Some rubocop refactoring, such as:
* remove the bundler dependency, becuase it is built in now
* add required Rubygems MFA to the gemspec

Github Action script and CI updates:
* drop the unsupported Rubies and added 3.1, 3.2, 3.4
* add simplecov JSON and lcov reporting
* switch ubuntu and macos to latest versions
* remove ruby version specification from the `coverage` step, because it
  should use the default/minimum Ruby specified in the `.ruby-version`
* remove the bundler version specification
* update action/checkout step to v4
* add Yardoc support
* add bundle:outdate Rake task
  • Loading branch information
acant committed Jan 31, 2025
1 parent 17439ad commit c7e1178
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 40 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,23 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, head, jruby, jruby-head]
ruby: [3.1, 3.2, 3.3, 3.4, head, jruby, jruby-head]
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || endsWith(matrix.ruby, 'jruby') }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
# HACK: Continue to use bundler <2 because of Ruby v2.2 support. Once the
# lowest dependency is Ruby v2.3 we can consider upgrading to Bundler 2.x.
bundler: 1.14
bundler-cache: true
- run: bundle exec rake spec
coverage:
needs: [ test ]
name: coverage
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.2'
# HACK: Continue to use bundler <2 because of Ruby v2.2 support. Once the
# lowest dependency is Ruby v2.3 we can consider upgrading to Bundler 2.x.
bundler: 1.14
bundler-cache: true
- run: bundle exec rake
env:
Expand Down
21 changes: 16 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
require: rubocop-rspec

AllCops:
Exclude:
- 'vendor/**/*'
- 'rspec-timecop.gemspec'
- 'lib/rspec/timecop/version.rb'
NewCops: enable

Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec

Metrics/MethodLength:
Max: 20

Documentation:
RSpec/EmptyExampleGroup:
Enabled: false

# Because of the way that blocks are used in RSpecs can end up being long when
# example groups are nested or many examples are checked.
# A similar pattern exists in the DSL for gemspec files.
Metrics/BlockLength:
Exclude:
- '*.gemspec'
- 'spec/**/*'
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log
All notable changes to this project will be documented in this file.

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

## [Unreleased]
### Changed
- minimum required Ruby version to 3.1.2, dropping support for 2.x and 3.0

## [0.3.0] - 2015-10-06
### Changed
- Upgrade timecop to v0.8.0
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in rspec-timecop.gemspec
Expand Down
26 changes: 24 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'bundler/audit/task'
require 'yard'
require 'yardstick/rake/measurement'
require 'pathname'
require 'license_finder'
require 'English'
Expand All @@ -29,11 +32,30 @@ end

Bundler::Audit::Task.new

desc 'Show which specified gems are outdated'
task 'bundle:outdated' do
bundle_outdated_report_pathname =
Pathname(Rake.application.original_dir).join('tmp', 'bundle_outdated.txt')
bundle_outdated_report_pathname.dirname.mkpath

# TODO: Should consider re-writing this without using `tee`.
sh("bundle outdated --only-explicit | tee #{bundle_outdated_report_pathname}")
end

desc 'Check dependency licenses'
task :license_finder do
puts `license_finder --quiet --format text`

abort('LicenseFinder failed') unless $CHILD_STATUS.success?
end

task default: %i[spec rubocop bundle:audit license_finder]
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb']
t.stats_options = ['--list-undoc']
end

Yardstick::Rake::Measurement.new(:yardstick_measure) do |measurement|
measurement.output = 'tmp/yard_coverage.txt'
end

task default: %i[spec rubocop yardsitck_measure bundle:audit license_finder]
6 changes: 3 additions & 3 deletions doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
:why:
:versions: []
:when: 2018-06-13 15:20:17.351348000 Z
- - :whitelist
- - :permit
- Apache 2.0
- :who: Andrew Sullivan Cant <[email protected]>
:why: SugarCRM's primary approved open source license
:versions: []
:when: 2018-06-18 19:28:33.314061000 Z
- - :whitelist
- - :permit
- MIT
- :who: Andrew Sullivan Cant <[email protected]>
:why: SugarCRM's secondary approved open source license
:versions: []
:when: 2018-06-13 15:18:36.240771000 Z
- - :whitelist
- - :permit
- BSD
- :who: Andrew Sullivan Cant <[email protected]>
:why: SugarCRM's secondary approved open source license
Expand Down
6 changes: 3 additions & 3 deletions lib/rspec/timecop.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

require 'rspec/core'
require 'timecop'
require 'rspec/timecop/version'
require 'rspec/timecop/helpers'

module RSpec
module Timecop
# Your code goes here...
module Timecop # rubocop:disable Style/Documentation
end
end
5 changes: 4 additions & 1 deletion lib/rspec/timecop/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

module RSpec
module Timecop
# Helper which will be include by default, and provide the `timecopped`
# help in all examples.
module Helpers
def timecopped(time)
result = nil
Expand Down
3 changes: 2 additions & 1 deletion lib/rspec/timecop/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

module RSpec
module Timecop
VERSION = '0.3.0'
Expand Down
29 changes: 18 additions & 11 deletions rspec-timecop.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rspec/timecop/version'

Expand All @@ -8,27 +9,33 @@ Gem::Specification.new do |spec|
spec.version = RSpec::Timecop::VERSION
spec.authors = ['Andrew Sullivan Cant']
spec.email = ['[email protected]']
spec.summary = %q{RSpec extension to control time.}
spec.description = %q{Provides helper methods for using Timecop in RSpec examples.}
spec.summary = 'RSpec extension to control time.'
spec.description = 'Provides helper methods for using Timecop in RSpec examples.'
spec.homepage = 'http://github.com/sugarcrm/rspec-timecop'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_runtime_dependency 'rspec-core', '>= 2.99.0'
spec.add_runtime_dependency 'timecop', '~> 0.8.0'
spec.add_development_dependency 'rubocop', '>= 0.30.0'
spec.add_development_dependency 'bundler', '~> 1.7'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 2.99.0'
spec.required_ruby_version = '>= 3.1.2'

spec.metadata['rubygems_mfa_required'] = 'true'

spec.add_dependency 'rspec-core', '>= 2.99.0'
spec.add_dependency 'timecop', '~> 0.8'

spec.add_development_dependency 'rake', '~> 12.2'
spec.add_development_dependency 'rspec', '~> 3.0'

# Dependencies whose APIs we do not really depend upon, and can be upgraded
# without limiting.
spec.add_development_dependency 'bundler-audit'
spec.add_development_dependency 'license_finder'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-rspec'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'simplecov-lcov'
spec.add_development_dependency 'yard'
spec.add_development_dependency 'yardstick'
end
4 changes: 3 additions & 1 deletion spec/helper_spec.rb → spec/rspec/timecop/helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe RSpec::Timecop::Helpers do
Expand All @@ -6,6 +8,6 @@

let(:now) { Time.parse('2015-01-01') }

it { should eq(now) }
it { is_expected.to eq(now) }
end
end
16 changes: 15 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

# Setup code coverage
require 'simplecov'
SimpleCov.start
require 'simplecov-lcov'
require 'simplecov_json_formatter'
SimpleCov.start do
# NOTE: Include the lcov formatter for CodeClimate reporting.
# Even though the simplecov JSON format will be output and used by default,
# the test reporter does not handle it reliable.
# Using the lcov formatter is more reliable.
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter,
SimpleCov::Formatter::LcovFormatter
]
)
end

require 'rspec/timecop'

0 comments on commit c7e1178

Please sign in to comment.