Skip to content

Commit eba14e1

Browse files
committed
feat: Add support for Ruby 3.0, and drop Ruby 2.5
Ruby 2.5 is no longer supported by the dev team.
1 parent b736120 commit eba14e1

16 files changed

+38
-25
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: ruby
22

33
rbenv:
4-
- 2.5
54
- 2.6
65
- 2.7
6+
- 3.0
77

88
addons:
99
apt:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ root@6fab5f89125f:/src/app# bundle
117117
```
118118

119119
At this point, the bundle is built with the `appmap` gem located in `/src/appmap`, which is volume-mounted from the host.
120-
So you can edit the fixture code and the appmap code and run test commands such as `rspec` and `cucumber` in the container.
120+
So you can edit the fixture code and the appmap code and run test commands such as `rspec` in the container.
121121
For example:
122122

123123
```sh-session
124-
root@6fab5f89125f:/src/app# bundle exec rspec
124+
root@6fab5f89125f:/src/app# APPMAP=true bundle exec rspec
125125
Configuring AppMap from path appmap.yml
126126
....
127127

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace 'gem' do
2828
end
2929
end
3030

31-
RUBY_VERSIONS=%w[2.5 2.6 2.7].select do |version|
31+
RUBY_VERSIONS=%w[2.6 2.7 3.0].select do |version|
3232
travis_ruby_version = ENV['TRAVIS_RUBY_VERSION']
3333
next true unless travis_ruby_version
3434

lib/appmap/command/agent_setup/init.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'json'
4+
require 'yaml'
45
require 'appmap/service/guesser'
56

67
module AppMap

