Skip to content

Commit 44b6976

Browse files
authored
Add CI check for RI backward compatibility (ruby#1625)
1 parent 08036aa commit 44b6976

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: RI Backward Compatibility
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
- '!dependabot/**'
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
ri-backward-compat:
15+
name: RI reads data generated by RDoc ${{ matrix.old_rdoc }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
old_rdoc: ['6.5.0', '6.9.0', '7.0.2']
20+
runs-on: ubuntu-latest
21+
env:
22+
RI_DATA_DIR: /tmp/ri_data
23+
steps:
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
- name: Set up Ruby
26+
uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0
27+
with:
28+
# Must use Ruby 3.x — on Ruby 4.0, Heading is always a Class while old
29+
# RDoc versions serialized it as a Struct, so the test would always fail
30+
# regardless of whether the current code is correct.
31+
ruby-version: '3.4'
32+
- name: Generate ri data with old RDoc
33+
run: |
34+
gem install rdoc -v ${{ matrix.old_rdoc }} --no-document
35+
ruby -e '
36+
gem "rdoc", "${{ matrix.old_rdoc }}"
37+
require "rdoc/rdoc"
38+
puts "Generating ri data with RDoc #{RDoc::VERSION}"
39+
RDoc::RDoc.new.document(["--ri", "--op", ENV["RI_DATA_DIR"], "--quiet", "lib/"])
40+
'
41+
- name: Install current RDoc
42+
run: |
43+
gem build rdoc.gemspec
44+
gem install rdoc-*.gem --no-document
45+
- name: Verify current ri can read old data
46+
run: |
47+
ruby -e '
48+
require "rdoc"
49+
puts "Reading ri data with RDoc #{RDoc::VERSION}"
50+
51+
store = RDoc::Store.new(RDoc::Options.new, path: ENV["RI_DATA_DIR"], type: :extra)
52+
store.load_cache
53+
54+
modules = store.module_names
55+
errors = []
56+
57+
modules.each do |mod_name|
58+
store.load_class(mod_name)
59+
rescue => e
60+
errors << [mod_name, e]
61+
warn "FAIL: #{mod_name} - #{e.class}: #{e.message}"
62+
end
63+
64+
if errors.empty?
65+
puts "All #{modules.size} modules loaded successfully"
66+
else
67+
abort "#{errors.size} of #{modules.size} modules failed to load"
68+
end
69+
'

0 commit comments

Comments
 (0)