modulorails 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +14 -0
  3. data/.gitignore +2 -0
  4. data/.travis.yml +23 -4
  5. data/Appraisals +18 -0
  6. data/CHANGELOG.md +12 -0
  7. data/Dockerfile.ruby25 +34 -0
  8. data/Dockerfile.ruby26 +28 -0
  9. data/Dockerfile.ruby27 +25 -0
  10. data/Dockerfile.ruby30 +25 -0
  11. data/Dockerfile.ruby31 +25 -0
  12. data/Gemfile.lock +59 -52
  13. data/README.md +16 -4
  14. data/Rakefile +1 -1
  15. data/docker-compose.yml +37 -0
  16. data/entrypoints/appraisal_test.sh +7 -0
  17. data/gemfiles/rails_52.gemfile +9 -0
  18. data/gemfiles/rails_60.gemfile +9 -0
  19. data/gemfiles/rails_61.gemfile +9 -0
  20. data/gemfiles/rails_70.gemfile +9 -0
  21. data/lib/generators/{docker → modulorails/docker}/docker_generator.rb +1 -1
  22. data/lib/generators/{docker → modulorails/docker}/templates/Dockerfile.prod.tt +14 -9
  23. data/lib/generators/{docker → modulorails/docker}/templates/Dockerfile.tt +5 -7
  24. data/lib/generators/{docker → modulorails/docker}/templates/config/database.yml.tt +11 -0
  25. data/lib/generators/{docker → modulorails/docker}/templates/docker-compose.prod.yml.tt +18 -4
  26. data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +71 -0
  27. data/lib/generators/{docker → modulorails/docker}/templates/entrypoints/docker-entrypoint.sh.tt +0 -0
  28. data/lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt +7 -0
  29. data/lib/generators/{gitlabci → modulorails/gitlabci}/gitlabci_generator.rb +4 -23
  30. data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +118 -0
  31. data/lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci +6 -0
  32. data/lib/generators/{gitlabci → modulorails/gitlabci}/templates/config/database-ci.yml.tt +0 -0
  33. data/lib/generators/modulorails/healthcheck/health_check_generator.rb +41 -0
  34. data/lib/generators/modulorails/healthcheck/templates/.modulorails-health_check +6 -0
  35. data/lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt +100 -0
  36. data/lib/generators/modulorails/self_update/self_update_generator.rb +32 -0
  37. data/lib/modulorails/configuration.rb +8 -2
  38. data/lib/modulorails/data.rb +21 -2
  39. data/lib/modulorails/railtie.rb +19 -4
  40. data/lib/modulorails/validators/database_configuration.rb +1 -1
  41. data/lib/modulorails/version.rb +1 -1
  42. data/lib/modulorails.rb +34 -15
  43. data/modulorails.gemspec +2 -0
  44. metadata +69 -24
  45. data/lib/generators/docker/templates/docker-compose.yml.tt +0 -37
  46. data/lib/generators/gitlabci/templates/.gitlab-ci.yml.tt +0 -79
  47. data/lib/generators/gitlabci/templates/.modulorails-gitlab-ci +0 -3
  48. data/lib/modulorails/updater.rb +0 -46
@@ -1,10 +1,9 @@
1
1
  version: '3.7'
2
2
 
3
- <% image_name = Modulorails.data.name.parameterize %>
4
-
3
+ <%- image_name = Modulorails.data.name.parameterize -%>
5
4
  services:
6
5
  app:
7
- image: modulotechgroup/<%= image_name %>
6
+ image: modulotechgroup/<%= image_name %>
8
7
  build:
9
8
  context: .
10
9
  dockerfile: Dockerfile.prod
@@ -20,13 +19,28 @@ services:
20
19
  <%= image_name.upcase %>_DATABASE_NAME: <%= image_name %>
21
20
  RAILS_SERVE_STATIC_FILES: 'true'
22
21
 
