modulorails 0.2.2 → 1.0.1

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +14 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +62 -0
  5. data/.travis.yml +23 -4
  6. data/Appraisals +18 -0
  7. data/CHANGELOG.md +42 -1
  8. data/Dockerfile.ruby25 +34 -0
  9. data/Dockerfile.ruby26 +28 -0
  10. data/Dockerfile.ruby27 +25 -0
  11. data/Dockerfile.ruby30 +25 -0
  12. data/Dockerfile.ruby31 +25 -0
  13. data/Gemfile.lock +59 -54
  14. data/README.md +16 -4
  15. data/Rakefile +1 -1
  16. data/app/assets/stylesheets/modulorails.css +21 -0
  17. data/app/helpers/modulorails/application_helper.rb +8 -0
  18. data/config/locales/en.yml +3 -0
  19. data/docker-compose.debug.yml +47 -0
  20. data/docker-compose.yml +37 -0
  21. data/entrypoints/appraisal_test.sh +7 -0
  22. data/gemfiles/rails_52.gemfile +9 -0
  23. data/gemfiles/rails_60.gemfile +9 -0
  24. data/gemfiles/rails_61.gemfile +9 -0
  25. data/gemfiles/rails_70.gemfile +9 -0
  26. data/lib/generators/modulorails/docker/docker_generator.rb +19 -0
  27. data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +57 -0
  28. data/lib/generators/modulorails/docker/templates/Dockerfile.tt +26 -0
  29. data/lib/generators/modulorails/docker/templates/config/database.yml.tt +32 -0
  30. data/lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt +50 -0
  31. data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +71 -0
  32. data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +20 -0
  33. data/lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt +7 -0
  34. data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +34 -0
  35. data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +118 -0
  36. data/lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci +6 -0
  37. data/lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt +8 -0
  38. data/lib/generators/modulorails/healthcheck/health_check_generator.rb +41 -0
  39. data/lib/generators/modulorails/healthcheck/templates/.modulorails-health_check +6 -0
  40. data/lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt +100 -0
  41. data/lib/generators/modulorails/rubocop/rubocop_generator.rb +24 -0
  42. data/lib/generators/modulorails/rubocop/templates/rubocop.yml.tt +18 -0
  43. data/lib/generators/modulorails/self_update/self_update_generator.rb +32 -0
  44. data/lib/generators/modulorails/service/service_generator.rb +13 -0
  45. data/lib/generators/modulorails/service/templates/service.rb.tt +28 -0
  46. data/lib/modulorails/configuration.rb +8 -2
  47. data/lib/modulorails/data.rb +21 -2
  48. data/lib/modulorails/error_data.rb +21 -0
  49. data/lib/modulorails/errors/base_error.rb +4 -0
  50. data/lib/modulorails/errors/errors.rb +3 -0
  51. data/lib/modulorails/errors/invalid_format_error.rb +14 -0
  52. data/lib/modulorails/errors/invalid_value_error.rb +14 -0
  53. data/lib/modulorails/railtie.rb +35 -3
  54. data/lib/modulorails/services/base_service.rb +203 -0
  55. data/lib/modulorails/services/logs_for_method_service.rb +42 -0
  56. data/lib/modulorails/services/services.rb +2 -0
  57. data/lib/modulorails/success_data.rb +17 -0
  58. data/lib/modulorails/validators/database_configuration.rb +9 -3
  59. data/lib/modulorails/version.rb +4 -1
  60. data/lib/modulorails.rb +46 -21
  61. data/modulorails.gemspec +4 -0
  62. metadata +114 -17
  63. data/lib/generators/gitlabci_generator.rb +0 -134
  64. data/lib/generators/templates/.gitlab-ci.yml +0 -72
  65. data/lib/generators/templates/.modulorails-gitlab-ci +0 -3
  66. data/lib/generators/templates/config/database-ci.yml +0 -7
  67. data/lib/modulorails/updater.rb +0 -46
data/lib/modulorails.rb CHANGED
@@ -2,10 +2,16 @@ require 'modulorails/version'
2
2
  require 'modulorails/configuration'
