launch_base 0.1.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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +98 -0
- data/LICENSE.txt +21 -0
- data/README.md +100 -0
- data/bin/launch_base +9 -0
- data/launch_base.gemspec +45 -0
- data/lib/launch_base.rb +2 -0
- data/lib/launch_base/cli.rb +54 -0
- data/lib/launch_base/lint_cli.rb +34 -0
- data/lib/launch_base/utilities.rb +14 -0
- data/lib/launch_base/version.rb +5 -0
- data/templates/.codeclimate.yml +73 -0
- data/templates/.eslintrc.json +19 -0
- data/templates/.mdlrc +1 -0
- data/templates/.rspec +3 -0
- data/templates/.rubocop.yml +133 -0
- data/templates/.ruby-gemset +1 -0
- data/templates/.ruby-version +1 -0
- data/templates/Jenkinsfile.erb +94 -0
- data/templates/README.md.erb +66 -0
- data/templates/app.json.erb +15 -0
- data/templates/app/controllers/homepage_controller.rb +4 -0
- data/templates/bin/ci +17 -0
- data/templates/bin/post_deploy +4 -0
- data/templates/config.reek +60 -0
- data/templates/config/database.yml.erb +20 -0
- data/templates/dockerfiles/ci/Dockerfile +45 -0
- data/templates/launch_base_default_template.rb +149 -0
- data/templates/spec/features/homepage_spec.rb +7 -0
- data/templates/spec/rails_helper.rb +25 -0
- data/templates/spec/requests/ping_spec.rb +8 -0
- data/templates/spec/support/capybara.rb +30 -0
- data/templates/spec/support/factory_bot.rb +3 -0
- data/templates/spec/support/feature_spec_helpers.rb +2 -0
- data/templates/spec/support/spec_helpers.rb +2 -0
- metadata +237 -0
data/templates/.mdlrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rules "~MD026", "~MD013"
|
data/templates/.rspec
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# https://rubocop.readthedocs.io/
|
2
|
+
AllCops:
|
3
|
+
Include:
|
4
|
+
- '**/Gemfile'
|
5
|
+
- '**/Rakefile'
|
6
|
+
- config.ru
|
7
|
+
- '**/*.gemspec'
|
8
|
+
Exclude:
|
9
|
+
- db/schema.rb
|
10
|
+
|
11
|
+
# Longer line length
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Max: 150
|
17
|
+
CountComments: false
|
18
|
+
|
19
|
+
# Methods can be 15 lines long
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 15
|
22
|
+
|
23
|
+
# Prefer raise over fail
|
24
|
+
Style/SignalException:
|
25
|
+
EnforcedStyle: only_raise
|
26
|
+
|
27
|
+
# Make literal hashes act like arrays
|
28
|
+
Layout/SpaceInsideHashLiteralBraces:
|
29
|
+
EnforcedStyle: space
|
30
|
+
|
31
|
+
Layout/MultilineMethodCallIndentation:
|
32
|
+
Enabled: true
|
33
|
+
EnforcedStyle: indented_relative_to_receiver
|
34
|
+
|
35
|
+
# Disable the documentation requirement
|
36
|
+
Style/Documentation:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Allow the usage of begin blocks
|
40
|
+
Style/BeginBlock:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Allow usage of regular array notation, which is familiar to non rubyists as well
|
44
|
+
Style/WordArray:
|
45
|
+
Enabled: true
|
46
|
+
EnforcedStyle: brackets
|
47
|
+
|
48
|
+
Style/SymbolArray:
|
49
|
+
Enabled: true
|
50
|
+
EnforcedStyle: brackets
|
51
|
+
|
52
|
+
# Enforce nested module/class notation.
|
53
|
+
# Note: We decided this may be disabled for controllers, add an rubocop file in the controller folder, that inherits from this file and disable the rule if preferred
|
54
|
+
Style/ClassAndModuleChildren:
|
55
|
+
Enabled: true
|
56
|
+
|
57
|
+
# Disable check for emptymethod. It would enforce semicolons otherwise, and we are allergic to those
|
58
|
+
Style/EmptyMethod:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
# Force Ruby 1.9 syntax and do not mix key types
|
62
|
+
Style/HashSyntax:
|
63
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
64
|
+
|
65
|
+
# Array indentation has to be consistent, but it is more flexible
|
66
|
+
Layout/IndentArray:
|
67
|
+
EnforcedStyle: consistent
|
68
|
+
|
69
|
+
# Hash indentation has to be consistent, but it is more flexible
|
70
|
+
Layout/IndentHash:
|
71
|
+
EnforcedStyle: consistent
|
72
|
+
|
73
|
+
# Use rails indentation
|
74
|
+
Layout/IndentationConsistency:
|
75
|
+
EnforcedStyle: normal
|
76
|
+
|
77
|
+
# Do not trail do end blocks with extra function calls
|
78
|
+
Style/MethodCalledOnDoEndBlock:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
# Do not enforce the use of `next if <condition>` instead of `unless <condition> ... end`
|
82
|
+
Style/Next:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
# Complex inline ifs need ()
|
86
|
+
Style/TernaryParentheses:
|
87
|
+
EnforcedStyle: require_parentheses_when_complex
|
88
|
+
|
89
|
+
Style/StringLiterals:
|
90
|
+
EnforcedStyle: single_quotes
|
91
|
+
# Use consistent quotes when multi-lining strings
|
92
|
+
ConsistentQuotesInMultiline: true
|
93
|
+
|
94
|
+
Style/FrozenStringLiteralComment:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
# Allow usage :"symbol"
|
98
|
+
Style/SymbolLiteral:
|
99
|
+
Enabled: false
|
100
|
+
|
101
|
+
# We usually only flatten only level so we can enable this feature
|
102
|
+
Performance/FlatMap:
|
103
|
+
EnabledForFlattenWithoutParams: true
|
104
|
+
|
105
|
+
# Force strict date getting to it handles better with activerecord dates
|
106
|
+
Rails/Date:
|
107
|
+
EnforcedStyle: strict
|
108
|
+
|
109
|
+
# Rails 5 cop
|
110
|
+
Rails/HttpPositionalArguments:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
# No need to sort gems in the bundle file
|
114
|
+
Bundler/OrderedGems:
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
# Don't check on block length in spec files.
|
118
|
+
# `describe` and `context` blocks can be large.
|
119
|
+
Metrics/BlockLength:
|
120
|
+
Exclude:
|
121
|
+
- 'spec/**/*_spec.rb'
|
122
|
+
|
123
|
+
Security/Eval:
|
124
|
+
Exclude:
|
125
|
+
- 'spec/*.rb'
|
126
|
+
- 'spec/**/*.rb'
|
127
|
+
|
128
|
+
# Do not suggest to rename `has_x?` to `x?`
|
129
|
+
Naming:
|
130
|
+
Enabled: false
|
131
|
+
|
132
|
+
Layout/MultilineMethodCallIndentation:
|
133
|
+
EnforcedStyle: indented_relative_to_receiver
|
@@ -0,0 +1 @@
|
|
1
|
+
launch-base
|
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
@@ -0,0 +1,94 @@
|
|
1
|
+
projectId = "<%= @app_id %>"
|
2
|
+
|
3
|
+
pipeline {
|
4
|
+
agent any
|
5
|
+
|
6
|
+
options {
|
7
|
+
ansiColor("xterm")
|
8
|
+
}
|
9
|
+
|
10
|
+
stages {
|
11
|
+
stage("Tests") {
|
12
|
+
agent {
|
13
|
+
dockerfile {
|
14
|
+
filename "dockerfiles/ci/Dockerfile"
|
15
|
+
additionalBuildArgs support.ciDockerFileBuildArgs()
|
16
|
+
args "${support.ciDockerFileRunArgs(projectId)} -u root"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
environment {
|
21
|
+
RAILS_ENV = 'test'
|
22
|
+
CODECLIMATE_REPO_TOKEN = credentials('<%= @app_id %>_codeclimate_test_reporter_id')
|
23
|
+
}
|
24
|
+
|
25
|
+
steps {
|
26
|
+
sh "service postgres start"
|
27
|
+
sh "bundle config --global jobs \$(cat /proc/cpuinfo | grep -c processor)"
|
28
|
+
sh "bin/ci"
|
29
|
+
}
|
30
|
+
|
31
|
+
post {
|
32
|
+
always {
|
33
|
+
script {
|
34
|
+
support.restoreWorkspacePermissions()
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
stage("Set APP_ENV for staging") {
|
41
|
+
when {
|
42
|
+
branch 'staging/*'
|
43
|
+
}
|
44
|
+
steps {
|
45
|
+
script {
|
46
|
+
env.APP_ENV = 'staging'
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
stage("Deploy to Dokku staging") {
|
52
|
+
when {
|
53
|
+
branch 'staging/*'
|
54
|
+
}
|
55
|
+
steps {
|
56
|
+
sh 'ssh-keyscan -H <%= @app_id %>.staging.kabisa.nl >> ~/.ssh/known_hosts # only needed on the first run'
|
57
|
+
sh 'git remote | grep dokku-staging >/dev/null || git remote add dokku-staging dokku@<%= @app_id %>.staging.kabisa.nl:<%= @app_id %>-staging'
|
58
|
+
sh 'git push dokku-staging HEAD:master --force'
|
59
|
+
}
|
60
|
+
post {
|
61
|
+
always {
|
62
|
+
script { support.slackNotification(channel: "#<%= @app_id %>") }
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
stage("Set APP_ENV for production") {
|
68
|
+
when {
|
69
|
+
branch 'master'
|
70
|
+
}
|
71
|
+
steps {
|
72
|
+
script {
|
73
|
+
env.APP_ENV = 'production'
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
stage("Deploy to Dokku production") {
|
79
|
+
when {
|
80
|
+
branch 'master'
|
81
|
+
}
|
82
|
+
steps {
|
83
|
+
// sh 'ssh-keyscan -H <%= @app_id %>.production.kabisa.nl >> ~/.ssh/known_hosts # only needed on the first run'
|
84
|
+
sh 'git remote | grep dokku-production >/dev/null || git remote add dokku-production dokku@<%= @app_id %>.production.kabisa.nl:<%= @app_id %>-production'
|
85
|
+
sh 'git push dokku-production HEAD:master --force'
|
86
|
+
}
|
87
|
+
post {
|
88
|
+
always {
|
89
|
+
script { support.slackNotification(channel: "#<%= @app_id %>") }
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Rails app generated by Kabisa LaunchBase :rocket:
|
2
|
+
|
3
|
+
## What's in it?
|
4
|
+
|
5
|
+
For specific version numbers please refer to
|
6
|
+
[the LaunchBase template](https://github.com/kabisa/launch-base/tree/master/templates/launch_base_default_template.rb)
|
7
|
+
|
8
|
+
- Rails with Spring and Bootsnap
|
9
|
+
- RSpec with Capybara, FactoryBot and Headless Chrome (via Selenium)
|
10
|
+
- SimpleCov including sending the coverage report to Code Climate
|
11
|
+
- SASS
|
12
|
+
- Pry
|
13
|
+
- database: PostgreSQL
|
14
|
+
- web server: puma
|
15
|
+
- lint configuration for CodeClimate, ESLint, Rubocop and Reek
|
16
|
+
|
17
|
+
## First steps
|
18
|
+
|
19
|
+
- create GitHub repository
|
20
|
+
- create Dokku repository
|
21
|
+
- setup the server provisioning
|
22
|
+
- add this project to Jenkins
|
23
|
+
- add the project to CodeClimate
|
24
|
+
- create Jenkins credential `<%= @app_id %>_codeclimate_test_reporter_id` containing the CodeClimate test
|
25
|
+
coverage reporter ID
|
26
|
+
|
27
|
+
## Basic usage
|
28
|
+
|
29
|
+
Run web server:
|
30
|
+
|
31
|
+
```
|
32
|
+
bundle exec rails s
|
33
|
+
```
|
34
|
+
|
35
|
+
Run tests:
|
36
|
+
|
37
|
+
```
|
38
|
+
bundle exec rspec spec
|
39
|
+
```
|
40
|
+
|
41
|
+
## CodeClimate
|
42
|
+
|
43
|
+
To analyze your code locally, install the CodeClimate CLI:
|
44
|
+
|
45
|
+
For OS X:
|
46
|
+
|
47
|
+
```
|
48
|
+
brew install codeclimate
|
49
|
+
```
|
50
|
+
|
51
|
+
Other systems:
|
52
|
+
|
53
|
+
```
|
54
|
+
curl -L https://github.com/codeclimate/codeclimate/archive/master.tar.gz | tar xvz
|
55
|
+
cd codeclimate-* && sudo make install
|
56
|
+
```
|
57
|
+
|
58
|
+
and run:
|
59
|
+
|
60
|
+
```
|
61
|
+
codeclimate analyze
|
62
|
+
```
|
63
|
+
|
64
|
+
More info about CodeClimate: [codeclimate.com](https://codeclimate.com)
|
65
|
+
|
66
|
+
More info about the CodeClimate CLI: [github.com/codeclimate/codeclimate](https://github.com/codeclimate/codeclimate)
|
data/templates/bin/ci
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
service postgresql start
|
4
|
+
|
5
|
+
# Bundle gems
|
6
|
+
bundle check || bundle install --path="/cache"
|
7
|
+
|
8
|
+
set -eu -o pipefail
|
9
|
+
|
10
|
+
env
|
11
|
+
|
12
|
+
bundle exec rake db:drop db:create db:schema:load assets:precompile
|
13
|
+
cc-test-reporter before-build
|
14
|
+
bundle exec rspec spec
|
15
|
+
rspec_exit_code=$?
|
16
|
+
cc-test-reporter after-build
|
17
|
+
exit $rspec_exit_code
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Do not require a descriptive comment for classes and modules
|
2
|
+
# See: https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md
|
3
|
+
IrresponsibleModule:
|
4
|
+
enabled: false
|
5
|
+
|
6
|
+
# Allow 2 occurrences of a method call. When adding the third, it should be
|
7
|
+
# extracted to a variable or method.
|
8
|
+
# See: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
|
9
|
+
#
|
10
|
+
# == Examples:
|
11
|
+
#
|
12
|
+
# Allowed:
|
13
|
+
#
|
14
|
+
# def search
|
15
|
+
# if params[:query].present?
|
16
|
+
# @results = Model.search(params[:query])
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# Not allowed:
|
21
|
+
#
|
22
|
+
# def search
|
23
|
+
# if params[:query].present?
|
24
|
+
# @results = Model.search(params[:query])
|
25
|
+
# session[:last_search_query] = params[:query]
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# Refactor to:
|
30
|
+
#
|
31
|
+
# def search
|
32
|
+
# if search_query.present?
|
33
|
+
# @results = Model.search(search_query)
|
34
|
+
# session[:last_search_query] = search_query
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# private
|
39
|
+
#
|
40
|
+
# def search_query
|
41
|
+
# params[:query]
|
42
|
+
# end
|
43
|
+
DuplicateMethodCall:
|
44
|
+
enabled: true
|
45
|
+
max_calls: 2
|
46
|
+
|
47
|
+
# Allow modules named "V1", because that is fairly common for Rails apps to have
|
48
|
+
UncommunicativeModuleName:
|
49
|
+
accept:
|
50
|
+
- V1
|
51
|
+
|
52
|
+
# Allow Rails helpers that do not depend on instance state
|
53
|
+
"app/helpers":
|
54
|
+
UtilityFunction:
|
55
|
+
enabled: false
|
56
|
+
|
57
|
+
# Allow spec helpers that do not depend on instance state
|
58
|
+
"spec/support":
|
59
|
+
UtilityFunction:
|
60
|
+
enabled: false
|
@@ -0,0 +1,20 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
port: 5432
|
4
|
+
pool: 5
|
5
|
+
timeout: 5000
|
6
|
+
user: postgres
|
7
|
+
password: postgres
|
8
|
+
template: template0
|
9
|
+
|
10
|
+
development:
|
11
|
+
<<: *default
|
12
|
+
database: <%= app_name %>_development
|
13
|
+
|
14
|
+
test:
|
15
|
+
<<: *default
|
16
|
+
database: <%= app_name %>_test
|
17
|
+
|
18
|
+
production:
|
19
|
+
<<: *default
|
20
|
+
database: <%= app_name %>_production
|