22
+ <%- adapter = Modulorails.data.adapter -%>
23
+ <%- if adapter =~ /mysql/ -%>
23
24
  database:
24
- image: mysql:8.0
25
+ image: mysql/mysql-server:8.0
25
26
  volumes:
26
27
  - db_data:/var/lib/mysql
27
28
  environment:
28
29
  MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
29
30
  MYSQL_DATABASE: <%= image_name %>
31
+ MYSQL_ROOT_HOST: '%'
32
+ <%- else -%>
33
+ database:
34
+ image: postgres:13.5
35
+ volumes:
36
+ - db_data:/var/lib/postgresql/data
37
+ environment:
38
+ POSTGRES_USER: postgres
39
+ POSTGRES_PASSWORD: postgres
40
+ POSTGRES_DB: <%= image_name %>
41
+ LC_COLLATE: 'en_US.UTF-8'
42
+ LC_CTYPE: 'en_US.UTF-8'
43
+ <%- end -%>
30
44
 
31
45
  redis:
32
46
  image: redis:6.2-alpine
@@ -0,0 +1,71 @@
1
+ version: '3.7'
2
+
3
+ <%- image_name = Modulorails.data.name.parameterize -%>
4
+ services:
5
+ app:
6
+ image: modulotechgroup/<%= image_name %>:dev
7
+ build:
8
+ context: .
9
+ dockerfile: Dockerfile
10
+ depends_on:
11
+ - database
12
+ - redis
13
+ ports:
14
+ - '3000:3000'
15
+ volumes:
16
+ - .:/app
17
+ environment:
18
+ RAILS_ENV: development
19
+ URL: http://localhost:3000
20
+ <%= image_name.upcase %>_DATABASE_HOST: database
21
+ <%= image_name.upcase %>_DATABASE_NAME: <%= image_name %>
22
+ entrypoint: ./entrypoints/docker-entrypoint.sh
23
+
24
+ <%- adapter = Modulorails.data.adapter -%>
25
+ <%- if adapter =~ /mysql/ -%>
26
+ database:
27
+ image: mysql/mysql-server:8.0
28
+ volumes:
29
+ - db_data:/var/lib/mysql
30
+ environment:
31
+ MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
32
+ MYSQL_DATABASE: <%= image_name %>
33
+ MYSQL_ROOT_HOST: '%'
34
+ <%- else-%>
35
+ database:
36
+ image: postgres:13.5
37
+ volumes:
38
+ - db_data:/var/lib/postgresql/data
39
+ environment:
40
+ POSTGRES_USER: postgres
41
+ POSTGRES_PASSWORD: postgres
42
+ POSTGRES_DB: <%= image_name %>
43
+ LC_COLLATE: 'en_US.UTF-8'
44
+ LC_CTYPE: 'en_US.UTF-8'
45
+ <%- end-%>
46
+
47
+ redis:
48
+ image: redis:6.2-alpine
49
+
50
+ mailcatcher:
51
+ image: tophfr/mailcatcher
52
+ ports:
53
+ - 1080:80
54
+
55
+ webpack:
56
+ image: modulotechgroup/<%= image_name %>:dev
57
+ build:
58
+ context: .
59
+ dockerfile: Dockerfile
60
+ entrypoint: ./entrypoints/webpack-entrypoint.sh
61
+ volumes:
62
+ - .:/app
63
+ ports:
64
+ - '3035:3035'
65
+ environment:
66
+ NODE_ENV: development
67
+ RAILS_ENV: development
68
+ WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
69
+
70
+ volumes:
71
+ db_data:
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # Exit immediately if a command exits with a non-zero status
4
+ set -e
5
+
6
+ # Launch webpack
7
+ ./bin/webpack-dev-server
@@ -2,36 +2,17 @@
2
2
 
3
3
  require 'rails/generators'
4
4
 
5
- class GitlabciGenerator < Rails::Generators::Base
5
+ class Modulorails::GitlabciGenerator < Rails::Generators::Base
6
6
  source_root File.expand_path('templates', __dir__)