3
3
  require 'modulorails/data'
4
4
  require 'modulorails/validators/database_configuration'
5
- require 'modulorails/updater'
6
5
  require 'modulorails/railtie' if defined?(Rails::Railtie)
7
- require 'generators/gitlabci_generator'
6
+ require 'generators/modulorails/gitlabci/gitlabci_generator'
7
+ require 'generators/modulorails/healthcheck/health_check_generator'
8
+ require 'generators/modulorails/self_update/self_update_generator'
9
+ require 'generators/modulorails/rubocop/rubocop_generator'
8
10
  require 'httparty'
11
+ require 'modulorails/error_data'
12
+ require 'modulorails/success_data'
13
+ require 'modulorails/errors/errors'
14
+ require 'modulorails/services/services'
9
15
 
10
16
  # Author: Matthieu 'ciappa_m' Ciappara
11
17
  # The entry point of the gem. It exposes the configurator, the gathered data and the method to
@@ -77,17 +83,25 @@ module Modulorails
77
83
  # Define the JSON body of the request
78
84
  body = data.to_params.to_json
79
85
 
80
- # Post to the configured endpoint on the Intranet
81
- response = HTTParty.post(configuration.endpoint, headers: headers, body: body)
82
-
83
- # According to the API specification, on a "Bad request" response, the server explicits what
84
- # went wrong with an `errors` field. We do not want to raise since the gem's user is not
85
- # (necessarily) responsible for the error but we still need to display it somewhere to warn
86
- # the user something went wrong.
87
- puts("[Modulorails] Error: #{response['errors'].join(', ')}") if response.code == 400
88
-
89
- # Return the response to allow users to do some more
90
- response
86
+ # Prevent HTTParty to raise error and crash the server in dev
87
+ begin
88
+ # Post to the configured endpoint on the Intranet
89
+ response = HTTParty.post(configuration.endpoint, headers: headers, body: body)
90
+
91
+ # According to the API specification, on a "Bad request" response, the server explicits what
92
+ # went wrong with an `errors` field. We do not want to raise since the gem's user is not
93
+ # (necessarily) responsible for the error but we still need to display it somewhere to warn
94
+ # the user something went wrong.
95
+ puts("[Modulorails] Error: #{response['errors'].join(', ')}") if response.code == 400
96
+
97
+ # Return the response to allow users to do some more
98
+ response
99
+ rescue StandardError => e
100
+ # Still need to notify the user
101
+ puts("[Modulorails] Error: Could not post to #{configuration.endpoint}")
102
+ puts e.message
103
+ nil
104
+ end
91
105
  else
92
106
  raise Error.new('No endpoint or api key')
93
107
  end
@@ -100,13 +114,7 @@ module Modulorails
100
114
  def generate_ci_template
101
115
  return if File.exists?(Rails.root.join('.modulorails-gitlab-ci'))
102
116
 
103
- generator_options = [
104
- '--app', data.rails_name.parameterize,
105
- '--database', data.adapter,
106
- '--bundler', data.bundler_version,
107
- '--ruby_version', data.ruby_version
108
- ]
109
- GitlabciGenerator.new([], generator_options, {}).invoke_all
117
+ Modulorails::GitlabciGenerator.new([], {}, {}).invoke_all
110
118
  end
111
119
 
112
120
  # @author Matthieu 'ciappa_m' Ciappara
@@ -130,9 +138,26 @@ module Modulorails
130
138
  # Check the last version of Modulorails available on rubygems and update if there was a
131
139
  # publication
132
140
  def self_update
133
- Modulorails::Updater.call unless configuration.no_auto_update
141
+ Modulorails::SelfUpdateGenerator.new([], {}, {}).invoke_all unless configuration.no_auto_update
134
142
  rescue StandardError => e
135
143
  puts("[Modulorails] An error occured: #{e.class} - #{e.message}")
136
144
  end
