Skip to content

Commit 2600f48

Browse files
committed
add workflow for testing backwards compat
1 parent f9c8382 commit 2600f48

6 files changed

Lines changed: 1648 additions & 0 deletions

File tree

Lines changed: 387 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,387 @@
1+
name: backwards-compatibility
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "lib/rubygems/**"
7+
- "bundler/lib/**"
8+
- "test/**"
9+
- "bundler/spec/**"
10+
push:
11+
branches:
12+
- master
13+
schedule:
14+
# Run weekly on Sunday at 6 AM UTC
15+
- cron: "0 6 * * 0"
16+
17+
concurrency:
18+
group: ci-${{ github.ref }}-${{ github.workflow }}
19+
cancel-in-progress: true
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
# This workflow tests bi-directional compatibility for:
26+
# 1. RubyGems marshal data (gemspecs, indexes, safe marshal)
27+
# 2. Bundler lockfiles
28+
#
29+
# Each compatibility type has:
30+
# - Forward: Current version generates → Old version consumes
31+
# - Backward: Old version generates → Current version consumes
32+
33+
# Forward compatibility: Generate test data with current RubyGems
34+
forward-generate:
35+
name: Generate Forward Test Data (RG ${{ matrix.rubygems_version }}, Ruby ${{ matrix.ruby_version }})
36+
runs-on: ubuntu-24.04
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
rubygems_version:
41+
- "current" # Use current source
42+
ruby_version:
43+
- "3.2.8"
44+
- "3.3.8"
45+
- "3.4.4"
46+
47+
steps:
48+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with:
50+
persist-credentials: false
51+
52+
- name: Setup Ruby
53+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
54+
with:
55+
ruby-version: ${{ matrix.ruby_version }}
56+
bundler: none
57+
58+
- name: Install current RubyGems from source
59+
run: |
60+
ruby setup.rb --no-format-executable
61+
62+
- name: Generate test data
63+
run: |
64+
mkdir -p test-data/forward-compat
65+
ruby tool/compat/generate_test_data.rb forward test-data/forward-compat/
66+
67+
- name: Upload test data
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: forward-data-rg${{ matrix.rubygems_version }}-ruby${{ matrix.ruby_version }}
71+
path: test-data/forward-compat/
72+
retention-days: 1
73+
74+
# Forward compatibility: Test deserialization with old RubyGems versions
75+
forward-validate:
76+
name: Forward Validate (Old RG ${{ matrix.old_rubygems }}, Ruby ${{ matrix.ruby_version }})
77+
runs-on: ubuntu-24.04
78+
needs: forward-generate
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
old_rubygems:
83+
- "2.7.11" # Last 2.7.x
84+
- "3.0.9" # Last 3.0.x
85+
- "3.1.6" # Last 3.1.x
86+
- "3.2.3" # Last 3.2.x
87+
- "3.3.26" # Last 3.3.x
88+
- "3.4.22" # Last 3.4.x
89+
ruby_version:
90+
- "3.2.8"
91+
- "3.3.8"
92+
- "3.4.4"
93+
94+
steps:
95+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96+
with:
97+
persist-credentials: false
98+
99+
- name: Setup Ruby
100+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
101+
with:
102+
ruby-version: ${{ matrix.ruby_version }}
103+
bundler: none
104+
105+
- name: Download all forward test data
106+
uses: actions/download-artifact@v4
107+
with:
108+
pattern: forward-data-*
109+
path: downloaded-data/
110+
merge-multiple: true
111+
112+
- name: Install old RubyGems version
113+
run: |
114+
gem install rubygems-update -v ${{ matrix.old_rubygems }}
115+
update_rubygems ${{ matrix.old_rubygems }}
116+
117+
- name: Test deserialization with old RubyGems
118+
run: |
119+
# Test against all generated data versions
120+
for data_dir in downloaded-data/*/; do
121+
echo "Testing data from: $data_dir"
122+
ruby tool/compat/validate_deserialization.rb "$data_dir" ${{ matrix.old_rubygems }}
123+
done
124+
125+
# Backward compatibility: Generate test data with old RubyGems versions
126+
backward-generate:
127+
name: Generate Backward Test Data (RG ${{ matrix.old_rubygems }}, Ruby ${{ matrix.ruby_version }})
128+
runs-on: ubuntu-24.04
129+
strategy:
130+
fail-fast: false
131+
matrix:
132+
old_rubygems:
133+
- "2.7.11"
134+
- "3.0.9"
135+
- "3.1.6"
136+
- "3.2.3"
137+
- "3.3.26"
138+
- "3.4.22"
139+
ruby_version:
140+
- "3.2.8"
141+
142+
steps:
143+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
144+
with:
145+
persist-credentials: false
146+
147+
- name: Setup Ruby
148+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
149+
with:
150+
ruby-version: ${{ matrix.ruby_version }}
151+
bundler: none
152+
153+
- name: Install old RubyGems version
154+
run: |
155+
gem install rubygems-update -v ${{ matrix.old_rubygems }}
156+
update_rubygems ${{ matrix.old_rubygems }}
157+
158+
- name: Generate test data with old RubyGems
159+
run: |
160+
mkdir -p test-data/backward-compat
161+
ruby tool/compat/generate_test_data.rb backward test-data/backward-compat/
162+
163+
- name: Upload test data
164+
uses: actions/upload-artifact@v4
165+
with:
166+
name: backward-data-rg${{ matrix.old_rubygems }}-ruby${{ matrix.ruby_version }}
167+
path: test-data/backward-compat/
168+
retention-days: 1
169+
170+
# Backward compatibility: Test deserialization with current RubyGems
171+
backward-validate:
172+
name: Backward Validate (Current RG, Ruby ${{ matrix.ruby_version }})
173+
runs-on: ubuntu-24.04
174+
needs: backward-generate
175+
strategy:
176+
fail-fast: false
177+
matrix:
178+
ruby_version:
179+
- "3.2.8"
180+
- "3.3.8"
181+
- "3.4.4"
182+
183+
steps:
184+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
185+
with:
186+
persist-credentials: false
187+
188+
- name: Setup Ruby
189+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
190+
with:
191+
ruby-version: ${{ matrix.ruby_version }}
192+
bundler: none
193+
194+
- name: Download all backward test data
195+
uses: actions/download-artifact@v4
196+
with:
197+
pattern: backward-data-*
198+
path: downloaded-data/
199+
merge-multiple: true
200+
201+
- name: Install current RubyGems from source
202+
run: |
203+
ruby setup.rb --no-format-executable
204+
205+
- name: Test deserialization with current RubyGems
206+
run: |
207+
# Test against all generated data versions
208+
for data_dir in downloaded-data/*/; do
209+
echo "Testing data from: $data_dir"
210+
ruby tool/compat/validate_deserialization.rb "$data_dir" current
211+
done
212+
213+
# Lockfile forward compatibility: Generate lockfiles with current Bundler
214+
lockfile-forward-generate:
215+
name: Generate Forward Lockfiles (Current Bundler, Ruby ${{ matrix.ruby_version }})
216+
runs-on: ubuntu-24.04
217+
strategy:
218+
fail-fast: false
219+
matrix:
220+
ruby_version:
221+
- "3.2.8"
222+
- "3.3.8"
223+
- "3.4.4"
224+
225+
steps:
226+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
227+
with:
228+
persist-credentials: false
229+
230+
- name: Setup Ruby
231+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
232+
with:
233+
ruby-version: ${{ matrix.ruby_version }}
234+
bundler: none
235+
236+
- name: Install current Bundler from source and generate lockfiles
237+
run: |
238+
cd bundler && rake install
239+
cd ..
240+
241+
# Generate lockfiles with current Bundler
242+
mkdir -p test-data/lockfiles
243+
ruby tool/compat/generate_lockfiles.rb current test-data/lockfiles/
244+
245+
- name: Upload forward lockfile data
246+
uses: actions/upload-artifact@v4
247+
with:
248+
name: lockfile-forward-data-current-ruby${{ matrix.ruby_version }}
249+
path: test-data/lockfiles/
250+
retention-days: 1
251+
252+
# Lockfile forward compatibility: Test with old Bundler versions
253+
lockfile-forward-validate:
254+
name: Lockfile Forward Validate (Old Bundler ${{ matrix.old_bundler }}, Ruby ${{ matrix.ruby_version }})
255+
runs-on: ubuntu-24.04
256+
needs: lockfile-forward-generate
257+
strategy:
258+
fail-fast: false
259+
matrix:
260+
old_bundler:
261+
- "1.17.3" # Last 1.x
262+
- "2.0.2" # First 2.x
263+
- "2.1.4" # Last 2.1.x
264+
- "2.2.33" # Last 2.2.x
265+
- "2.3.26" # Last 2.3.x
266+
- "2.4.22" # Last 2.4.x
267+
- "2.5.23" # Last 2.5.x
268+
ruby_version:
269+
- "3.2.8"
270+
271+
steps:
272+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
273+
with:
274+
persist-credentials: false
275+
276+
- name: Setup Ruby
277+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
278+
with:
279+
ruby-version: ${{ matrix.ruby_version }}
280+
bundler: none
281+
282+
- name: Download all forward lockfile data
283+
uses: actions/download-artifact@v4
284+
with:
285+
pattern: lockfile-forward-data-*
286+
path: downloaded-data/
287+
merge-multiple: true
288+
289+
- name: Install old Bundler version
290+
run: |
291+
gem install bundler -v ${{ matrix.old_bundler }}
292+
293+
- name: Test lockfile parsing with old Bundler
294+
run: |
295+
# Test against all generated lockfile versions
296+
for data_dir in downloaded-data/*/; do
297+
echo "Testing lockfiles from: $data_dir"
298+
ruby tool/compat/validate_lockfiles.rb "$data_dir" ${{ matrix.old_bundler }}
299+
done
300+
301+
# Lockfile backward compatibility: Generate lockfiles with old Bundler versions
302+
lockfile-backward-generate:
303+
name: Generate Backward Lockfiles (Bundler ${{ matrix.old_bundler }}, Ruby ${{ matrix.ruby_version }})
304+
runs-on: ubuntu-24.04
305+
strategy:
306+
fail-fast: false
307+
matrix:
308+
old_bundler:
309+
- "1.17.3" # Last 1.x
310+
- "2.0.2" # First 2.x
311+
- "2.1.4" # Last 2.1.x
312+
- "2.2.33" # Last 2.2.x
313+
- "2.3.26" # Last 2.3.x
314+
- "2.4.22" # Last 2.4.x
315+
- "2.5.23" # Last 2.5.x
316+
ruby_version:
317+
- "3.2.8"
318+
319+
steps:
320+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
321+
with:
322+
persist-credentials: false
323+
324+
- name: Setup Ruby
325+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
326+
with:
327+
ruby-version: ${{ matrix.ruby_version }}
328+
bundler: none
329+
330+
- name: Install old Bundler version and generate lockfiles
331+
run: |
332+
# Install specific Bundler version
333+
gem install bundler -v ${{ matrix.old_bundler }}
334+
335+
# Generate lockfiles
336+
mkdir -p test-data/lockfiles
337+
ruby tool/compat/generate_lockfiles.rb ${{ matrix.old_bundler }} test-data/lockfiles/
338+
339+
- name: Upload backward lockfile data
340+
uses: actions/upload-artifact@v4
341+
with:
342+
name: lockfile-backward-data-bundler${{ matrix.old_bundler }}-ruby${{ matrix.ruby_version }}
343+
path: test-data/lockfiles/
344+
retention-days: 1
345+
346+
# Lockfile backward compatibility: Test with current Bundler
347+
lockfile-backward-validate:
348+
name: Lockfile Backward Validate (Current Bundler, Ruby ${{ matrix.ruby_version }})
349+
runs-on: ubuntu-24.04
350+
needs: lockfile-backward-generate
351+
strategy:
352+
fail-fast: false
353+
matrix:
354+
ruby_version:
355+
- "3.2.8"
356+
- "3.3.8"
357+
- "3.4.4"
358+
359+
steps:
360+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
361+
with:
362+
persist-credentials: false
363+
364+
- name: Setup Ruby
365+
uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # v1.244.0
366+
with:
367+
ruby-version: ${{ matrix.ruby_version }}
368+
bundler: none
369+
370+
- name: Download all backward lockfile data
371+
uses: actions/download-artifact@v4
372+
with:
373+
pattern: lockfile-backward-data-*
374+
path: downloaded-data/
375+
merge-multiple: true
376+
377+
- name: Install current Bundler from source
378+
run: |
379+
cd bundler && rake install
380+
381+
- name: Test lockfile parsing with current Bundler
382+
run: |
383+
# Test against all generated lockfile versions
384+
for data_dir in downloaded-data/*/; do
385+
echo "Testing lockfiles from: $data_dir"
386+
ruby tool/compat/validate_lockfiles.rb "$data_dir" current
387+
done

0 commit comments

Comments
 (0)