7
7
  desc 'This generator creates a template for a .gitlab-ci.yml file at root'
8
8
 
9
- # Configurations for MySQL/Postgres dockers
10
- MYSQL_DOCKER_DB = <<~EOS
11
- # Install a MySQL 5.7 database and configure mandatory environment variables
12
- # (https://hub.docker.com/_/mysql/)
13
- services:
14
- - mysql:5.7
15
- variables:
16
- MYSQL_DATABASE: test
17
- MYSQL_ROOT_PASSWORD: password
18
- EOS
19
- POSTGRES_DOCKER_DB = <<~EOS
20
- # Install a Postgres 11 database and configure mandatory environment variables
21
- # (https://hub.docker.com/_/postgres/)
22
- services:
23
- - postgresql:11
24
- variables:
25
- POSTGRES_DB: test
26
- POSTGRES_PASSWORD: password
27
- EOS
28
-
29
9
  def create_config_file
30
10
  # Update the gitlab-ci template
31
11
  template '.gitlab-ci.yml'
32
12
 
33
- # Update the database-ci template
34
- template 'config/database-ci.yml'
13
+ # Remove the database-ci template if it exists.
14
+ # It used to be referenced by the gitlab-ci template.
15
+ remove_file 'config/database-ci.yml'
35
16
 
36
17
  # Create file to avoid this generator on next modulorails launch
37
18
  create_keep_file