145
+
146
+ # @author Matthieu 'ciappa_m' Ciappara
147
+ #
148
+ # Generate a health_check configuration unless it was already done.
149
+ # The check is done using a 'keepfile'.
150
+ def generate_healthcheck_template
151
+ return if File.exists?(Rails.root.join('.modulorails-health_check'))
152
+
153
+ Modulorails::HealthCheckGenerator.new([], {}, {}).invoke_all
154
+ end
155
+
156
+ # @author Matthieu 'ciappa_m' Ciappara
157
+ #
158
+ # Generate a rubocop configuration.
159
+ def generate_rubocop_template
160
+ Modulorails::RubocopGenerator.new([], {}, {}).invoke_all
161
+ end
137
162
  end
138
163
  end
data/modulorails.gemspec CHANGED
@@ -33,6 +33,10 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency 'git', '~> 1.7', '>= 1.7.0'
34
34
  spec.add_runtime_dependency 'httparty'
35
35
  spec.add_runtime_dependency 'i18n'
36
+ spec.add_runtime_dependency 'health_check', '~> 3.1'
37
+ spec.add_runtime_dependency 'rubocop', '= 1.25.1'
38
+ spec.add_runtime_dependency 'rubocop-rails', '= 2.13.2'
36
39
 
37
40
  spec.add_development_dependency 'activerecord', '>= 4.2.0'
41
+ spec.add_development_dependency 'appraisal'
38
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulorails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu Ciappara
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -28,22 +28,22 @@ dependencies:
28
28
  name: git
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.7'
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
33
  version: 1.7.0
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '1.7'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '1.7'
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
43
  version: 1.7.0
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: httparty
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +72,48 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: health_check
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.1'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 1.25.1
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 1.25.1
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-rails
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.13.2
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '='
115
+ - !ruby/object:Gem::Version
116
+ version: 2.13.2
75
117
  - !ruby/object:Gem::Dependency
76
118
  name: activerecord
77
119
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +128,20 @@ dependencies:
86
128
  - - ">="
87
129
  - !ruby/object:Gem::Version
88
130
  version: 4.2.0
131
+ - !ruby/object:Gem::Dependency
132
+ name: appraisal
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
89
145
  description: |
90
146
  Modulorails is the common base for the Ruby on Rails project at Modulotech
