Skip to content

Commit

Permalink
DO|NOT|PUSH dev changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amaierhofer committed Nov 15, 2023
1 parent 0a6708b commit 590bfdd
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 42 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ group :development, :test do
gem 'graphiti_spec_helpers'
gem 'parallel_tests'
gem 'pry-byebug'
gem 'pry-doc' # provides show-source/$ in the pry-console
gem 'pry-doc', require: false # provides show-source/$ in the pry-console
gem 'rspec-rails', '~> 5.0'
gem 'rswag-specs'
end

group :development do
gem 'bullet'
gem 'bumbler'
gem 'listen'
gem 'redcarpet'
gem 'request_profiler'
Expand All @@ -139,6 +140,7 @@ group :console do
gem 'hirb'
gem 'pry-remote'
gem 'pry-stack_explorer'
gem 'test-prof'
gem 'spring-commands-rspec'
gem 'wirble'
end
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ GEM
bullet (7.1.1)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
bumbler (0.9.0)
byebug (11.1.3)
cancancan (3.1.0)
capybara (3.39.2)
Expand Down Expand Up @@ -651,6 +652,7 @@ GEM
strip_attributes (1.13.0)
activemodel (>= 3.0, < 8.0)
temple (0.10.3)
test-prof (1.2.3)
thinking-sphinx (5.5.1)
activerecord (>= 4.2.0)
builder (>= 2.1.2)
Expand Down Expand Up @@ -730,6 +732,7 @@ DEPENDENCIES
bootsnap
brakeman
bullet
bumbler
cancancan (< 3.2.0)
capybara
capybara-screenshot
Expand Down Expand Up @@ -831,6 +834,7 @@ DEPENDENCIES
sprockets (~> 3.7.2)
sqlite3
strip_attributes
test-prof
thinking-sphinx
truemail
validates_by_schema
Expand Down
37 changes: 23 additions & 14 deletions bin/active_wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@
class Setup

USED_RUBY_VERSION = '3.0.6'
USED_NODE_VERSION = '14.18.1'
USED_YARN_VERSION = '1.22.19'

def run
write_and_copy('.envrc', environment)
write_and_copy('.tool-versions', <<~TOOL_VERSION)
ruby #{USED_RUBY_VERSION}
nodejs 14.18.1
yarn 1.22.19
nodejs #{USED_NODE_VERSION}
yarn #{USED_YARN_VERSION}
TOOL_VERSION
write_and_copy('.ruby-version', USED_RUBY_VERSION)

write('Wagonfile', gemfile)
write('.envrc', environment)

wagons.each do |wagon|
write("../hitobito_#{wagon}/.envrc", environment(core: false))
FileUtils.touch("../hitobito_#{wagon}/config/environment.rb") # needed for rails-vim
end

FileUtils.rm_rf(root.join('tmp'))
end

Expand All @@ -32,8 +41,8 @@ def write(name, content)

def write_and_copy(name, content)
write(name, content)
wagons.each do |w|
FileUtils.cp(root.join(name), root.join("../hitobito_#{w}")) unless core?
(wagons - core_aliases).each do |w|
FileUtils.cp(root.join(name), root.join("../hitobito_#{w}"))
end
end

Expand All @@ -60,15 +69,19 @@ def gemfile
GEMFILE
end

def environment
def environment(core: true)
<<~DIRENV
PATH_add bin
export RAILS_DB_ADAPTER=mysql2
export RAILS_DB_NAME=hit_#{wagon}_development
export RAILS_TEST_DB_NAME=hit_#{wagon}_test
export RAILS_PRODUCTION_DB_NAME=hit_#{wagon}_production
export SPRING_APPLICATION_ID=hit_#{wagon}
export RAILS_DB_HOST=127.0.0.1
export RAILS_DB_PORT=33066
export RAILS_DB_USERNAME=root
export RAILS_DB_NAME=hit_#{wagon}_dev
export RAILS_TEST_DB_NAME=hit_#{core ? "core_test" : "#{wagon}_test"}
export SPRING_APPLICATION_ID=hit_#{core ? "core" : wagon}
export RUBYOPT=-W0
export DISABLE_SPRING=1
export DISABLE_TEST_SCHEMA_MAINTENANCE=1
#{'export WAGONS="' + wagons.join(' ') + '"' if wagons.any?}
log_status "hitobito now uses: #{wagons.any? ? wagons.join(', ') : 'just the core'}"
source_up
Expand All @@ -95,10 +108,6 @@ def available(excluded = %w(youth jubla_ci site))
.compact.reject(&:empty?) - excluded + core_aliases
end

def core?
core_aliases.include?(wagon)
end

def core_aliases
%w(core hitobito)
end
Expand Down
6 changes: 6 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
load File.expand_path("spring", __dir__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
6 changes: 6 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
load File.expand_path("spring", __dir__)
require_relative '../config/boot'
require 'rake'
Rake.application.run
1 change: 1 addition & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ begin
rescue LoadError => e
raise unless e.message.include?('spring')
end
load File.expand_path("spring", __dir__)
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
17 changes: 17 additions & 0 deletions bin/spring
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby

# This file loads Spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.

unless defined?(Spring)
require 'rubygems'
require 'bundler'

lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
if spring
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
require 'spring/binstub'
end
end
23 changes: 0 additions & 23 deletions bin/with_mysql

This file was deleted.

12 changes: 11 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@

require_relative 'boot'

require 'rails/all'
railties = %w[
active_record/railtie
active_storage/engine
action_controller/railtie
action_view/railtie
action_mailer/railtie
active_job/railtie
action_text/engine
rails/test_unit/railtie
sprockets/railtie
].each { |railtie| require railtie }

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
6 changes: 3 additions & 3 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

config.cache_classes = true
config.autoloader = :classic
config.cache_classes = false
config.autoloader = :zeitwerk

# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
Expand All @@ -25,7 +25,7 @@
config.action_controller.perform_caching = false

# Set to false for faster wagon tests once db is setup
config.active_record.maintain_test_schema = true
config.active_record.maintain_test_schema = %w[1 true].exclude?(ENV["DISABLE_TEST_SCHEMA_MAINTENANCE"])

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.4'
services:
db:
image: mysql:5.7
command:
- --sort_buffer_size=2M
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --max_allowed_packet=32505856 # Set max_allowed_packet to 256M (or any other value)
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "1"
ports:
- "33066:3306"
ulimits:
nproc: 65535
nofile:
soft: 20000
hard: 40000
volumes:
- db:/var/lib/mysql

volumes:
db:

0 comments on commit 590bfdd

Please sign in to comment.