Skip to content

Commit

Permalink
Merge pull request #452 from Shopify/mangara-fix-dev-up
Browse files Browse the repository at this point in the history
Prepare for isogun removal
  • Loading branch information
Mangara authored Jan 18, 2024
2 parents ca7bef9 + 2ddf0d8 commit bc6ff2b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
.ruby-version
.rubocop-http---shopify-github-io-ruby-style-guide-rubocop-yml
gemfiles/*.lock
dump.rdb
15 changes: 7 additions & 8 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
name: job-iteration

up:
- homebrew:
- mysql-client:
or: [[email protected]]
- ruby:
version: 2.7.6
- isogun
- packages:
- mysql_client
- ruby: 2.7.6
- bundler
- mysql
- redis
- custom:
name: Create Job Iteration database
meet: mysql -uroot -h job-iteration.railgun -e "CREATE DATABASE job_iteration_test"
met?: mysql -uroot -h job-iteration.railgun job_iteration_test -e "SELECT 1" &> /dev/null
meet: mysql -uroot -h $MYSQL_HOST -P $MYSQL_PORT -e "CREATE DATABASE job_iteration_test"
met?: mysql -uroot -h $MYSQL_HOST -P $MYSQL_PORT job_iteration_test -e "SELECT 1" &> /dev/null

commands:
test:
Expand Down
1 change: 0 additions & 1 deletion isogun.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# https://development.shopify.io/tools/dev/railgun/Railgun-Config
name: job-iteration

vm:
Expand Down
7 changes: 1 addition & 6 deletions test/support/resque/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ require "i18n"

require_relative "../jobs"

redis_url = if ENV["USING_DEV"] == "1"
"job-iteration.railgun:6379"
else
"localhost:6379"
end

redis_url = ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" }
Resque.redis = redis_url

I18n.available_locales = [:en]
Expand Down
8 changes: 2 additions & 6 deletions test/support/sidekiq/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@

require_relative "../jobs"

redis_host = if ENV["USING_DEV"] == "1"
"job-iteration.railgun"
else
"localhost"
end
redis_url = ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" }

Sidekiq.configure_server do |config|
config.redis = { host: redis_host }
config.redis = { url: redis_url }
end

I18n.available_locales = [:en]
Expand Down
13 changes: 8 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,31 @@ class Order < ActiveRecord::Base
self.primary_key = [:shop_id, :id]
end

host = ENV["USING_DEV"] == "1" ? "job-iteration.railgun" : "localhost"
mysql_host = ENV.fetch("MYSQL_HOST") { "localhost" }
mysql_port = ENV.fetch("MYSQL_PORT") { 3306 }

connection_config = {
adapter: "mysql2",
database: "job_iteration_test",
username: "root",
host: host,
host: mysql_host,
port: mysql_port,
}
connection_config[:password] = "root" if ENV["CI"]

ActiveRecord::Base.establish_connection(connection_config)

redis_url = ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" }

Redis.singleton_class.class_eval do
attr_accessor :current
end

Redis.current = Redis.new(host: host, timeout: 1.0).tap(&:ping)

Redis.current = Redis.new(url: redis_url, timeout: 1.0).tap(&:ping)
Resque.redis = Redis.current

Sidekiq.configure_client do |config|
config.redis = { host: host }
config.redis = { url: redis_url }
end

ActiveRecord::Schema.define do
Expand Down

0 comments on commit bc6ff2b

Please sign in to comment.