91
147
  (https://www.modulotech.fr/).
@@ -98,28 +154,69 @@ executables: []
98
154
  extensions: []
99
155
  extra_rdoc_files: []
100
156
  files:
157
+ - ".dockerignore"
101
158
  - ".gitignore"
102
159
  - ".rspec"
160
+ - ".rubocop.yml"
103
161
  - ".travis.yml"
162
+ - Appraisals
104
163
  - CHANGELOG.md
105
164
  - CODE_OF_CONDUCT.md
165
+ - Dockerfile.ruby25
166
+ - Dockerfile.ruby26
167
+ - Dockerfile.ruby27
168
+ - Dockerfile.ruby30
169
+ - Dockerfile.ruby31
106
170
  - Gemfile
107
171
  - Gemfile.lock
108
172
  - LICENSE.txt
109
173
  - README.md
110
174
  - Rakefile
175
+ - app/assets/stylesheets/modulorails.css
176
+ - app/helpers/modulorails/application_helper.rb
111
177
  - bin/console
112
178
  - bin/setup
113
179
  - config/locales/en.yml
114
- - lib/generators/gitlabci_generator.rb
115
- - lib/generators/templates/.gitlab-ci.yml
116
- - lib/generators/templates/.modulorails-gitlab-ci
117
- - lib/generators/templates/config/database-ci.yml
180
+ - docker-compose.debug.yml
181
+ - docker-compose.yml
182
+ - entrypoints/appraisal_test.sh
183
+ - gemfiles/rails_52.gemfile
184
+ - gemfiles/rails_60.gemfile
185
+ - gemfiles/rails_61.gemfile
186
+ - gemfiles/rails_70.gemfile
187
+ - lib/generators/modulorails/docker/docker_generator.rb
188
+ - lib/generators/modulorails/docker/templates/Dockerfile.prod.tt
189
+ - lib/generators/modulorails/docker/templates/Dockerfile.tt
190
+ - lib/generators/modulorails/docker/templates/config/database.yml.tt
191
+ - lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt
192
+ - lib/generators/modulorails/docker/templates/docker-compose.yml.tt
193
+ - lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt
194
+ - lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt
195
+ - lib/generators/modulorails/gitlabci/gitlabci_generator.rb
196
+ - lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt
197
+ - lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci
198
+ - lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt
199
+ - lib/generators/modulorails/healthcheck/health_check_generator.rb
200
+ - lib/generators/modulorails/healthcheck/templates/.modulorails-health_check
201
+ - lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt
202
+ - lib/generators/modulorails/rubocop/rubocop_generator.rb
203
+ - lib/generators/modulorails/rubocop/templates/rubocop.yml.tt
204
+ - lib/generators/modulorails/self_update/self_update_generator.rb
205
+ - lib/generators/modulorails/service/service_generator.rb
206
+ - lib/generators/modulorails/service/templates/service.rb.tt
118
207
  - lib/modulorails.rb
119
208
  - lib/modulorails/configuration.rb
120
209
  - lib/modulorails/data.rb
210
+ - lib/modulorails/error_data.rb
211
+ - lib/modulorails/errors/base_error.rb
212
+ - lib/modulorails/errors/errors.rb
213
+ - lib/modulorails/errors/invalid_format_error.rb
214
+ - lib/modulorails/errors/invalid_value_error.rb
121
215
  - lib/modulorails/railtie.rb
122
- - lib/modulorails/updater.rb
216
+ - lib/modulorails/services/base_service.rb
217
+ - lib/modulorails/services/logs_for_method_service.rb
218
+ - lib/modulorails/services/services.rb
219
+ - lib/modulorails/success_data.rb
123
220
  - lib/modulorails/validators/database_configuration.rb
124
221
  - lib/modulorails/version.rb
125
222
  - modulorails.gemspec
@@ -130,7 +227,7 @@ metadata:
130
227
  homepage_uri: https://github.com/moduloTech/modulorails
131
228
  source_code_uri: https://github.com/moduloTech/modulorails
132
229
  changelog_uri: https://github.com/moduloTech/modulorails/blob/master/CHANGELOG.md
133
- post_install_message:
230
+ post_install_message:
134
231
  rdoc_options: []
135
232
  require_paths:
136
233
  - lib
@@ -145,8 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
242
  - !ruby/object:Gem::Version
146
243
  version: '0'
147
244
  requirements: []
148
- rubygems_version: 3.1.2
149
- signing_key:
245
+ rubygems_version: 3.0.3
246
+ signing_key:
150
247
  specification_version: 4
151
248
  summary: Common base for Ruby on Rails projects at Modulotech
152
249
  test_files: []
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators'
4
-
5
- class GitlabciGenerator < Rails::Generators::Base
6
- source_root File.expand_path('templates', __dir__)
7
- class_option(:app,
8
- required: true, type: :string,
9
- desc: 'Specify the application name.')
10
- class_option(:database,
11
- required: true, type: :string,
12
- desc: 'Specify the database to use (either mysql or postgres).')
13
- class_option(:bundler,
14
- required: true, type: :string,
15
- desc: 'Specify the Bundler version.')
16
- class_option(:ruby_version,
17
- required: true, type: :string,
18
- desc: 'Specify the Ruby version.')
19
- desc 'This generator creates a template for a .gitlab-ci.yml file at root'
20
-
21
- # Configurations for MySQL/Postgres dockers
22
- MYSQL_DOCKER_DB = <<~EOS
23
- # Install a MySQL 5.7 database and configure mandatory environment variables
24
- # (https://hub.docker.com/_/mysql/)
25
- services:
26
- - mysql:5.7
27
- variables:
28
- MYSQL_DATABASE: test
29
- MYSQL_ROOT_PASSWORD: password
30
- EOS
31
- POSTGRES_DOCKER_DB = <<~EOS
32
- # Install a Postgres 11 database and configure mandatory environment variables
33
- # (https://hub.docker.com/_/postgres/)
34
- services:
35
- - postgresql:11
36
- variables:
37
- POSTGRES_DB: test
38
- POSTGRES_PASSWORD: password
39
- EOS
40
-
41
- def create_config_file
42
- # Get the configuration for the database engine
43
- db_conf = database_config(options[:database])
44
-
45
- # Update the gitlab-ci template
46
- update_gitlab_ci(options, db_conf)
47
-
48
- # Update the database-ci template
49
- update_database_ci(db_conf)
50
-
51
- # Create file to avoid this generator on next modulorails launch
52
- create_keep_file
53
- rescue StandardError => e
54
- $stderr.puts("[Modulorails] Error: cannot generate CI configuration: #{e.message}")
55
- end
56
-
57
- private
58
-
59
- def update_gitlab_ci(options, db_conf)
60
- file = '.gitlab-ci.yml'
61
- exists = File.exists?(file)
62
-
63
- # Remove original file if there is one
64
- remove_file file if exists
65
-
66
- # Copy file
67
- copy_file file, file
68
-
69
- # Add the correct database docker
70
- prepend_file file, db_conf[:header]
71
-
72
- # Replace key for CI/CD cache
73
- gsub_file file, 'CI_CD_CACHE_KEY', "#{options[:app]}-ci_cd"
74
-
75
- # Replace key for bundler version
76
- gsub_file file, 'BUNDLER_VERSION', options[:bundler]
77
-
78
- # Replace ruby version
79
- gsub_file file, 'RUBY_VERSION', '2.5.0'
80
-
81
- # Warn the user about file overwrite/creation
82
- warn_file_update(file, exists)
83
- end
84
-
85
- def update_database_ci(db_conf)
86
- file = 'config/database-ci.yml'
87
- exists = File.exists?(file)
88
-
89
- # Remove original file if there is one
90
- remove_file file if exists
91
-
92
- # Copy file
93
- copy_file file, file
94
-
95
- # Replace configuration
96
- gsub_file file, 'HOST', db_conf[:host]
97
- gsub_file file, 'ADAPTER', db_conf[:adapter]
98
- gsub_file file, 'DATABASE', 'test'
99
-
100
- # Warn the user about file overwrite/creation
101
- warn_file_update(file, exists)
102
- end
103
-
104
- def database_config(database)
105
- case database
106
- when 'mysql', 'mysql2'
107
- { header: MYSQL_DOCKER_DB, host: 'mysql', adapter: 'mysql2' }
108
- when 'postgres', 'postgresql'
109
- { header: POSTGRES_DOCKER_DB, host: 'postgres', adapter: 'postgresql' }
110
- else
111
- raise "Unknown database adapter `#{database}`: either mysql or postgres"
112
- end
113
- end
114
-
115
- def warn_file_update(file, exists)
116
- intro = if exists
117
- "/!\\ Watch out! Your #{file} was overwritten"
118
- else
119
- "A new file #{file} was added"
120
- end
121
-
122
- say "#{intro} by Modulorails. Ensure everything is correct!"
123
- end
124
-
125
- def create_keep_file
126
- file = '.modulorails-gitlab-ci'
127
-
128
- # Create file to avoid this generator on next modulorails launch
129
- copy_file(file, file)
130
-
131
- say "Add #{file} to git"
132
- %x(git add #{file})
133
- end
134
- end
@@ -1,72 +0,0 @@
1
- image: ruby:RUBY_VERSION
2
- stages:
3
- - lint
4
- - test
5
- - deploy
6
- cache:
7
- key: CI_CD_CACHE_KEY
8
- paths:
9
- - vendor/ruby
10
-
11
- before_script:
12
- - apt-get update -qy
13
- - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
14
- - eval $(ssh-agent -s)
15
- - ssh-add <(echo "$SSH_PRIVATE_KEY")
16
- - mkdir -p ~/.ssh
17
- - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
18
- - apt-get install -y ruby-dev
19
- - gem install bundler -v BUNDLER_VERSION --no-document
20
- # You might need DPL if you're deploying using Heroku
21
- #- gem install dpl -v 1.10.15 --no-document
22
- # You might need to add some configurations here like a key for a theme
23
- #- bundle config gems.rapidrailsthemes.com "$RRT_CFG"
24
- - bundle install -j $(nproc) --path vendor
25
-
26
- rubocop:
27
- stage: lint
28
- script:
29
- - bundle exec rubocop -D
30
- tags:
31
- - rails
32
- except:
33
- - master
34
- - staging
35
-
36
- test:
37
- stage: test
38
- script:
39
- - cp config/database-ci.yml config/database.yml
40
- - "bundle exec rake db:create RAILS_ENV=test"
41
- - "RAILS_ENV=test bundle exec rake db:migrate:reset"
42
- - bundle exec rspec
43
- tags:
44
- - rails
45
- except:
46
- - master
47
-
48
- staging:
49
- stage: deploy
50
- script:
51
- # Uncomment the next line and update the application name if you're using DPL to deploy on
52
- # Heroku
53
- #- dpl --provider=heroku --app=APP_NAME --api-key=$HEROKU_API_KEY
54
- # Remove the next line if you're not using Capistrano
55
- - bundle exec cap staging deploy
56
- only:
57
- - staging
58
- tags:
59
- - rails
60
-
61
- production:
62
- stage: deploy
63
- script:
64
- # Uncomment the next line and update the application name if you're using DPL to deploy on
65
- # Heroku
66
- #- dpl --provider=heroku --app=APP_NAME --api-key=$HEROKU_API_KEY
67
- # Remove the next line if you're not using Capistrano
68
- - bundle exec cap production deploy
69
- only:
70
- - master
71
- tags:
72
- - rails
@@ -1,3 +0,0 @@
1
- This file ensures the modulorails gem will not try to override your current .gitlab-ci.yml file.
2
-
3
- You can remove this file if you want the generator to rewrite your .gitlab-ci.yml file.
@@ -1,7 +0,0 @@
1
- test:
2
- host: HOST
3
- adapter: ADAPTER
4
- database: DATABASE
5
- username: root
6
- password: password
7
- encoding: utf8
@@ -1,46 +0,0 @@
1
- module Modulorails
2
- # Author: Matthieu 'ciappa_m' Ciappara
3
- # This updates modulorails by editing the gemfile and running a bundle update
4
- class Updater
5
- LATEST_VERSION_URL = 'https://rubygems.org/api/v1/versions/modulorails/latest.json'.freeze
6
-
7
- def self.call(*args)
8
- new(*args).call
9
- end
10
-
11
- def call
12
- # Get the last published version
13
- @last_published_version = HTTParty.get(LATEST_VERSION_URL).parsed_response['version']
14
-
15
- # Do nothing if we could not fetch the last published version (whatever the reason)
16
- # Or if the current version is the same as the last published version
17
- return if @last_published_version.nil? || @last_published_version == Modulorails::VERSION
18
-
19
- # If the last published version is different from the current version, we update the gem
20
- edit_gemfile
21
- end
22
-
23
- private
24
-
25
- def edit_gemfile
26
- # Log to warn the user
27
- puts("[Modulorails] Last version for modulorails is #{@last_published_version} while you "\
28
- "are using version #{Modulorails::VERSION}. Running auto-update.")
29
-
30
- # Read the lines of the Gemfile
31
- gemfile_location = Rails.root.join('Gemfile')
32
- lines = File.readlines gemfile_location
33
-
34
- # Search and replace the modulorails line
35
- index = lines.index { |l| l =~ /gem\s['"]modulorails['"]/ }
36
- lines[index].gsub!(/(\s*)gem\s['"]modulorails['"].*/,
37
- "#{$1}gem 'modulorails', '= #{@last_published_version}'")
38
-
39
- # Update the Gemfile
40
- File.open(gemfile_location, 'w') { |f| f.puts(lines) }
41
-
42
- # Update the gem and the Gemfile.lock
43
- system('bundle install')
44
- end
45
- end
46
- end