Skip to content

Commit

Permalink
CI should install the same Rails version as the template requires
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinkelly committed Aug 30, 2024
1 parent df16a26 commit 460df41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout this repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -174,4 +173,7 @@ jobs:
PGUSER: postgres
PGPASSWORD: postgres
PGHOST: localhost
# This version constraint string must match the value of the
# RAILS_REQUIREMENT constant in `./template.rb`
RAILS_VERSION_CONSTRAINT: '~> 7.1.1'
run: ./ci/bin/build-and-test
4 changes: 3 additions & 1 deletion ci/bin/build-and-test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ config_path = if ENV.fetch("CONFIG_PATH", "") == ""
config_env_var = %Q(CONFIG_PATH="#{config_path}") if config_path
skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker")

rails_version_constraint = ENV.fetch("RAILS_VERSION_CONSTRAINT")

puts "=" * 80
puts <<~EO_CONFIG_SUMMARY
Config summary:
Expand All @@ -33,7 +35,7 @@ puts "=" * 80
raise "Missing config YML file" if config_path && !(File.exist?(config_path) && File.file?(config_path))

puts "Installing latest rails gem"
system "gem install rails --no-document"
system "gem install rails --version '#{rails_version_constraint}' --no-document"

unless Dir.exist?(builds_path)
puts "Creating #{builds_path}"
Expand Down
6 changes: 6 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
require "shellwords"
require "pp"

# Express the Rails version as a requirement so that we will automatically
# support the most recent patch version
#
# IMPORTANT: When you change this you must also update the
# `RAILS_VERSION_CONSTRAINT` environment variable in `.githug/ci.yml` to ensure
# that the CI runs against the correct version of Rails.
RAILS_REQUIREMENT = "~> 7.1.1".freeze

##
Expand Down

0 comments on commit 460df41

Please sign in to comment.