Skip to content

Commit

Permalink
CI: do not test Rails Edge for CI workflows
Browse files Browse the repository at this point in the history
- set an env var for CI workflows to denote CI workflow presence
- use a common Envfile helper to unshift Rails Edge onto the list of gem
  versions to test against
- update `active_record_pg`, `rails`, and `rails_prepend` to use the
  helper
- do not touch `active_record` at this time
  • Loading branch information
fallwith committed Oct 11, 2023
1 parent 7ca493f commit af2f4d5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
CI_FOR_PR: true
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- "3306:3306"
Expand Down Expand Up @@ -83,6 +84,7 @@ jobs:
env:
RUBY_VERSION: ${{ matrix.ruby-version }}
RAILS_VERSION: ${{ env.rails }}
CI_FOR_PR: true

- name: Run Unit Tests
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # tag v2.8.3
Expand All @@ -94,6 +96,7 @@ jobs:
DB_PORT: ${{ job.services.mysql.ports[3306] }}
VERBOSE_TEST_OUTPUT: true
COVERAGE: true
CI_FOR_PR: true

- name: Save coverage results
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # tag v3.1.2
Expand Down Expand Up @@ -253,6 +256,7 @@ jobs:
POSTGRES_PASSWORD: password
SERIALIZE: 1
COVERAGE: true
CI_FOR_PR: true

- name: Annotate errors
if: ${{ failure() }}
Expand Down Expand Up @@ -306,6 +310,7 @@ jobs:
VERBOSE_TEST_OUTPUT: true
SERIALIZE: 1
COVERAGE: true
CI_FOR_PR: true

- name: Annotate errors
if: ${{ failure() }}
Expand Down
28 changes: 28 additions & 0 deletions test/multiverse/lib/multiverse/envfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,34 @@ def serialize?
@serialize
end

# add Rails Edge to the array of gem versions for testing,
# unless we're operating in a PR workflow context
def prepend_rails_edge(gem_version_array = [])
return if ci_for_pr?

# Unshift Rails Edge (representing the latest GitHub primary branch
# commit for https://github.com/rails/rails) onto the front of the
# gem version array. This produces the following line in the generated
# Gemfile file:
#
# gem 'rails', github: 'rails'
#
# NOTE: Individually distributed Rails gems such as Active Record are each
# contained within the same 'rails' GitHub repo. For now we are not
# too concerned with cloning the entire Rails repo despite only
# wanting to test one gem.
#
# NOTE: The Rails Edge version is not tested unless the Ruby version in
# play is greater than or equal to (>=) the version number at the
# end of the unshifted inner array
array.unshift(["github: 'rails'", 3.0])
end

# are we running in a CI context intended for PR approvals?
def ci_for_pr?
ENV.key?('CI_FOR_PR')
end

private

def last_supported_ruby_version?(last_supported_ruby_version)
Expand Down
3 changes: 2 additions & 1 deletion test/multiverse/suites/active_record_pg/Envfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ end
serialize!

ACTIVERECORD_VERSIONS = [
["github: 'rails'", 3.0], # Rails Edge
[nil, 2.7],
['7.0.0', 2.7],
['6.1.0', 2.5],
Expand All @@ -22,6 +21,8 @@ ACTIVERECORD_VERSIONS = [
['5.0.0', 2.4, 2.7]
]

prepend_rails_edge(ACTIVERECORD_VERSIONS)

def gem_list(activerecord_version = nil)
<<~RB
gem 'activerecord'#{activerecord_version}
Expand Down
3 changes: 2 additions & 1 deletion test/multiverse/suites/rails/Envfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# frozen_string_literal: true

RAILS_VERSIONS = [
["github: 'rails'", 3.0], # Rails Edge
[nil, 2.7],
['7.0.4', 2.7],
['6.1.7', 2.5],
Expand All @@ -14,6 +13,8 @@ RAILS_VERSIONS = [
['4.2.11', 2.4, 2.4]
]

prepend_rails_edge(RAILS_VERSIONS)

def haml_rails(rails_version = nil)
if rails_version && (
rails_version.include?('4.0.13') ||
Expand Down
2 changes: 2 additions & 0 deletions test/multiverse/suites/rails_prepend/Envfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RAILS_VERSIONS = [
['4.2.0', 2.4, 2.4]
]

prepend_rails_edge(RAILS_VERSIONS)

def gem_list(rails_version = nil)
# earlier thor errors, uncertain if they persist
thor = "gem 'thor', '< 0.20.1'" if RUBY_PLATFORM == 'java' && rails_version && rails_version.include?('4')
Expand Down

0 comments on commit af2f4d5

Please sign in to comment.