Skip to content

Commit

Permalink
Fix CI env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Sep 1, 2024
1 parent d81a122 commit a51fc8f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,32 @@ jobs:
### TEST RUBY VERSIONS
- ruby: "2.7"
- ruby: "3.0"
db_gem_version: "~> 1.4" # fixes sqlite3 gem dependency issue
- ruby: "3.1"
- ruby: "3.2"
- ruby: "3.3"
### TEST RAILS VERSIONS
- ruby: "2.7"
env:
RAILS_VERSION: "6.0"
rails_version: "~> 6.0.0"
- ruby: "2.7"
env:
RAILS_VERSION: "6.1"
rails_version: "~> 6.1.0"
- ruby: "3.3"
env:
RAILS_VERSION: "7.0"
rails_version: "~> 7.0.0"
db_gem_version: "~> 1.4" # fixes sqlite3 gem dependency issue
- ruby: "3.3"
env:
RAILS_VERSION: "7.1"
rails_version: "~> 7.1.0"
- ruby: "3.3"
env:
RAILS_VERSION: "7.2"
rails_version: "~> 7.2.0"

steps:
- uses: actions/checkout@v3

- name: Set env variables
run: |
echo "RAILS_VERSION=${{ matrix.rails_version }}" >> "$GITHUB_ENV"
echo "DB_GEM=${{ matrix.db_gem }}" >> "$GITHUB_ENV"
echo "DB_GEM_VERSION=${{ matrix.db_gem_version }}" >> "$GITHUB_ENV"
- name: Install ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
5 changes: 2 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ end

gem "rails", get_env("RAILS_VERSION")

db_gem = get_env("DB_GEM") || "sqlite3"
gem db_gem, get_env("DB_GEM_VERSION")

if get_env("RAILS_VERSION").to_f >= 7.2
gem "activerecord-enhancedsqlite3-adapter"
gem "sqlite3", "~> 2.0"
else
gem "sqlite3", "~> 1.7"
end

group :development do
Expand Down
30 changes: 30 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,33 @@

config.filter_rails_from_backtrace!
end

if Rails::VERSION::STRING.to_f <= 6.0
def assert_difference(expression, *args, &block)
expressions =
if expression.is_a?(Hash)
message = args[0]
expression
else
difference = args[0] || 1
message = args[1]
Array(expression).index_with(difference)
end

exps = expressions.keys.map { |e|
e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
}
before = exps.map(&:call)

retval = assert_nothing_raised(&block)

expressions.zip(exps, before) do |(code, diff), exp, before_value|
actual = exp.call
error = "#{code.inspect} didn't change by #{diff}, but by #{actual - before_value}"
error = "#{message}.\n#{error}" if message
assert_equal(before_value + diff, actual, error)
end

retval
end
end

0 comments on commit a51fc8f

Please sign in to comment.