seed_dump 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +38 -0
- data/Appraisals +47 -0
- data/Gemfile +23 -7
- data/README.md +53 -19
- data/VERSION +1 -1
- data/find_ruby_compat.sh +237 -0
- data/gemfiles/rails_6.1.gemfile +28 -0
- data/gemfiles/rails_6.1.gemfile.lock +150 -0
- data/gemfiles/rails_7.0.gemfile +28 -0
- data/gemfiles/rails_7.0.gemfile.lock +148 -0
- data/gemfiles/rails_7.1.gemfile +28 -0
- data/gemfiles/rails_7.1.gemfile.lock +161 -0
- data/gemfiles/rails_7.2.gemfile +28 -0
- data/gemfiles/rails_7.2.gemfile.lock +164 -0
- data/gemfiles/rails_8.0.gemfile +28 -0
- data/gemfiles/rails_8.0.gemfile.lock +163 -0
- data/lib/seed_dump/dump_methods/enumeration.rb +11 -3
- data/lib/seed_dump/dump_methods.rb +421 -64
- data/lib/seed_dump/environment.rb +294 -8
- data/seed_dump.gemspec +30 -29
- data/spec/dump_methods_spec.rb +1012 -74
- data/spec/environment_spec.rb +515 -46
- data/spec/factories/another_samples.rb +17 -10
- data/spec/factories/authors.rb +5 -0
- data/spec/factories/base_users.rb +16 -0
- data/spec/factories/books.rb +6 -0
- data/spec/factories/bosses.rb +5 -0
- data/spec/factories/reviews.rb +7 -0
- data/spec/factories/samples.rb +16 -12
- data/spec/factories/yet_another_samples.rb +17 -10
- data/spec/helpers.rb +169 -9
- data/spec/spec_helper.rb +28 -5
- metadata +46 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 511098e751f9bc1761ba88f8fa017c354b70c88c98522ca9ae7cdcca10cedd18
|
|
4
|
+
data.tar.gz: b719e6cb717d0a50ef4c6c223da3a5a4f232cb762a56a56b27734c4d32da9c97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfc449642cf4cc1d33665f2780a2021a49f4cad644beece695365ac7dc87af419dcca064298653d101d0daafb683cefa3539952de4a92ab583be9aae12091616
|
|
7
|
+
data.tar.gz: 22c058a82ecf0dd3d9b775b52de95f15efca5c14a3eb767a8a22f3cc4acd6a1d8f8696510a1f57fcd19c1fb2df959196c748b1620eec34e359428af247e25c53
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
name: Release gem to RubyGems.org
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write # Required for trusted publishing
|
|
15
|
+
contents: write # Required for GitHub release creation
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Ruby
|
|
21
|
+
uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: '3.3'
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Configure RubyGems credentials
|
|
27
|
+
uses: rubygems/configure-rubygems-credentials@v1.0.0
|
|
28
|
+
|
|
29
|
+
- name: Build gem
|
|
30
|
+
run: gem build seed_dump.gemspec
|
|
31
|
+
|
|
32
|
+
- name: Push to RubyGems
|
|
33
|
+
run: gem push seed_dump-*.gem
|
|
34
|
+
|
|
35
|
+
- name: Create GitHub Release
|
|
36
|
+
uses: softprops/action-gh-release@v2
|
|
37
|
+
with:
|
|
38
|
+
generate_release_notes: true
|
data/Appraisals
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Appraisals file for testing seed_dump against different Rails versions.
|
|
2
|
+
# Gems defined here are combined with the main Gemfile.
|
|
3
|
+
# Gems specified here take precedence over the Gemfile versions for that appraisal.
|
|
4
|
+
|
|
5
|
+
# Appraisal for Rails 6.1.x
|
|
6
|
+
appraise 'rails-6.1' do
|
|
7
|
+
# Specify gems specific to this appraisal scenario
|
|
8
|
+
gem 'activerecord', '~> 6.1.0'
|
|
9
|
+
gem 'activesupport', '~> 6.1.0'
|
|
10
|
+
gem 'sqlite3', '>= 1.3', '< 2.0' # Broadly compatible range
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Appraisal for Rails 7.0.x
|
|
14
|
+
appraise 'rails-7.0' do
|
|
15
|
+
# Specify gems specific to this appraisal scenario
|
|
16
|
+
gem 'activerecord', '~> 7.0.0'
|
|
17
|
+
gem 'activesupport', '~> 7.0.0'
|
|
18
|
+
gem 'sqlite3', '>= 1.3', '< 2.0' # Broadly compatible range
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Appraisal for Rails 7.1.x
|
|
22
|
+
appraise 'rails-7.1' do
|
|
23
|
+
# Specify gems specific to this appraisal scenario
|
|
24
|
+
gem 'activerecord', '~> 7.1.0'
|
|
25
|
+
gem 'activesupport', '~> 7.1.0'
|
|
26
|
+
gem 'sqlite3', '>= 1.3', '< 2.0' # Broadly compatible range
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Appraisal for Rails 7.2.x
|
|
30
|
+
appraise 'rails-7.2' do
|
|
31
|
+
gem 'activerecord', '~> 7.2.0'
|
|
32
|
+
gem 'activesupport', '~> 7.2.0'
|
|
33
|
+
gem 'sqlite3', '>= 1.3', '< 2.0'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Appraisal for Rails 8.0.x (Edge/Main)
|
|
37
|
+
appraise 'rails-8.0' do
|
|
38
|
+
# Specify gems specific to this appraisal scenario
|
|
39
|
+
gem 'activerecord', '>= 8.0.0.alpha', '< 8.1'
|
|
40
|
+
gem 'activesupport', '>= 8.0.0.alpha', '< 8.1'
|
|
41
|
+
|
|
42
|
+
# Override sqlite3 constraint for Rails 8 compatibility
|
|
43
|
+
# Rails 8 requires sqlite3 >= 2.1
|
|
44
|
+
gem 'sqlite3', '>= 2.1'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Common test gems (rspec, factory_bot, etc.) are inherited from the main Gemfile's :test group.
|
data/Gemfile
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
+
# Runtime dependencies (also used in test appraisals)
|
|
3
4
|
gem 'activesupport', '>= 4'
|
|
4
5
|
gem 'activerecord', '>= 4'
|
|
5
6
|
|
|
6
7
|
group :development, :test do
|
|
7
|
-
|
|
8
|
-
gem '
|
|
9
|
-
gem '
|
|
8
|
+
# Common development and test dependencies
|
|
9
|
+
gem 'byebug', '~> 11.1'
|
|
10
|
+
gem 'factory_bot', '~> 6.1'
|
|
11
|
+
# activerecord-import might be needed for tests if using :import option
|
|
12
|
+
gem 'activerecord-import', '~> 0.28'
|
|
10
13
|
end
|
|
11
14
|
|
|
12
15
|
group :development do
|
|
13
|
-
|
|
16
|
+
# Development-only dependencies
|
|
17
|
+
gem 'jeweler', '~> 2.3'
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
group :test do
|
|
17
|
-
|
|
18
|
-
gem '
|
|
19
|
-
gem 'database_cleaner', '~>
|
|
21
|
+
# Test-only dependencies (common across all appraisals)
|
|
22
|
+
gem 'rspec', '~> 3.13.0'
|
|
23
|
+
gem 'database_cleaner-active_record', '~> 2.0'
|
|
24
|
+
gem 'appraisal', '~> 2.4'
|
|
25
|
+
|
|
26
|
+
# Add gems removed from Ruby stdlib/default but needed by older ActiveSupport
|
|
27
|
+
# Required for Ruby 3.4+
|
|
28
|
+
gem 'mutex_m'
|
|
29
|
+
# Recommended for Ruby 3.5+ (or to silence warning in 3.4)
|
|
30
|
+
gem 'logger'
|
|
31
|
+
# Add benchmark to silence Ruby 3.5+ warning
|
|
32
|
+
gem 'benchmark'
|
|
20
33
|
end
|
|
34
|
+
|
|
35
|
+
# Pull in dependencies specified in the gemspec
|
|
36
|
+
gemspec
|
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
Seed Dump
|
|
2
|
-
========
|
|
1
|
+
# Seed Dump
|
|
3
2
|
|
|
4
|
-
Seed Dump is a Rails 4
|
|
3
|
+
Seed Dump is a Rails plugin (compatible with **Rails 4 through 8+**) that adds a rake task named `db:seed:dump`.
|
|
5
4
|
|
|
6
5
|
It allows you to create seed data files from the existing data in your database.
|
|
7
6
|
|
|
@@ -9,8 +8,7 @@ You can also use Seed Dump from the Rails console. See below for usage examples.
|
|
|
9
8
|
|
|
10
9
|
Note: if you want to use Seed Dump with Rails 3 or earlier, use [version 0.5.3](http://rubygems.org/gems/seed_dump/versions/0.5.3).
|
|
11
10
|
|
|
12
|
-
Installation
|
|
13
|
-
------------
|
|
11
|
+
## Installation
|
|
14
12
|
|
|
15
13
|
Add it to your Gemfile with:
|
|
16
14
|
```ruby
|
|
@@ -20,8 +18,7 @@ Or install it by hand:
|
|
|
20
18
|
```sh
|
|
21
19
|
$ gem install seed_dump
|
|
22
20
|
```
|
|
23
|
-
Examples
|
|
24
|
-
--------
|
|
21
|
+
## Examples
|
|
25
22
|
|
|
26
23
|
### Rake task
|
|
27
24
|
|
|
@@ -98,34 +95,71 @@ irb(main):004:0> SeedDump.dump(User, exclude: [:name, :age])
|
|
|
98
95
|
|
|
99
96
|
Options are specified as a Hash for the second argument.
|
|
100
97
|
|
|
101
|
-
In the console, any relation of ActiveRecord rows can be dumped (not individual objects though)
|
|
98
|
+
In the console, any relation of ActiveRecord rows can be dumped (not individual objects though):
|
|
102
99
|
```ruby
|
|
103
|
-
irb(main):
|
|
100
|
+
irb(main):005:0> puts SeedDump.dump(User.where(is_admin: false))
|
|
104
101
|
User.create!([
|
|
105
102
|
{ password: "123456", username: "test_1", is_admin: false },
|
|
106
103
|
{ password: "234567", username: "test_2", is_admin: false }
|
|
107
104
|
])
|
|
108
105
|
```
|
|
109
106
|
|
|
110
|
-
Options
|
|
111
|
-
-------
|
|
107
|
+
## Options
|
|
112
108
|
|
|
113
109
|
Options are common to both the Rake task and the console, except where noted.
|
|
114
110
|
|
|
115
111
|
`append`: If set to `true`, append the data to the file instead of overwriting it. Default: `false`.
|
|
116
112
|
|
|
117
|
-
`batch_size`: Controls the number of records that are
|
|
113
|
+
`batch_size`: Controls the number of records that are processed and written at a given time. Default: 1000. If you're running out of memory when dumping, try decreasing this. If things are dumping too slow, trying increasing this.
|
|
118
114
|
|
|
119
|
-
`exclude`: Attributes to be excluded from the dump. Pass a comma-separated list to the Rake task (
|
|
115
|
+
`exclude`: Attributes to be excluded from the dump. Pass a comma-separated list to the Rake task (e.g., `EXCLUDE=name,age`) and an array of symbols on the console (e.g., `exclude: [:name, :age]`). Default: `[:id, :created_at, :updated_at, :created_on, :updated_on]`.
|
|
120
116
|
|
|
121
|
-
`file`: Write to the specified output file. The Rake task default is `db/seeds.rb`. The console returns the dump as a string by default.
|
|
117
|
+
`file`: Write to the specified output file. The Rake task default is `db/seeds.rb`. The console returns the dump as a string by default if this option is omitted.
|
|
122
118
|
|
|
123
|
-
`import`: If `true`, output will be in the format needed by the [activerecord-import](https://github.com/zdennis/activerecord-import) gem, rather than the default format. Default: `false`.
|
|
119
|
+
`import`: If `true`, output will be in the format needed by the [activerecord-import](https://github.com/zdennis/activerecord-import) gem, rather than the default format. You can also pass a Hash of options which will be passed through to the `import` call (e.g., `IMPORT='{ "validate": false }'` for Rake, or `import: { validate: false }` for console). Default: `false`.
|
|
124
120
|
|
|
125
|
-
`
|
|
121
|
+
`include_all`: If set to `true`, include all columns in the dump (including `id`, `created_at`, and `updated_at`). Equivalent to `EXCLUDE=""`. Default: `false`. **Rake task only.** Example: `rake db:seed:dump INCLUDE_ALL=true`
|
|
126
122
|
|
|
127
|
-
`
|
|
123
|
+
`insert_all`: If `true`, output will use Rails 6+ [`insert_all`](https://api.rubyonrails.org/classes/ActiveRecord/Persistence/ClassMethods.html#method-i-insert_all) for faster bulk inserts that bypass validations and callbacks. Default: `false`. Example: `rake db:seed:dump INSERT_ALL=true` or `SeedDump.dump(User, insert_all: true)`.
|
|
128
124
|
|
|
129
|
-
`
|
|
125
|
+
`limit`: Dump no more than this amount of data *per model*. Default: no limit. **Rake task only.** In the console, just pass in an ActiveRecord::Relation with the appropriate limit (e.g., `SeedDump.dump(User.limit(5))`).
|
|
130
126
|
|
|
131
|
-
`
|
|
127
|
+
`model_limits`: Set different limits for specific models. Format: `Model1:limit1,Model2:limit2`. Use `0` to mean "no limit" for a specific model. This is useful when `LIMIT` would break foreign key relationships. **Rake task only.** Example: `rake db:seed:dump LIMIT=10 MODEL_LIMITS="Teacher:0,Student:50"` dumps all Teachers, 50 Students, and 10 of everything else.
|
|
128
|
+
|
|
129
|
+
`model[s]`: Restrict the dump to the specified comma-separated list of models. Default: all models that have data. If you are using a Rails engine you can dump a specific model by passing "EngineName::ModelName". **Rake task only.** Example: `rake db:seed:dump MODELS="User, Position, Function"`
|
|
130
|
+
|
|
131
|
+
`models_exclude`: Exclude the specified comma-separated list of models from the dump. Default: no models excluded. **Rake task only.** Example: `rake db:seed:dump MODELS_EXCLUDE="User"`
|
|
132
|
+
|
|
133
|
+
`header`: If `true`, adds a comment header to the output file showing the seed_dump command and options used. If a string, uses that string as the header comment. Default: `false`. **Rake task only.** Example: `rake db:seed:dump HEADER=true` or `HEADER="Generated by seed_dump"`.
|
|
134
|
+
|
|
135
|
+
`upsert_all`: If `true`, output will use Rails 6+ [`upsert_all`](https://api.rubyonrails.org/classes/ActiveRecord/Persistence/ClassMethods.html#method-i-upsert_all) which preserves record IDs and handles conflicts by updating existing records. This is useful when you need to maintain foreign key relationships or want idempotent seed files. Automatically includes `id` in the dump. Default: `false`. Example: `rake db:seed:dump UPSERT_ALL=true` or `SeedDump.dump(User, upsert_all: true)`.
|
|
136
|
+
|
|
137
|
+
## Automatic Behaviors
|
|
138
|
+
|
|
139
|
+
**Foreign Key Ordering**: Models are automatically dumped in dependency order based on foreign key relationships. This ensures that parent records are created before child records that reference them.
|
|
140
|
+
|
|
141
|
+
**STI Handling**: Single Table Inheritance (STI) models are automatically deduplicated— only the base model is dumped, avoiding duplicate records.
|
|
142
|
+
|
|
143
|
+
**HABTM Handling**: Has-and-belongs-to-many join tables are automatically detected and dumped without duplication.
|
|
144
|
+
|
|
145
|
+
## Usage Outside of Rails
|
|
146
|
+
|
|
147
|
+
If you're using ActiveRecord outside of Rails (e.g., with [standalone-migrations](https://github.com/thuss/standalone-migrations)), you can set up a custom Rake task:
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
# In your Rakefile
|
|
151
|
+
$LOAD_PATH.unshift(File.expand_path('app/models', __dir__))
|
|
152
|
+
Dir.glob(File.expand_path('app/models/*.rb', __dir__)).sort.each(&method(:require))
|
|
153
|
+
require 'seed_dump'
|
|
154
|
+
|
|
155
|
+
namespace :db do
|
|
156
|
+
namespace :seed do
|
|
157
|
+
desc "Dump records from the database into db/seeds.rb"
|
|
158
|
+
task :dump => :environment do
|
|
159
|
+
SeedDump.dump_using_environment(ENV)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
This loads your models and creates a `db:seed:dump` task that works like the Rails version.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.4.0
|
data/find_ruby_compat.sh
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Script to find the oldest supported MRI Ruby version using asdf and appraisal.
|
|
4
|
+
# Iterates from the latest available MRI Ruby version downwards.
|
|
5
|
+
|
|
6
|
+
set -uo pipefail # Exit on unset variables, error on pipeline failure
|
|
7
|
+
|
|
8
|
+
# --- Configuration ---
|
|
9
|
+
# Regex to match stable MRI Ruby versions (e.g., 3.3.0, 3.2.4, 2.7.8)
|
|
10
|
+
# Excludes pre-releases, RCs, dev versions. Adjust if needed.
|
|
11
|
+
MRI_VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+$'
|
|
12
|
+
|
|
13
|
+
# --- Functions ---
|
|
14
|
+
cleanup() {
|
|
15
|
+
echo "Cleaning up..."
|
|
16
|
+
# Remove .tool-versions if it exists
|
|
17
|
+
if [[ -f ".tool-versions" ]]; then
|
|
18
|
+
echo "Removing temporary .tool-versions file."
|
|
19
|
+
rm -f ".tool-versions"
|
|
20
|
+
fi
|
|
21
|
+
echo "Cleanup finished."
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# --- Main Script ---
|
|
25
|
+
|
|
26
|
+
# Ensure asdf is available
|
|
27
|
+
if ! command -v asdf &> /dev/null; then
|
|
28
|
+
echo "Error: asdf command not found. Please install asdf."
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Ensure appraisal is available (at least check the command)
|
|
33
|
+
if ! command -v appraisal &> /dev/null; then
|
|
34
|
+
echo "Warning: appraisal command not found. Ensure it's in the Gemfile and run 'bundle install' first."
|
|
35
|
+
# Attempt bundle install once initially
|
|
36
|
+
if ! bundle check &> /dev/null; then
|
|
37
|
+
echo "Running initial 'bundle install'..."
|
|
38
|
+
if ! bundle install; then
|
|
39
|
+
echo "Error: Initial bundle install failed. Cannot proceed."
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Set trap for cleanup on exit (normal or error)
|
|
47
|
+
trap cleanup EXIT
|
|
48
|
+
|
|
49
|
+
echo "Starting Ruby compatibility check..."
|
|
50
|
+
|
|
51
|
+
# 1. Get currently installed Ruby versions to avoid uninstalling them
|
|
52
|
+
echo "Detecting pre-installed Ruby versions..."
|
|
53
|
+
pre_installed_rubies=$(asdf list ruby 2>/dev/null | xargs)
|
|
54
|
+
echo "Found pre-installed: ${pre_installed_rubies:-None}"
|
|
55
|
+
|
|
56
|
+
# 2. Get all available MRI Ruby versions and sort them latest first
|
|
57
|
+
echo "Fetching available MRI Ruby versions from asdf..."
|
|
58
|
+
# Use process substitution and handle potential errors reading the list
|
|
59
|
+
available_versions_output=$(asdf list all ruby)
|
|
60
|
+
if [[ $? -ne 0 ]]; then
|
|
61
|
+
echo "Error: Failed to list all ruby versions from asdf."
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
sorted_mri_versions=$(echo "$available_versions_output" | grep -E "$MRI_VERSION_REGEX" | sort -V -r)
|
|
66
|
+
if [[ -z "$sorted_mri_versions" ]]; then
|
|
67
|
+
echo "Error: Could not find any stable MRI Ruby versions matching regex '$MRI_VERSION_REGEX'."
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# 3. Initialize state variables
|
|
72
|
+
last_successful_version=""
|
|
73
|
+
first_failing_version=""
|
|
74
|
+
tested_a_version=false # Flag to check if any version was actually tested
|
|
75
|
+
|
|
76
|
+
# 4. Loop through sorted versions
|
|
77
|
+
while IFS= read -r version; do
|
|
78
|
+
echo ""
|
|
79
|
+
echo "--------------------------------------------------"
|
|
80
|
+
echo "Attempting tests with Ruby $version"
|
|
81
|
+
echo "--------------------------------------------------"
|
|
82
|
+
tested_a_version=true
|
|
83
|
+
was_installed_by_script=false
|
|
84
|
+
|
|
85
|
+
# Check if this version was already installed
|
|
86
|
+
is_pre_installed=false
|
|
87
|
+
for installed_version in $pre_installed_rubies; do
|
|
88
|
+
if [[ "$installed_version" == "$version" ]]; then
|
|
89
|
+
is_pre_installed=true
|
|
90
|
+
break
|
|
91
|
+
fi
|
|
92
|
+
done
|
|
93
|
+
|
|
94
|
+
# Install if not pre-installed
|
|
95
|
+
if [[ "$is_pre_installed" == "false" ]]; then
|
|
96
|
+
echo "Ruby $version is not pre-installed. Attempting installation..."
|
|
97
|
+
if ! asdf install ruby "$version"; then
|
|
98
|
+
echo "ERROR: Failed to install Ruby $version. Skipping."
|
|
99
|
+
# Clean up potentially partially installed version
|
|
100
|
+
asdf uninstall ruby "$version" || true
|
|
101
|
+
continue
|
|
102
|
+
fi
|
|
103
|
+
was_installed_by_script=true
|
|
104
|
+
else
|
|
105
|
+
echo "Ruby $version is pre-installed."
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
# Set local version (creates .tool-versions) using the correct syntax
|
|
109
|
+
echo "Setting local Ruby version to $version using 'asdf set local'..."
|
|
110
|
+
if ! asdf set local ruby "$version"; then
|
|
111
|
+
echo "ERROR: Failed to set local Ruby version to $version. Skipping."
|
|
112
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
113
|
+
echo "Uninstalling Ruby $version as it was installed by script."
|
|
114
|
+
asdf uninstall ruby "$version" || true
|
|
115
|
+
fi
|
|
116
|
+
# Ensure .tool-versions is removed if setting failed
|
|
117
|
+
rm -f ".tool-versions"
|
|
118
|
+
continue
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
# *** Explicitly reshim after setting local version ***
|
|
122
|
+
echo "Reshimming Ruby $version executables..."
|
|
123
|
+
if ! asdf reshim ruby "$version"; then
|
|
124
|
+
# This might happen if the install was corrupted, but often it's okay.
|
|
125
|
+
echo "WARNING: Failed to reshim Ruby $version. Proceeding, but executables might not be found."
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# Ensure bundler is available and install dependencies
|
|
129
|
+
echo "Ensuring Bundler and installing gems for Ruby $version..."
|
|
130
|
+
# Try installing bundler conservatively, update RubyGems if needed. Ignore errors somewhat.
|
|
131
|
+
# Use 'asdf exec' to ensure we use the shimmed gem command
|
|
132
|
+
if ! asdf exec gem install bundler --conservative; then
|
|
133
|
+
echo "Conservative bundler install failed, trying RubyGems update..."
|
|
134
|
+
if ! asdf exec gem update --system; then
|
|
135
|
+
echo "WARNING: RubyGems update failed."
|
|
136
|
+
fi
|
|
137
|
+
echo "Retrying bundler install..."
|
|
138
|
+
if ! asdf exec gem install bundler; then
|
|
139
|
+
echo "ERROR: Failed to install bundler for Ruby $version even after attempts. Skipping."
|
|
140
|
+
# Reset local ruby, cleanup, and continue
|
|
141
|
+
rm -f ".tool-versions"
|
|
142
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
143
|
+
echo "Uninstalling Ruby $version as it was installed by script."
|
|
144
|
+
asdf uninstall ruby "$version" || true
|
|
145
|
+
fi
|
|
146
|
+
continue
|
|
147
|
+
fi
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
# Use 'asdf exec' to ensure we use the shimmed bundle command
|
|
151
|
+
if ! asdf exec bundle install; then
|
|
152
|
+
echo "ERROR: 'bundle install' failed for Ruby $version. Skipping."
|
|
153
|
+
# Reset local ruby, cleanup, and continue
|
|
154
|
+
rm -f ".tool-versions"
|
|
155
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
156
|
+
echo "Uninstalling Ruby $version as it was installed by script."
|
|
157
|
+
asdf uninstall ruby "$version" || true
|
|
158
|
+
fi
|
|
159
|
+
continue
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
# Install gems via appraisal
|
|
163
|
+
echo "Running 'bundle exec appraisal install' for Ruby $version..."
|
|
164
|
+
# Use 'asdf exec' to ensure we use the shimmed bundle command
|
|
165
|
+
if ! asdf exec bundle exec appraisal install; then
|
|
166
|
+
echo "ERROR: 'bundle exec appraisal install' failed for Ruby $version. Skipping."
|
|
167
|
+
rm -f ".tool-versions"
|
|
168
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
169
|
+
echo "Uninstalling Ruby $version as it was installed by script."
|
|
170
|
+
asdf uninstall ruby "$version" || true
|
|
171
|
+
fi
|
|
172
|
+
continue
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
# Run the tests via appraisal
|
|
176
|
+
echo "Running tests ('bundle exec appraisal rake spec') for Ruby $version..."
|
|
177
|
+
test_passed=false
|
|
178
|
+
# Use 'asdf exec' to ensure we use the shimmed bundle command
|
|
179
|
+
if asdf exec bundle exec appraisal rake spec; then
|
|
180
|
+
test_passed=true
|
|
181
|
+
fi
|
|
182
|
+
|
|
183
|
+
# Handle test results
|
|
184
|
+
if [[ "$test_passed" == "true" ]]; then
|
|
185
|
+
echo "SUCCESS: Tests PASSED for Ruby $version."
|
|
186
|
+
last_successful_version="$version"
|
|
187
|
+
# Uninstall if we installed it
|
|
188
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
189
|
+
echo "Uninstalling Ruby $version as it passed and was installed by script."
|
|
190
|
+
asdf uninstall ruby "$version" || true
|
|
191
|
+
fi
|
|
192
|
+
else
|
|
193
|
+
echo "FAILURE: Tests FAILED for Ruby $version."
|
|
194
|
+
first_failing_version="$version"
|
|
195
|
+
# Uninstall if we installed it
|
|
196
|
+
if [[ "$was_installed_by_script" == "true" ]]; then
|
|
197
|
+
echo "Uninstalling Ruby $version as it failed and was installed by script."
|
|
198
|
+
asdf uninstall ruby "$version" || true
|
|
199
|
+
fi
|
|
200
|
+
# Reset local ruby version immediately after failure detection
|
|
201
|
+
rm -f ".tool-versions"
|
|
202
|
+
# Stop searching further
|
|
203
|
+
break
|
|
204
|
+
fi
|
|
205
|
+
|
|
206
|
+
# Reset local ruby version before next iteration or script end
|
|
207
|
+
rm -f ".tool-versions"
|
|
208
|
+
|
|
209
|
+
done <<< "$sorted_mri_versions" # Feed the sorted list into the loop
|
|
210
|
+
|
|
211
|
+
# 5. Report results
|
|
212
|
+
echo ""
|
|
213
|
+
echo "--------------------------------------------------"
|
|
214
|
+
echo "Compatibility Check Summary"
|
|
215
|
+
echo "--------------------------------------------------"
|
|
216
|
+
|
|
217
|
+
if [[ -n "$first_failing_version" ]]; then
|
|
218
|
+
echo "The first version that FAILED tests was: $first_failing_version"
|
|
219
|
+
if [[ -n "$last_successful_version" ]]; then
|
|
220
|
+
echo "The oldest tested version that PASSED tests is likely: $last_successful_version"
|
|
221
|
+
echo "(Suggest setting minimum required Ruby version >= $last_successful_version)"
|
|
222
|
+
else
|
|
223
|
+
echo "No tested Ruby version passed the tests."
|
|
224
|
+
fi
|
|
225
|
+
elif [[ "$tested_a_version" == "false" ]]; then
|
|
226
|
+
echo "No matching Ruby versions were found or could be tested."
|
|
227
|
+
elif [[ -n "$last_successful_version" ]]; then
|
|
228
|
+
echo "All tested Ruby versions passed!"
|
|
229
|
+
echo "The oldest tested version (which passed) was: $last_successful_version"
|
|
230
|
+
else
|
|
231
|
+
echo "No versions were successfully tested."
|
|
232
|
+
fi
|
|
233
|
+
echo "--------------------------------------------------"
|
|
234
|
+
|
|
235
|
+
# Cleanup is handled by the trap EXIT
|
|
236
|
+
|
|
237
|
+
exit 0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activesupport", "~> 6.1.0"
|
|
6
|
+
gem "activerecord", "~> 6.1.0"
|
|
7
|
+
gem "sqlite3", ">= 1.3", "< 2.0"
|
|
8
|
+
|
|
9
|
+
group :development, :test do
|
|
10
|
+
gem "byebug", "~> 11.1"
|
|
11
|
+
gem "factory_bot", "~> 6.1"
|
|
12
|
+
gem "activerecord-import", "~> 0.28"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
group :development do
|
|
16
|
+
gem "jeweler", "~> 2.3"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
group :test do
|
|
20
|
+
gem "rspec", "~> 3.13.0"
|
|
21
|
+
gem "database_cleaner-active_record", "~> 2.0"
|
|
22
|
+
gem "appraisal", "~> 2.4"
|
|
23
|
+
gem "mutex_m"
|
|
24
|
+
gem "logger"
|
|
25
|
+
gem "benchmark"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
gemspec path: "../"
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
seed_dump (3.3.1)
|
|
5
|
+
activerecord (>= 4)
|
|
6
|
+
activesupport (>= 4)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activemodel (6.1.7.10)
|
|
12
|
+
activesupport (= 6.1.7.10)
|
|
13
|
+
activerecord (6.1.7.10)
|
|
14
|
+
activemodel (= 6.1.7.10)
|
|
15
|
+
activesupport (= 6.1.7.10)
|
|
16
|
+
activerecord-import (0.28.2)
|
|
17
|
+
activerecord (>= 3.2)
|
|
18
|
+
activesupport (6.1.7.10)
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
i18n (>= 1.6, < 2)
|
|
21
|
+
minitest (>= 5.1)
|
|
22
|
+
tzinfo (~> 2.0)
|
|
23
|
+
zeitwerk (~> 2.3)
|
|
24
|
+
addressable (2.4.0)
|
|
25
|
+
appraisal (2.5.0)
|
|
26
|
+
bundler
|
|
27
|
+
rake
|
|
28
|
+
thor (>= 0.14.0)
|
|
29
|
+
base64 (0.2.0)
|
|
30
|
+
benchmark (0.4.0)
|
|
31
|
+
bigdecimal (3.1.9)
|
|
32
|
+
builder (3.3.0)
|
|
33
|
+
byebug (11.1.3)
|
|
34
|
+
concurrent-ruby (1.3.5)
|
|
35
|
+
database_cleaner-active_record (2.2.0)
|
|
36
|
+
activerecord (>= 5.a)
|
|
37
|
+
database_cleaner-core (~> 2.0.0)
|
|
38
|
+
database_cleaner-core (2.0.1)
|
|
39
|
+
date (3.4.1)
|
|
40
|
+
descendants_tracker (0.0.4)
|
|
41
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
42
|
+
diff-lcs (1.6.1)
|
|
43
|
+
factory_bot (6.5.1)
|
|
44
|
+
activesupport (>= 6.1.0)
|
|
45
|
+
faraday (0.9.2)
|
|
46
|
+
multipart-post (>= 1.2, < 3)
|
|
47
|
+
git (1.11.0)
|
|
48
|
+
rchardet (~> 1.8)
|
|
49
|
+
github_api (0.16.0)
|
|
50
|
+
addressable (~> 2.4.0)
|
|
51
|
+
descendants_tracker (~> 0.0.4)
|
|
52
|
+
faraday (~> 0.8, < 0.10)
|
|
53
|
+
hashie (>= 3.4)
|
|
54
|
+
mime-types (>= 1.16, < 3.0)
|
|
55
|
+
oauth2 (~> 1.0)
|
|
56
|
+
hashie (5.0.0)
|
|
57
|
+
highline (3.1.2)
|
|
58
|
+
reline
|
|
59
|
+
i18n (1.14.7)
|
|
60
|
+
concurrent-ruby (~> 1.0)
|
|
61
|
+
io-console (0.8.0)
|
|
62
|
+
jeweler (2.3.9)
|
|
63
|
+
builder
|
|
64
|
+
bundler
|
|
65
|
+
git (>= 1.2.5)
|
|
66
|
+
github_api (~> 0.16.0)
|
|
67
|
+
highline (>= 1.6.15)
|
|
68
|
+
nokogiri (>= 1.5.10)
|
|
69
|
+
psych
|
|
70
|
+
rake
|
|
71
|
+
rdoc
|
|
72
|
+
semver2
|
|
73
|
+
jwt (2.10.1)
|
|
74
|
+
base64
|
|
75
|
+
logger (1.7.0)
|
|
76
|
+
mime-types (2.99.3)
|
|
77
|
+
mini_portile2 (2.8.8)
|
|
78
|
+
minitest (5.25.5)
|
|
79
|
+
multi_json (1.15.0)
|
|
80
|
+
multi_xml (0.7.1)
|
|
81
|
+
bigdecimal (~> 3.1)
|
|
82
|
+
multipart-post (2.4.1)
|
|
83
|
+
mutex_m (0.3.0)
|
|
84
|
+
nokogiri (1.18.8)
|
|
85
|
+
mini_portile2 (~> 2.8.2)
|
|
86
|
+
racc (~> 1.4)
|
|
87
|
+
nokogiri (1.18.8-arm64-darwin)
|
|
88
|
+
racc (~> 1.4)
|
|
89
|
+
oauth2 (1.4.8)
|
|
90
|
+
faraday (>= 0.8, < 3.0)
|
|
91
|
+
jwt (>= 1.0, < 3.0)
|
|
92
|
+
multi_json (~> 1.3)
|
|
93
|
+
multi_xml (~> 0.5)
|
|
94
|
+
rack (>= 1.2, < 3)
|
|
95
|
+
psych (5.2.3)
|
|
96
|
+
date
|
|
97
|
+
stringio
|
|
98
|
+
racc (1.8.1)
|
|
99
|
+
rack (2.2.13)
|
|
100
|
+
rake (13.2.1)
|
|
101
|
+
rchardet (1.9.0)
|
|
102
|
+
rdoc (6.13.1)
|
|
103
|
+
psych (>= 4.0.0)
|
|
104
|
+
reline (0.6.1)
|
|
105
|
+
io-console (~> 0.5)
|
|
106
|
+
rspec (3.13.2)
|
|
107
|
+
rspec-core (~> 3.13.0)
|
|
108
|
+
rspec-expectations (~> 3.13.0)
|
|
109
|
+
rspec-mocks (~> 3.13.0)
|
|
110
|
+
rspec-core (3.13.6)
|
|
111
|
+
rspec-support (~> 3.13.0)
|
|
112
|
+
rspec-expectations (3.13.5)
|
|
113
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
114
|
+
rspec-support (~> 3.13.0)
|
|
115
|
+
rspec-mocks (3.13.7)
|
|
116
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
117
|
+
rspec-support (~> 3.13.0)
|
|
118
|
+
rspec-support (3.13.6)
|
|
119
|
+
semver2 (3.4.2)
|
|
120
|
+
sqlite3 (1.7.3)
|
|
121
|
+
mini_portile2 (~> 2.8.0)
|
|
122
|
+
stringio (3.1.7)
|
|
123
|
+
thor (1.3.2)
|
|
124
|
+
thread_safe (0.3.6)
|
|
125
|
+
tzinfo (2.0.6)
|
|
126
|
+
concurrent-ruby (~> 1.0)
|
|
127
|
+
zeitwerk (2.7.2)
|
|
128
|
+
|
|
129
|
+
PLATFORMS
|
|
130
|
+
arm64-darwin-24
|
|
131
|
+
ruby
|
|
132
|
+
|
|
133
|
+
DEPENDENCIES
|
|
134
|
+
activerecord (~> 6.1.0)
|
|
135
|
+
activerecord-import (~> 0.28)
|
|
136
|
+
activesupport (~> 6.1.0)
|
|
137
|
+
appraisal (~> 2.4)
|
|
138
|
+
benchmark
|
|
139
|
+
byebug (~> 11.1)
|
|
140
|
+
database_cleaner-active_record (~> 2.0)
|
|
141
|
+
factory_bot (~> 6.1)
|
|
142
|
+
jeweler (~> 2.3)
|
|
143
|
+
logger
|
|
144
|
+
mutex_m
|
|
145
|
+
rspec (~> 3.13.0)
|
|
146
|
+
seed_dump!
|
|
147
|
+
sqlite3 (>= 1.3, < 2.0)
|
|
148
|
+
|
|
149
|
+
BUNDLED WITH
|
|
150
|
+
2.6.2
|