@@ -0,0 +1,118 @@
1
+ <%- image_name = Modulorails.data.name.parameterize -%>
2
+ include:
3
+ - project: 'modulosource/modulotech/devops/gitlab-ci-templates'
4
+ file:
5
+ - '/templates/helm.gitlab-ci.yml'
6
+ - '/templates/integration.gitlab-ci.yml'
7
+ - '/templates/docker-buildx.gitlab-ci.yml'
8
+
9
+ services:
10
+ <%- adapter = Modulorails.data.adapter -%>
11
+ <%- if adapter =~ /mysql/ -%>
12
+ - mysql:8.0
13
+ <%- else -%>
14
+ - postgres:13.5
15
+ <%- end -%>
16
+ - redis:6.2
17
+
18
+ variables:
19
+ IMAGE_NAME: <%= image_name %>
20
+ MYSQL_DATABASE: <%= image_name %>_test
21
+ MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
22
+ <%= image_name.upcase %>_DATABASE_HOST: mysql
23
+
24
+ stages:
25
+ - test
26
+ - build
27
+ - deploy
28
+
29
+ test:
30
+ extends: .test
31
+ script:
32
+ - "bundle exec rake db:create RAILS_ENV=test"
33
+ - "RAILS_ENV=test bundle exec rake db:migrate:reset"
34
+ - RAILS_ENV=test bundle exec rspec --format progress --format RspecJunitFormatter --out rspec.xml
35
+
36
+ build_integration_image:
37
+ extends: .build_integration_image
38
+
39
+ docker_build:
40
+ extends: .docker_buildx_push
41
+ only:
42
+ - merge_requests
43
+ - staging
44
+
45
+ <%- review_base_url = Modulorails.data.review_base_url -%>
46
+ <%- if review_base_url.present? -%>
47
+ deploy_review:
48
+ extends: .deploy_helm
49
+ variables:
50
+ NAMESPACE: <%= image_name %>-$CI_ENVIRONMENT_SLUG
51
+ NAME: <%= image_name %>
52
+ CHART_NAME: <%= image_name %>
53
+ CONFIG_FILE: config/deploy/kubernetes/review.yaml
54
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set ingress.hosts[0].host=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set ingress.tls[0].hosts[0]=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set env.url=${CI_ENVIRONMENT_SLUG}.<%= review_base_url %> --set database.password=$DB_PASSWORD --set encryption.key=$ENCRYPTION_KEY
55
+ environment:
56
+ name: review/$CI_COMMIT_REF_SLUG
57
+ url: https://${CI_ENVIRONMENT_SLUG}.<%= review_base_url %>
58
+ on_stop: stop_review
59
+ auto_stop_in: 3 days
60
+ only:
61
+ - merge_requests
62
+
63
+ stop_review:
64
+ extends: .stop_review
65
+ variables:
66
+ NAMESPACE: <%= image_name %>-$CI_ENVIRONMENT_SLUG
67
+ NAME: <%= image_name %>
68
+ only:
69
+ - merge_requests
70
+ <%- end -%>
71
+
72
+ <%- staging_url = Modulorails.data.staging_url -%>
73
+ <%- if staging_url.present? -%>
74
+ deploy_staging:
75
+ extends: .deploy_helm
76
+ variables:
77
+ NAMESPACE: <%= image_name %>
78
+ NAME: <%= image_name %>
79
+ CHART_NAME: <%= image_name %>
80
+ CONFIG_FILE: config/deploy/kubernetes/staging.yaml
81
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.password=$DB_PASSWORD
82
+ environment:
83
+ name: staging
84
+ url: https://<%= staging_url %>
85
+ only:
86
+ - staging
87
+ <%- else -%>
88
+ deploy_staging:
89
+ extends: .deploy_capistrano
90
+ variables:
91
+ STAGE: staging
92
+ only:
93
+ - staging
94
+ <%- end -%>
95
+
96
+ <%- production_url = Modulorails.data.production_url -%>
97
+ <%- if production_url.present? -%>
98
+ deploy_production:
99
+ extends: .deploy_helm
100
+ variables:
101
+ NAMESPACE: <%= image_name %>
102
+ NAME: <%= image_name %>
103
+ CHART_NAME: <%= image_name %>
104
+ CONFIG_FILE: config/deploy/kubernetes/production.yaml
105
+ EXTRA_VARS: --set image.tag=$CI_COMMIT_SHORT_SHA --set database.password=$DB_PASSWORD
106
+ environment:
107
+ name: production
108
+ url: https://<%= production_url %>
109
+ only:
110
+ - master
111
+ <%- else -%>
112
+ deploy_production:
113
+ extends: .deploy_capistrano
114
+ variables:
115
+ STAGE: production
116
+ only:
117
+ - master
118
+ <%- end -%>
@@ -0,0 +1,6 @@
1
+ This file ensures the modulorails gem will not try to override your current .gitlab-ci.yml
2
+ file on Rails start.
3
+
4
+ If you want to reset your CI configuration, you can either:
5
+ - remove this file,
6
+ - or run `rails g modulorails:gitlabci`.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ class Modulorails::HealthCheckGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+ desc 'This generator creates a configuration for the health_check gem'
8
+
9
+ def create_config_file
10
+ # Update the template
11
+ template 'config/initializers/health_check.rb'
12
+
13
+ # Add the route
14
+ unless File.read(Rails.root.join('config/routes.rb')).match?('health_check_routes')
15
+ inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do <<~'RUBY'
16
+ health_check_routes
17
+ RUBY
18
+ end
19
+ end
20
+
21
+ # Update the gem and the Gemfile.lock
22
+ system('bundle install')
23
+
24
+ # Create file to avoid this generator on next modulorails launch
25
+ create_keep_file
26
+ rescue StandardError => e
27
+ $stderr.puts("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
28
+ end
29
+
30
+ private
31
+
32
+ def create_keep_file
33
+ file = '.modulorails-health_check'
34
+
35
+ # Create file to avoid this generator on next modulorails launch
36
+ copy_file(file, file)
37
+
38
+ say "Add #{file} to git"
39
+ %x(git add #{file})
40
+ end
41
+ end
@@ -0,0 +1,6 @@
1
+ This file ensures the modulorails gem will not try to override your current
2
+ config/initializers/health_check.rb file on Rails start.
3
+
4
+ If you want to reset your heal_check configuration, you can either:
5
+ - remove this file,
6
+ - or run `rails g modulorails:health_check`.
@@ -0,0 +1,100 @@
1
+ HealthCheck.setup do |config|
2
+
3
+ # uri prefix (no leading slash)
4
+ config.uri = 'health'
5
+
6
+ # Text output upon success
7
+ config.success = 'success'
8
+
9
+ # Text output upon failure
10
+ config.failure = 'health_check failed'
11
+
12
+ # Disable the error message to prevent /health_check from leaking
13
+ # sensitive information
14
+ config.include_error_in_response_body = false
15
+
16
+ # Log level (success or failure message with error details is sent to rails log unless this is set to nil)
17
+ config.log_level = 'info'
18
+
19
+ # Timeout in seconds used when checking smtp server
20
+ config.smtp_timeout = 30.0
21
+
22
+ # http status code used when plain text error message is output
23
+ # Set to 200 if you want your want to distinguish between partial (text does not include success) and
24
+ # total failure of rails application (http status of 500 etc)
25
+
26
+ config.http_status_for_error_text = 500
27
+
28
+ # http status code used when an error object is output (json or xml)
29
+ # Set to 200 if you want to distinguish between partial (healthy property == false) and
30
+ # total failure of rails application (http status of 500 etc)
31
+
32
+ config.http_status_for_error_object = 500
33
+
34
+ # bucket names to test connectivity - required only if s3 check used, access permissions can be mixed
35
+ # config.buckets = { 'bucket_name' => %i[R W D] }
36
+
37
+ # You can customize which checks happen on a standard health check, eg to set an explicit list use:
38
+ config.standard_checks = %w[database migrations custom]
39
+
40
+ # Or to exclude one check:
41
+ config.standard_checks -= %w[emailconf]
42
+
43
+ # You can set what tests are run with the 'full' or 'all' parameter
44
+ config.full_checks = %w[database migrations custom email cache redis]
45
+ # config.full_checks = %w[database migrations custom email cache redis sidekiq-redis s3]
46
+
47
+ # Add one or more custom checks that return a blank string if ok, or an error message if there is an error
48
+ # config.add_custom_check do
49
+ # CustomHealthCheck.perform_check # any code that returns blank on success and non blank string upon failure
50
+ # end
51
+
52
+ # Add another custom check with a name, so you can call just specific custom checks. This can also be run using
53
+ # the standard 'custom' check.
54
+ # You can define multiple tests under the same name - they will be run one after the other.
55
+ # config.add_custom_check('sometest') do
56
+ # CustomHealthCheck.perform_another_check # any code that returns blank on success and non blank string upon failure
57
+ # end
58
+
59
+ # max-age of response in seconds
60
+ # cache-control is public when max_age > 1 and basic_auth_username is not set
61
+ # You can force private without authentication for longer max_age by
62
+ # setting basic_auth_username but not basic_auth_password
63
+ config.max_age = 1
64
+
65
+ # Protect health endpoints with basic auth
66
+ # These default to nil and the endpoint is not protected
67
+ # config.basic_auth_username = 'my_username'
68
+ # config.basic_auth_password = 'my_password'
69
+
70
+ # Whitelist requesting IPs by a list of IP and/or CIDR ranges, either IPv4 or IPv6 (uses IPAddr.include? method to check)
71
+ # Defaults to blank which allows any IP
72
+ # config.origin_ip_whitelist = %w(123.123.123.123 10.11.12.0/24 2400:cb00::/32)
73
+
74
+ # Use ActionDispatch::Request's remote_ip method when behind a proxy to pick up the real remote IP for origin_ip_whitelist check
75
+ # Otherwise uses Rack::Request's ip method (the default, and always used by Middleware), which is more susceptible to spoofing
76
+ # See https://stackoverflow.com/questions/10997005/whats-the-difference-between-request-remote-ip-and-request-ip-in-rails
77
+ config.accept_proxied_requests = false
78
+
79
+ # http status code used when the ip is not allowed for the request
80
+ config.http_status_for_ip_whitelist_error = 403
81
+
82
+ # rabbitmq
83
+ # config.rabbitmq_config = {}
84
+
85
+ # When redis url/password is non-standard
86
+ config.redis_url = ENV['REDIS_URL']
87
+ # Only included if set, as url can optionally include passwords as well
88
+ # config.redis_password = 'redis_password' # default ENV['REDIS_PASSWORD']
89
+
90
+ # Failure Hooks to do something more ...
91
+ # checks lists the checks requested
92
+ config.on_failure do |checks, msg|
93
+ # log msg somewhere
94
+ end
95
+
96
+ config.on_success do |checks|
97
+ # flag that everything is well
98
+ end
99
+
100
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ # Author: Matthieu 'ciappa_m' Ciappara
6
+ # This updates modulorails by editing the gemfile and running a bundle update
7
+ class Modulorails::SelfUpdateGenerator < Rails::Generators::Base
8
+ source_root File.expand_path('templates', __dir__)
9
+ desc 'This generator updates Modulorails if required'
10
+
11
+ LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'.freeze
12
+
13
+ def create_config_file
14
+ modulorails_version = Gem::Version.new(Modulorails::VERSION)
15
+
16
+ # Get the last published version
17
+ last_published_version_s = HTTParty.get(LATEST_VERSION_URL).parsed_response['version']
18
+ last_published_version = Gem::Version.new(last_published_version_s)
19
+
20
+ # Do nothing if we could not fetch the last published version (whatever the reason)
21
+ # Or if the current version is the same as the last published version
22
+ return if last_published_version <= modulorails_version
23
+
24
+ # Add gem to Gemfile
25
+ gsub_file 'Gemfile', /^\s*gem\s['"]modulorails['"].*$/, "gem 'modulorails', '= #{last_published_version}'"
26
+
27
+ # Update the gem and the Gemfile.lock
28
+ system('bundle install')
29
+ rescue StandardError => e
30
+ $stderr.puts("[Modulorails] Error: cannot generate health_check configuration: #{e.message}")
31
+ end
32
+ end
@@ -4,7 +4,7 @@ module Modulorails
4
4
  class Configuration
5
5
  # All the keys to configure the gem
6
6
  attr_accessor :_name, :_main_developer, :_project_manager, :_endpoint, :_api_key,
7
- :_no_auto_update
7
+ :_no_auto_update, :_production_url, :_staging_url, :_review_base_url
8
8
 
9
9
  # This allows to define a DSL to configure the gem
10
10
  # Example:
@@ -14,8 +14,14 @@ module Modulorails
14
14
  # config.project_manager 'pm@modulotech.fr'
15
15
  # config.endpoint "intranet's endpoint"
16
16
  # config.api_key "intranet's api key"
17
+ # config.production_url "production.app.com"
18
+ # config.staging_url "staging.app.com"
19
+ # config.review_base_url "review.app.com"
17
20
  # end
18
- %i[name main_developer project_manager endpoint api_key no_auto_update].each do |field|
21
+ %i[
22
+ name main_developer project_manager endpoint api_key no_auto_update production_url staging_url
23
+ review_base_url
24
+ ].each do |field|
19
25
  define_method(field) do |value=nil|
20
26
  # No value means we want to get the field
21
27
  return send("_#{field}") unless value
@@ -10,7 +10,8 @@ module Modulorails
10
10
  # All the data handled by this class
11
11
  ATTRIBUTE_KEYS = %i[
12
12
  name main_developer project_manager repository type rails_name ruby_version rails_version
13
- bundler_version modulorails_version adapter db_version adapter_version
13
+ bundler_version modulorails_version adapter db_version adapter_version production_url
14
+ staging_url review_base_url
14
15
  ].freeze
15
16
 
16
17
  # Useful if the gem's user need to read one of the data
@@ -30,7 +31,7 @@ module Modulorails
30
31
  # Get the gem's specifications to fetch the versions of critical gems
31
32
  loaded_specs = Gem.loaded_specs
32
33
 
33
- # The three data written by the user in the configuration
34
+ # The data written by the user in the configuration
34
35
  # The name is the usual name of the project, the one used in conversations at Modulotech
35
36
  @name = configuration.name
36
37
  # The main developer, the lead developer, in short the developer to call when something's
@@ -39,6 +40,19 @@ module Modulorails
39
40
  # The project manager of the application; the other person to call when something's wrong with
40
41
  # the application ;)
41
42
  @project_manager = configuration.project_manager
43
+ # The URL of the production environment for the application
44
+ @production_url = configuration.production_url
45
+ # The URL of the staging environment for the application
46
+ @staging_url = configuration.staging_url
47
+ # The base URL of the review environment for the application.
48
+ # A real review URL is built like this at Modulotech:
49
+ # https://review-#{shortened_branch_name}-#{ci_slug}.#{review_base_url}
50
+ # Example:
51
+ # review_base_url: dev.app.com
52
+ # branch_name: 786-a_super_branch => shortened_branch_name: 786-a_sup
53
+ # ci_slug: jzzham
54
+ # |-> https://review-786-a_sup-jzzham.dev.app.com/
55
+ @review_base_url = configuration.review_base_url
42
56
 
43
57
  # Theorically, origin is the main repository of the project and git is the sole VCS we use
44
58
  # at Modulotech
@@ -101,6 +115,11 @@ module Modulorails
101
115
  'adapter' => @adapter,
102
116
  'db_version' => @db_version,
103
117
  'gem_version' => @adapter_version
118
+ },
119
+ 'urls' => {
120
+ 'production' => @production_url,
121
+ 'staging' => @staging_url,
122
+ 'review_base' => @review_base_url
104
123
  }
105
124
  }
106
125
  }
