Skip to content

Commit 3a382e2

Browse files
authored
CI: Test with Ruby 4.0.0 (sinatra#2136)
Allow newer commonmarker to be used in CI as 0.23.10 can't be used with Ruby 4: https://rubygems.org/gems/commonmarker/versions/0.23.10 For now, we need to use Bundler 2 when running the tests (Ruby 4 ships with Bundler 4 as the default): sinatra#2135
1 parent 0135c85 commit 3a382e2

3 files changed

Lines changed: 46 additions & 15 deletions

File tree

.github/workflows/test.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,33 @@ jobs:
8989
- "3.2"
9090
- "3.3"
9191
- "3.4"
92+
bundler:
93+
- default
9294
rubyopt:
9395
- "--enable-frozen-string-literal --debug-frozen-string-literal"
9496
include:
97+
# Avoid Bundler 4 for now: https://github.com/sinatra/sinatra/issues/2135
98+
- { ruby: "4.0", bundler: 2.7.2, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
9599
# Rack
96-
- { ruby: 3.4, rack: "~>3.0.0", puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
97-
- { ruby: 3.4, rack: "~>3.1.0", puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
98-
- { ruby: 3.4, rack: head, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
100+
- { ruby: 3.4, bundler: default, rack: "~>3.0.0", puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
101+
- { ruby: 3.4, bundler: default, rack: "~>3.1.0", puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
102+
- { ruby: 3.4, bundler: default, rack: head, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable }
99103
# Rack::Session
100-
- { ruby: 3.4, rack: stable, puma: stable, tilt: stable, rack_session: head, zeitwerk: stable }
104+
- { ruby: 3.4, bundler: default, rack: stable, puma: stable, tilt: stable, rack_session: head, zeitwerk: stable }
101105
# Puma
102-
- { ruby: 3.4, rack: stable, puma: head, tilt: stable, rack_session: stable, zeitwerk: stable }
106+
- { ruby: 3.4, bundler: default, rack: stable, puma: head, tilt: stable, rack_session: stable, zeitwerk: stable }
103107
# Tilt
104-
- { ruby: 3.4, rack: stable, puma: stable, tilt: head, rack_session: stable, zeitwerk: stable }
108+
- { ruby: 3.4, bundler: default, rack: stable, puma: stable, tilt: head, rack_session: stable, zeitwerk: stable }
105109
# Test Zeitwerk < 2.7.0 separately
106-
- { ruby: 3.4, rack: stable, puma: stable, tilt: head, rack_session: stable, zeitwerk: '<2.7.0' }
110+
- { ruby: 3.4, bundler: default, rack: stable, puma: stable, tilt: head, rack_session: stable, zeitwerk: '<2.7.0' }
107111
# JRuby, tests are notable flaky
108-
- { ruby: jruby, rubyopt: "", rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
112+
- { ruby: jruby, bundler: default, rubyopt: "", rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
109113
# Never fail our build due to problems with head rubies
110-
- { ruby: ruby-head, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
111-
- { ruby: jruby-head, rubyopt: "", rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
112-
- { ruby: truffleruby-head, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
114+
- { ruby: ruby-head, bundler: 2.7.2, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
115+
- { ruby: jruby-head, bundler: default, rubyopt: "", rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
116+
- { ruby: truffleruby-head, bundler: default, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
113117
# truffleruby 24.1 fails, see https://github.com/oracle/truffleruby/issues/3788
114-
- { ruby: truffleruby, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
118+
- { ruby: truffleruby, bundler: default, rack: stable, puma: stable, tilt: stable, rack_session: stable, zeitwerk: stable, allow-failure: true }
115119

116120
env:
117121
rack: ${{ matrix.rack }}
@@ -141,11 +145,21 @@ jobs:
141145
id: setup-ruby
142146
with:
143147
ruby-version: ${{ matrix.ruby }}
148+
bundler: ${{ matrix.bundler }}
144149
bundler-cache: true
145150
# Update rubygems due to https://github.com/rubygems/rubygems/pull/6490 (3.0)
146151
# and https://github.com/sinatra/sinatra/issues/2051 (3.1)
147152
rubygems: ${{ matrix.ruby == '3.0' && 'latest' || matrix.ruby == '3.1' && 'latest' || 'default' }}
148153

154+
# workaround for https://github.com/ruby/setup-ruby/issues/845
155+
- name: Ensure Gemfile.lock is created with Bundler 2 for Ruby 4
156+
if: matrix.ruby == '4.0' || matrix.ruby == 'ruby-head'
157+
run: |
158+
rm Gemfile.lock
159+
bundle install
160+
env:
161+
BUNDLER_VERSION: ${{ matrix.bundler }}
162+
149163
- name: Run sinatra tests
150164
continue-on-error: ${{ matrix.allow-failure || false }}
151165
id: tests

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ gem 'sinatra-contrib', path: 'sinatra-contrib'
3737
gem 'asciidoctor'
3838
gem 'builder'
3939
gem 'childprocess', '>= 5'
40-
gem 'commonmarker', '~> 0.23.4', platforms: [:ruby]
4140
gem 'erubi'
4241
gem 'eventmachine'
4342
gem 'falcon', '~> 0.40', platforms: [:ruby]
@@ -64,3 +63,7 @@ gem 'webrick'
6463
java = %w(jruby truffleruby).include?(RUBY_ENGINE)
6564
aarch64 = RbConfig::CONFIG["target_cpu"] == 'aarch64'
6665
gem 'sass-embedded', '~> 1.54' unless java && aarch64
66+
67+
# jruby does not support native extensions
68+
# https://github.com/truffleruby/truffleruby/issues/3396#issuecomment-3694252552
69+
gem 'commonmarker' unless java

test/markdown_test.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ def setup
1414
super
1515
end
1616

17+
# commonmarker is not installed on all platforms (e.g. jruby)
18+
def commonmarker_v1_or_higher?
19+
defined?(CommonMarkerTest) && self.class == CommonMarkerTest && defined?(::Commonmarker)
20+
end
21+
1722
it 'uses the correct engine' do
1823
assert_equal engine, Tilt[:md]
1924
assert_equal engine, Tilt[:mkd]
@@ -23,13 +28,22 @@ def setup
2328
it 'renders inline markdown strings' do
2429
markdown_app { markdown '# Hiya' }
2530
assert ok?
26-
assert_like "<h1>Hiya</h1>\n", body
31+
if commonmarker_v1_or_higher?
32+
assert_equal "<h1><a href=\"#hiya\" aria-hidden=\"true\" class=\"anchor\" id=\"hiya\"></a>Hiya</h1>\n", body
33+
else
34+
assert_like "<h1>Hiya</h1>\n", body
35+
end
2736
end
2837

2938
it 'renders .markdown files in views path' do
3039
markdown_app { markdown :hello }
3140
assert ok?
32-
assert_like "<h1>Hello From Markdown</h1>", body
41+
if commonmarker_v1_or_higher?
42+
assert_equal "<h1><a href=\"#hello-from-markdown\" aria-hidden=\"true\" " \
43+
"class=\"anchor\" id=\"hello-from-markdown\"></a>Hello From Markdown</h1>\n", body
44+
else
45+
assert_like "<h1>Hello From Markdown</h1>", body
46+
end
3347
end
3448

3549
it "raises error if template not found" do

0 commit comments

Comments
 (0)