lib/appmap/config.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def initialize(name,
254254
functions.each do |func|
255255
package_options = {}
256256
package_options[:labels] = func.labels if func.labels
257-
@hooked_methods[func.cls] << TargetMethods.new(func.function_names, Package.build_from_path(func.package, package_options))
257+
@hooked_methods[func.cls] << TargetMethods.new(func.function_names, Package.build_from_path(func.package, **package_options))
258258
end
259259

260260
@hooked_methods.each_value do |hooks|
@@ -367,7 +367,7 @@ def load(config_data)
367367
config_params[:depends_config] = depends_config
368368
end
369369

370-
Config.new name, config_params
370+
Config.new name, **config_params
371371
end
372372
end
373373

lib/appmap/service/validator/config_validator.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'appmap/service/validator/violation'
4+
require 'yaml'
45

56
module AppMap
67
module Service
@@ -76,7 +77,10 @@ def validate_rails_presence
7677
end
7778

7879
def validate_ruby_version
79-
unless RUBY_VERSION =~ AppMap::SUPPORTED_RUBY_VERSIONS_REGEX
80+
major, minor, _ = RUBY_VERSION.split('.')
81+
version = [ major, minor ].join('.')
82+
83+
unless AppMap::SUPPORTED_RUBY_VERSIONS.member?(version)
8084
@violations << Violation.error(
8185
message: "AppMap does not support Ruby #{RUBY_VERSION}. " \
8286
"Supported versions are: #{AppMap::SUPPORTED_RUBY_VERSIONS.join(', ')}."

lib/appmap/version.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ module AppMap
77

88
APPMAP_FORMAT_VERSION = '1.5.1'
99

10-
SUPPORTED_RUBY_VERSIONS_REGEX = /^2\.[567]\./.freeze
11-
SUPPORTED_RUBY_VERSIONS = %w[2.5 2.6 2.7].freeze
10+
SUPPORTED_RUBY_VERSIONS = %w[2.6 2.7 3.0].freeze
1211

1312
DEFAULT_APPMAP_DIR = 'tmp/appmap'.freeze
1413
DEFAULT_CONFIG_FILE_PATH = 'appmap.yml'.freeze

spec/depends/api_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def minitest_select_tests_method(test_files)
5555
describe '.inspect_test_files' do
5656
it 'reports metadata, added, removed, changed, failed' do
5757
test_report = api.inspect_test_files(appmap_dir: DEPENDS_TEST_DIR, test_file_patterns: %w[spec/fixtures/depends/spec/*_spec.rb])
58-
expect(test_report.metadata_files).to eq(%w[spec/fixtures/depends/user_page_scenario/metadata.json spec/fixtures/depends/revoke_api_key/metadata.json])
58+
expect(test_report.metadata_files.sort).to eq(%w[spec/fixtures/depends/revoke_api_key/metadata.json spec/fixtures/depends/user_page_scenario/metadata.json])
5959
expect(test_report.added).to be_empty
6060
expect(test_report.removed).to be_empty
6161
expect(test_report.changed).to be_empty

spec/fixtures/rails6_users_app/Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem 'haml-rails'
77

88
gem 'activerecord', require: false
99
gem 'pg'
10-
gem 'sequel', '= 5.20.0', require: false
10+
gem 'sequel', '>= 5.43.0', require: false
1111
gem 'sequel-rails', require: false
1212
gem 'sequel_secure_password', require: false
1313

spec/fixtures/rails6_users_app/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
dockerfile: Dockerfile
1616
image: rails6-app:${RUBY_VERSION}
1717
command:
18-
[ "./bin/rails", "server", "-b", "0.0.0.0", "webrick" ]
18+
[ "./bin/rails", "server", "-b", "0.0.0.0", "-u", "webrick" ]
1919
environment:
2020
RAILS_ENV:
2121
ORM_MODULE:

spec/hook_spec.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,12 @@ def secure_compare(a, b)
987987
end
988988

989989
describe 'kwargs handling' do
990-
# https://github.com/applandinc/appmap-ruby/issues/153
991-
it 'empty hash for **kwrest can be proxied as a regular function argument', github_issue: 153 do
992-
invoke_test_file 'spec/fixtures/hook/kwargs.rb' do
993-
expect(Kwargs.has_kwrest_calls_no_kwargs(nil, {})).to eq({})
990+
if ruby_2?
991+
# https://github.com/applandinc/appmap-ruby/issues/153
992+
it 'empty hash for **kwrest can be proxied as a regular function argument', github_issue: 153 do
993+
invoke_test_file 'spec/fixtures/hook/kwargs.rb' do
994+
expect(Kwargs.has_kwrest_calls_no_kwargs(nil, {})).to eq({})
995+
end
994996
end
995997
end
996998
end

spec/rails_recording_spec.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
require 'rails_spec_helper'
22

3+
# Rails5 doesn't work with Ruby 3.x
4+
RailsVersions = ruby_2? ? [ 5, 6 ] : [ 6 ]
5+
36
describe 'Rails' do
4-
%w[5 6].each do |rails_major_version| # rubocop:disable Metrics/BlockLength
7+
RailsVersions.each do |rails_major_version| # rubocop:disable Metrics/BlockLength
58
context "#{rails_major_version}" do
69
include_context 'Rails app pg database', "spec/fixtures/rails#{rails_major_version}_users_app" unless use_existing_data?
710
include_context 'rails integration test setup'
@@ -239,7 +242,7 @@ def run_spec(spec_name)
239242
end
240243

241244
describe 'with default appmap.yml' do
242-
include_context 'Rails app pg database', "spec/fixtures/rails5_users_app" unless use_existing_data?
245+
include_context 'Rails app pg database', "spec/fixtures/rails6_users_app" unless use_existing_data?
243246
include_context 'rails integration test setup'
244247

245248
def run_spec(spec_name)

spec/railtie_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rails_spec_helper'
22

33
describe 'AppMap tracer via Railtie' do
4-
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
4+
include_context 'Rails app pg database', 'spec/fixtures/rails6_users_app' do
55
let(:env) { {} }
66

77
let(:cmd) { %(docker-compose run --rm -e RAILS_ENV=development -e APPMAP app ./bin/rails r "puts AppMap.instance_variable_get('@configuration').nil?") }
@@ -10,13 +10,13 @@
1010
Open3.capture3(env, cmd, chdir: fixture_dir).tap do |result|
1111
unless result[2] == 0
1212
warn <<~STDERR
13-
Failed to run rails5_users_app container
13+
Failed to run rails6_users_app container
1414
<<< Output:
1515
#{result[0]}
1616
#{result[1]}
1717
>>> End of output
1818
STDERR
19-
raise 'Failed to run rails5_users_app container'
19+
raise 'Failed to run rails6_users_app container'
2020
end
2121
end
2222
end

spec/record_sql_rails_pg_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rails_spec_helper'
22

33
describe 'SQL events' do
4-
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
4+
include_context 'Rails app pg database', 'spec/fixtures/rails6_users_app' do
55
around(:each) do |example|
66
FileUtils.rm_rf tmpdir
77
FileUtils.mkdir_p tmpdir

spec/remote_recording_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
require 'socket'
44

55
describe 'remote recording', :order => :defined do
6-
include_context 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
6+
include_context 'Rails app pg database', 'spec/fixtures/rails6_users_app' do
77
before(:all) do
8-
fixture_dir = 'spec/fixtures/rails5_users_app'
8+
fixture_dir = 'spec/fixtures/rails6_users_app'
99
start_cmd = 'docker-compose up -d app'
1010
run_cmd({ 'ORM_MODULE' => 'sequel', 'APPMAP' => 'true' }, start_cmd, chdir: fixture_dir)
1111
Dir.chdir fixture_dir do
@@ -44,7 +44,7 @@ def json_body(res)
4444
end
4545

4646
after(:all) do
47-
fixture_dir = 'spec/fixtures/rails5_users_app'
47+
fixture_dir = 'spec/fixtures/rails6_users_app'
4848
run_cmd 'docker-compose rm -fs app', chdir: fixture_dir
4949
end
5050

spec/spec_helper.rb

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ def use_existing_data?
2121
ENV['USE_EXISTING_DATA'] == 'true'
2222
end
2323

24+
def ruby_2?
25+
RUBY_VERSION.split('.')[0].to_i == 2
26+
end
27+
2428
shared_context 'collect events' do
2529
def collect_events(tracer)
2630
[].tap do |events|

0 commit comments

Comments
 (0)