@@ -1,9 +1,24 @@
1
1
  module Modulorails
2
+ # Bind in the Rails lifecycle
2
3
  class Railtie < ::Rails::Railtie
3
- # Binding in the Rails lifecycle. Sending data after the initialization ensures we can access
4
- # all gems and symbols we might have to use.
4
+ # Update and add gems before we load the configuration
5
+ config.before_configuration do
6
+ # Currently, we limit everything to the development environment
7
+ if Rails.env.development?
8
+ # Check database configuration
9
+ Modulorails.generate_healthcheck_template
10
+ end
11
+ end
12
+
13
+ # Require the gem before we read the health_check initializer
14
+ config.before_initialize do
15
+ require 'health_check'
16
+ end
17
+
18
+ # Sending data after the initialization ensures we can access
19
+ # all gems, constants and configurations we might need.
5
20
  config.after_initialize do
6
- # For now, we limit everything to the development environment
21
+ # Currently, we limit everything to the development environment
7
22
  if Rails.env.development?
8
23
  # Load translations
9
24
  I18n.load_path += [File.expand_path('../../../config/locales/en.yml', __FILE__)]
@@ -18,7 +33,7 @@ module Modulorails
18
33
  Modulorails.check_database_config
19
34
 
20
35
  # Gem's self-update if a new version was released
21
- # Modulorails.self_update
36
+ Modulorails.self_update
22
37
  end
23
38
  end
24
39
  end
@@ -31,7 +31,7 @@ module Modulorails
31
31
 
32
32
  def call
33
33
  database_configuration = check_standard_config_file_location
34
- return false unless database_configuration
34
+ return [:standard_config_file_location] unless database_configuration
35
35
 
36
36
  check_test_database_not_equals_dev_database(database_configuration)
37
37
  check_rules_for_environment(database_configuration, :development)
@@ -1,3 +1,3 @@
1
1
  module Modulorails
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end