satorix 1.5.6 → 1.6.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/satorix.rb +1 -6
- data/lib/satorix/CI/deploy/flynn.rb +9 -12
- data/lib/satorix/CI/deploy/flynn/environment_variables.rb +7 -9
- data/lib/satorix/CI/deploy/flynn/resources.rb +2 -4
- data/lib/satorix/CI/deploy/flynn/routes.rb +4 -5
- data/lib/satorix/CI/deploy/flynn/scale.rb +4 -4
- data/lib/satorix/CI/shared/buildpack_manager.rb +2 -7
- data/lib/satorix/CI/shared/buildpack_manager/buildpack.rb +6 -12
- data/lib/satorix/CI/shared/ruby/gem_manager.rb +3 -4
- data/lib/satorix/CI/shared/yarn_manager.rb +2 -5
- data/lib/satorix/CI/test/python/django_test.rb +7 -10
- data/lib/satorix/CI/test/python/safety.rb +3 -6
- data/lib/satorix/CI/test/ruby/brakeman.rb +3 -6
- data/lib/satorix/CI/test/ruby/bundler_audit.rb +3 -6
- data/lib/satorix/CI/test/ruby/cucumber.rb +2 -5
- data/lib/satorix/CI/test/ruby/rails_test.rb +2 -5
- data/lib/satorix/CI/test/ruby/rspec.rb +2 -5
- data/lib/satorix/CI/test/ruby/rubocop.rb +41 -41
- data/lib/satorix/shared/console.rb +71 -48
- data/lib/satorix/version.rb +1 -1
- data/satorix/CI/deploy/ie_gem_server.rb +13 -17
- data/satorix/CI/deploy/rubygems.rb +34 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 274dbd65366f3a703d2a57b81524f4aa9aa9522b0caa2f2b8158758b20c1861c
|
4
|
+
data.tar.gz: 3fb98c60b4e33c30d053d23c6833d39e809c6d9da4785475694b554e974a9699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f3d4a3a876d26f1d335936e4d613dad6280cbff9367d31672a2b56df16086c074ba066a1b11760a802d9a357491e1275d81bb09473726716dffc47f1798de8
|
7
|
+
data.tar.gz: 22aefe7ba2cb3a806b44635e8554762a912283a66cb7f6628a16937e1e3e166ce7437ae38e13471722c2e5cbc196d043d6f1c33886990a5771ac974f0c6c4ada
|
data/Gemfile.lock
CHANGED
data/lib/satorix.rb
CHANGED
@@ -5,12 +5,10 @@ require 'etc'
|
|
5
5
|
|
6
6
|
module Satorix
|
7
7
|
|
8
|
-
|
9
8
|
module Shared
|
10
9
|
autoload :Console, 'satorix/shared/console'
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
12
|
module CI
|
15
13
|
|
16
14
|
module Deploy
|
@@ -51,10 +49,8 @@ module Satorix
|
|
51
49
|
|
52
50
|
end
|
53
51
|
|
54
|
-
|
55
52
|
include Satorix::Shared::Console
|
56
53
|
|
57
|
-
|
58
54
|
extend self
|
59
55
|
|
60
56
|
|
@@ -89,7 +85,7 @@ module Satorix
|
|
89
85
|
|
90
86
|
def add_user(username)
|
91
87
|
unless user_exists?(username)
|
92
|
-
run_command
|
88
|
+
run_command(['useradd', '--user-group', '--comment', "'#{ username } user'", '--shell', '/bin/bash', '--home', app_dir, username], quiet: true)
|
93
89
|
end
|
94
90
|
end
|
95
91
|
|
@@ -342,5 +338,4 @@ module Satorix
|
|
342
338
|
Dir[File.join(build_dir, '*.gemspec')].any?
|
343
339
|
end
|
344
340
|
|
345
|
-
|
346
341
|
end
|
@@ -3,7 +3,6 @@ module Satorix
|
|
3
3
|
module Deploy
|
4
4
|
module Flynn
|
5
5
|
|
6
|
-
|
7
6
|
include Satorix
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
@@ -19,7 +18,6 @@ module Satorix
|
|
19
18
|
require_relative 'flynn/scale'
|
20
19
|
include Scale
|
21
20
|
|
22
|
-
|
23
21
|
extend self
|
24
22
|
|
25
23
|
|
@@ -43,12 +41,12 @@ module Satorix
|
|
43
41
|
|
44
42
|
|
45
43
|
def add_cluster
|
46
|
-
run_command
|
44
|
+
run_command(['flynn', 'cluster', 'add', '--force', '--default', "--tls-pin=#{ tls_pin }", cluster_name, domain_for_cluster, key], filtered_text: [tls_pin, key])
|
47
45
|
end
|
48
46
|
|
49
47
|
|
50
48
|
def add_remote
|
51
|
-
run_command
|
49
|
+
run_command(['flynn', '-a', project_name, 'remote', 'add', cluster_name, '-y'])
|
52
50
|
end
|
53
51
|
|
54
52
|
|
@@ -58,21 +56,21 @@ module Satorix
|
|
58
56
|
|
59
57
|
|
60
58
|
def configure_inactive_slug_releases
|
61
|
-
run_command
|
59
|
+
run_command(%w[flynn meta set gc.max_inactive_slug_releases=2])
|
62
60
|
end
|
63
61
|
|
64
62
|
|
65
63
|
def create_project
|
66
64
|
if project_exists?
|
67
|
-
log
|
65
|
+
log("Skipping - Flynn project '#{ project_name }' already exists.")
|
68
66
|
else
|
69
|
-
run_command
|
67
|
+
run_command(['flynn', 'create', "--remote=#{ cluster_name }", '-y', 'project_name'])
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
73
71
|
|
74
72
|
def deploy
|
75
|
-
run_command
|
73
|
+
run_command(['git', 'push', cluster_name, 'HEAD:refs/heads/master'])
|
76
74
|
end
|
77
75
|
|
78
76
|
|
@@ -102,7 +100,7 @@ module Satorix
|
|
102
100
|
|
103
101
|
|
104
102
|
def project_exists?
|
105
|
-
|
103
|
+
run_command(%w[flynn apps], quiet: true).split(/\R/).map { |a| a.split.last }.include? project_name
|
106
104
|
end
|
107
105
|
|
108
106
|
|
@@ -115,8 +113,8 @@ module Satorix
|
|
115
113
|
if desired_resource_provider_names.nil? || desired_resource_provider_names.empty?
|
116
114
|
log 'Skipping migrations, no database has been defined. Please see the resources section of this log for more information.'
|
117
115
|
else
|
118
|
-
run_command(
|
119
|
-
run_command(
|
116
|
+
run_command(%w[flynn run --enable-log bundle exec rake db:migrate]) if rails_app?
|
117
|
+
run_command(%w[flynn run --enable-log python public/manage.py migrate]) if django_app?
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
@@ -125,7 +123,6 @@ module Satorix
|
|
125
123
|
ENV["FLYNN_#{ current_branch }_TLSPIN"]
|
126
124
|
end
|
127
125
|
|
128
|
-
|
129
126
|
end
|
130
127
|
end
|
131
128
|
end
|
@@ -6,7 +6,6 @@ module Satorix
|
|
6
6
|
module Flynn
|
7
7
|
module EnvironmentVariables
|
8
8
|
|
9
|
-
|
10
9
|
def adjust_env_vars
|
11
10
|
ensure_required_env_vars_are_defined unless ENV["SATORIX_#{ current_branch }_ENFORCE_ENV_VAR_DEFINITION"] == 'false'
|
12
11
|
env_unset
|
@@ -15,7 +14,7 @@ module Satorix
|
|
15
14
|
|
16
15
|
|
17
16
|
def aeev_key_exists?
|
18
|
-
!(run_command(
|
17
|
+
!(run_command(%w[flynn env], quiet: true) =~ /#{ exported_aeevs_key }=/mi).nil?
|
19
18
|
end
|
20
19
|
|
21
20
|
|
@@ -35,7 +34,7 @@ module Satorix
|
|
35
34
|
|
36
35
|
|
37
36
|
def current_flynn_keys
|
38
|
-
aeev_key_exists? ? run_command(
|
37
|
+
aeev_key_exists? ? run_command(['flynn', 'env', 'get', exported_aeevs_key], quiet: true).split : []
|
39
38
|
end
|
40
39
|
|
41
40
|
|
@@ -87,17 +86,17 @@ module Satorix
|
|
87
86
|
if env_vars_to_unset.empty?
|
88
87
|
log 'No existing environment variables to unset.'
|
89
88
|
else
|
90
|
-
run_command
|
89
|
+
run_command(['flynn', 'env', 'unset', env_vars_to_unset])
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
94
93
|
|
95
94
|
def env_vars
|
96
95
|
@_env_vars ||= begin
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
{}.tap do |vars|
|
97
|
+
current_flynn_keys.each { |key| vars[key] = run_command(['flynn', 'env', 'get', key], quiet: true).chomp }
|
98
|
+
end
|
99
|
+
end
|
101
100
|
end
|
102
101
|
|
103
102
|
|
@@ -115,7 +114,6 @@ module Satorix
|
|
115
114
|
'AEEV_KEYS'
|
116
115
|
end
|
117
116
|
|
118
|
-
|
119
117
|
end
|
120
118
|
end
|
121
119
|
end
|
@@ -4,12 +4,11 @@ module Satorix
|
|
4
4
|
module Flynn
|
5
5
|
module Resources
|
6
6
|
|
7
|
-
|
8
7
|
def add_resources
|
9
8
|
if resources_to_add.empty?
|
10
9
|
log 'No resources to add.'
|
11
10
|
else
|
12
|
-
resources_to_add.each { |resource| run_command
|
11
|
+
resources_to_add.each { |resource| run_command(['flynn', 'resource', 'add', resource]) }
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
@@ -47,7 +46,7 @@ module Satorix
|
|
47
46
|
|
48
47
|
|
49
48
|
def resource
|
50
|
-
run_command(
|
49
|
+
run_command(%w[flynn resource], quiet: true).chomp
|
51
50
|
end
|
52
51
|
|
53
52
|
|
@@ -71,7 +70,6 @@ module Satorix
|
|
71
70
|
remove_resources
|
72
71
|
end
|
73
72
|
|
74
|
-
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
@@ -4,7 +4,6 @@ module Satorix
|
|
4
4
|
module Flynn
|
5
5
|
module Routes
|
6
6
|
|
7
|
-
|
8
7
|
def find_or_create_route(domain)
|
9
8
|
route_ids = route_ids(domain)
|
10
9
|
if route_ids.empty?
|
@@ -134,22 +133,22 @@ module Satorix
|
|
134
133
|
|
135
134
|
|
136
135
|
def fc_route
|
137
|
-
run_command(
|
136
|
+
run_command(['flynn', '-a', project_name, 'route'], quiet: true).chomp
|
138
137
|
end
|
139
138
|
|
140
139
|
|
141
140
|
def fc_route_add(domain)
|
142
|
-
run_command(
|
141
|
+
run_command(['flynn', 'route', 'add', 'http', domain, '--sticky']).chomp
|
143
142
|
end
|
144
143
|
|
145
144
|
|
146
145
|
def fc_route_remove(route_id)
|
147
|
-
run_command
|
146
|
+
run_command(['flynn', 'route', 'remove', route_id])
|
148
147
|
end
|
149
148
|
|
150
149
|
|
151
150
|
def fc_route_update(route_id)
|
152
|
-
run_command
|
151
|
+
run_command(['flynn', 'route', 'update', route_id, '--tls-cert=crt', '--tls-key=key', '--sticky'], quiet: true)
|
153
152
|
end
|
154
153
|
|
155
154
|
|
@@ -4,7 +4,6 @@ module Satorix
|
|
4
4
|
module Flynn
|
5
5
|
module Scale
|
6
6
|
|
7
|
-
|
8
7
|
def adjust_scale
|
9
8
|
cached_scale_options_to_set = scale_options_to_set
|
10
9
|
log "No scale specified in #{ defined_scale_key }. Displaying current scale:" if cached_scale_options_to_set.empty?
|
@@ -28,7 +27,9 @@ module Satorix
|
|
28
27
|
|
29
28
|
|
30
29
|
def fc_scale(scale_options_to_set = nil)
|
31
|
-
|
30
|
+
command = %w[flynn scale].concat(scale_options_to_set)
|
31
|
+
|
32
|
+
run_command(command)
|
32
33
|
end
|
33
34
|
|
34
35
|
|
@@ -36,7 +37,7 @@ module Satorix
|
|
36
37
|
[].tap do |scale|
|
37
38
|
defined_scale.each { |job, workers| scale << "#{ job }=#{ workers }" }
|
38
39
|
(current_scale.keys - defined_scale.keys).each { |job| scale << "#{ job }=0" } unless defined_scale.empty?
|
39
|
-
end
|
40
|
+
end
|
40
41
|
end
|
41
42
|
|
42
43
|
|
@@ -44,7 +45,6 @@ module Satorix
|
|
44
45
|
{}.tap { |jobs| scale_string.split.map { |x| x.partition('=') }.each { |x| jobs[x.first.to_sym] = x.last } }
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -2,19 +2,15 @@ module Satorix
|
|
2
2
|
module CI
|
3
3
|
module Shared
|
4
4
|
|
5
|
-
|
6
5
|
# This code was inspired by:
|
7
6
|
# herokuish - https://github.com/gliderlabs/herokuish
|
8
7
|
# flynn - https://github.com/flynn/flynn/blob/master/slugbuilder/builder/build.sh
|
9
8
|
module BuildpackManager
|
10
9
|
|
11
|
-
|
12
10
|
require 'fileutils'
|
13
11
|
|
14
|
-
|
15
12
|
include Satorix::Shared::Console
|
16
13
|
|
17
|
-
|
18
14
|
extend self
|
19
15
|
|
20
16
|
|
@@ -111,7 +107,7 @@ module Satorix
|
|
111
107
|
|
112
108
|
|
113
109
|
def lsb_release
|
114
|
-
run_command(
|
110
|
+
run_command(%w[lsb_release --release --short], quiet: true).chomp
|
115
111
|
end
|
116
112
|
|
117
113
|
|
@@ -139,7 +135,7 @@ module Satorix
|
|
139
135
|
profile_locations.each do |profile_location|
|
140
136
|
Dir.glob(profile_location) do |shell_file|
|
141
137
|
# Uncomment below to debug profile loading
|
142
|
-
# run_command
|
138
|
+
# run_command(['cat', shell_file])
|
143
139
|
source_env_from shell_file
|
144
140
|
end
|
145
141
|
end
|
@@ -211,7 +207,6 @@ module Satorix
|
|
211
207
|
end
|
212
208
|
end
|
213
209
|
|
214
|
-
|
215
210
|
end
|
216
211
|
end
|
217
212
|
end
|
@@ -3,17 +3,13 @@ module Satorix
|
|
3
3
|
module Shared
|
4
4
|
module BuildpackManager
|
5
5
|
|
6
|
-
|
7
6
|
class Buildpack
|
8
7
|
|
9
|
-
|
10
8
|
require 'fileutils'
|
11
9
|
require 'uri'
|
12
10
|
|
13
|
-
|
14
11
|
include Satorix::Shared::Console
|
15
12
|
|
16
|
-
|
17
13
|
attr_accessor :commit_sha_short,
|
18
14
|
:url
|
19
15
|
|
@@ -30,10 +26,10 @@ module Satorix
|
|
30
26
|
|
31
27
|
def compile
|
32
28
|
log_bench "Building application using the #{ name } buildpack..." do
|
33
|
-
run_command
|
29
|
+
run_command([compile_binary_path,
|
34
30
|
Satorix.build_dir,
|
35
31
|
Satorix.paths[:cache],
|
36
|
-
Satorix.paths[:env]]
|
32
|
+
Satorix.paths[:env]])
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
@@ -98,14 +94,14 @@ module Satorix
|
|
98
94
|
|
99
95
|
|
100
96
|
def checkout_specific_version
|
101
|
-
run_command
|
102
|
-
Dir.chdir(path) { run_command
|
103
|
-
Dir.chdir(path) { run_command
|
97
|
+
run_command(['git', 'clone', '--quiet', '--no-checkout', url, path], quiet: true)
|
98
|
+
Dir.chdir(path) { run_command(['git', 'checkout', '--quiet', commit_sha_short], quiet: true) }
|
99
|
+
Dir.chdir(path) { run_command(%w[git submodule update --init --recursive], quiet: true) }
|
104
100
|
end
|
105
101
|
|
106
102
|
|
107
103
|
def checkout_newest_version
|
108
|
-
run_command
|
104
|
+
run_command(['git', 'clone', '--quiet', '--recursive', '--depth', '1', url, path], quiet: true)
|
109
105
|
end
|
110
106
|
|
111
107
|
|
@@ -149,10 +145,8 @@ module Satorix
|
|
149
145
|
satorix_distrib_sha_version || git_sha_short
|
150
146
|
end
|
151
147
|
|
152
|
-
|
153
148
|
end
|
154
149
|
|
155
|
-
|
156
150
|
end
|
157
151
|
end
|
158
152
|
end
|
@@ -38,7 +38,7 @@ module Satorix
|
|
38
38
|
def restore_missing_gems(quiet = true)
|
39
39
|
# The buildpack incorrectly removes gems that are included using add_development_dependency.
|
40
40
|
# These gems must remain available for testing.
|
41
|
-
run_command(
|
41
|
+
run_command(%w[bundle install --with development], quiet: quiet)
|
42
42
|
end
|
43
43
|
|
44
44
|
|
@@ -64,12 +64,11 @@ module Satorix
|
|
64
64
|
|
65
65
|
|
66
66
|
def regenerate_gemfile_lock(quiet = true)
|
67
|
-
run_command(
|
68
|
-
run_command(
|
67
|
+
run_command(%w[bundle config --local frozen false], quiet: quiet)
|
68
|
+
run_command(%w[bundle install], quiet: quiet)
|
69
69
|
log "\n\n#{ File.read(File.join(Satorix.app_dir, 'Gemfile.lock')) }" unless quiet
|
70
70
|
end
|
71
71
|
|
72
|
-
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
@@ -4,20 +4,17 @@ module Satorix
|
|
4
4
|
|
5
5
|
module YarnManager
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Installing yarn dependencies...') { run_command
|
13
|
+
log_bench('Installing yarn dependencies...') { run_command(%w[yarn install]) }
|
16
14
|
end
|
17
15
|
|
18
16
|
|
19
|
-
private
|
20
|
-
|
17
|
+
private
|
21
18
|
|
22
19
|
end
|
23
20
|
end
|
@@ -4,32 +4,29 @@ module Satorix
|
|
4
4
|
module Python
|
5
5
|
module DjangoTest
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Python version...') { run_command
|
13
|
+
log_bench('Displaying current Python version...') { run_command(%w[python --version]) }
|
16
14
|
log_bench('Running tests...') { run_tests }
|
17
15
|
end
|
18
16
|
|
19
17
|
|
20
18
|
def run_tests
|
21
|
-
run_command
|
22
|
-
run_command
|
19
|
+
run_command([manage, 'collectstatic'])
|
20
|
+
run_command([manage, 'test', 'public'])
|
23
21
|
end
|
24
22
|
|
25
23
|
|
26
|
-
private
|
24
|
+
private
|
27
25
|
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def manage
|
28
|
+
File.join(Satorix.app_dir, 'public', 'manage.py')
|
29
|
+
end
|
33
30
|
|
34
31
|
end
|
35
32
|
end
|
@@ -4,25 +4,22 @@ module Satorix
|
|
4
4
|
module Python
|
5
5
|
module Safety
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Python version...') { run_command
|
16
|
-
log_bench('Installing Safety...') {run_command
|
13
|
+
log_bench('Displaying current Python version...') { run_command(%w[python --version]) }
|
14
|
+
log_bench('Installing Safety...') { run_command(%w[pip install safety]) }
|
17
15
|
log_bench('Auditing requirements.txt...') { run_scan }
|
18
16
|
end
|
19
17
|
|
20
18
|
|
21
19
|
def run_scan
|
22
|
-
run_command
|
20
|
+
run_command(%w[safety check -r requirements.txt])
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
23
|
end
|
27
24
|
end
|
28
25
|
end
|
@@ -4,30 +4,27 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module Brakeman
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Installing Brakeman...') { install_gem }
|
17
15
|
log_bench('Running Brakeman scan...') { run_scan }
|
18
16
|
end
|
19
17
|
|
20
18
|
|
21
19
|
def install_gem
|
22
|
-
run_command
|
20
|
+
run_command(['gem', 'install', 'brakeman', '--no-document', '--bindir', Satorix.bin_dir])
|
23
21
|
end
|
24
22
|
|
25
23
|
|
26
24
|
def run_scan
|
27
|
-
run_command
|
25
|
+
run_command(['brakeman', '-z', '--table-width', '1200', '--exit-on-error', '--path', Satorix.app_dir])
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
28
|
end
|
32
29
|
end
|
33
30
|
end
|
@@ -4,30 +4,27 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module BundlerAudit
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Installing bundler-audit...') { install_gem }
|
17
15
|
log_bench('Auditing Gemfile.lock...') { run_scan }
|
18
16
|
end
|
19
17
|
|
20
18
|
|
21
19
|
def install_gem
|
22
|
-
run_command
|
20
|
+
run_command(['gem', 'install', 'bundler-audit', '--no-document', '--bindir', Satorix.bin_dir])
|
23
21
|
end
|
24
22
|
|
25
23
|
|
26
24
|
def run_scan
|
27
|
-
run_command
|
25
|
+
run_command(%w[bundle-audit check --update])
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
28
|
end
|
32
29
|
end
|
33
30
|
end
|
@@ -4,24 +4,21 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module Cucumber
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Running Cucumber...') { run_cucumber }
|
17
15
|
end
|
18
16
|
|
19
17
|
|
20
18
|
def run_cucumber
|
21
|
-
run_command
|
19
|
+
run_command(%w[bundle exec cucumber])
|
22
20
|
end
|
23
21
|
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -4,24 +4,21 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module RailsTest
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Running Rails test...') { run_scan }
|
17
15
|
end
|
18
16
|
|
19
17
|
|
20
18
|
def run_scan
|
21
|
-
run_command
|
19
|
+
run_command(%w[rails test])
|
22
20
|
end
|
23
21
|
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -4,24 +4,21 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module Rspec
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Running specs...') { run_specs }
|
17
15
|
end
|
18
16
|
|
19
17
|
|
20
18
|
def run_specs
|
21
|
-
run_command
|
19
|
+
run_command(%w[rspec spec])
|
22
20
|
end
|
23
21
|
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -4,15 +4,13 @@ module Satorix
|
|
4
4
|
module Ruby
|
5
5
|
module Rubocop
|
6
6
|
|
7
|
-
|
8
7
|
include Satorix::Shared::Console
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
14
12
|
def go
|
15
|
-
log_bench('Displaying current Ruby version...') { run_command
|
13
|
+
log_bench('Displaying current Ruby version...') { run_command(%w[ruby -v]) }
|
16
14
|
log_bench('Installing Rubocop...') { install_gems }
|
17
15
|
log_bench('Configuring Rubocop...') { create_rubocop_config }
|
18
16
|
log_bench('Running Rubocop inspection...') { run_scan }
|
@@ -20,9 +18,9 @@ module Satorix
|
|
20
18
|
|
21
19
|
|
22
20
|
def install_gems
|
23
|
-
run_command
|
24
|
-
run_command
|
25
|
-
run_command
|
21
|
+
run_command(['gem', 'install', 'rubocop', '--no-document', '--bindir', Satorix.bin_dir])
|
22
|
+
run_command(['gem', 'install', 'rubocop-performance', '--no-document', '--bindir', Satorix.bin_dir])
|
23
|
+
run_command(['gem', 'install', 'rubocop-rails_config', '--no-document', '--bindir', Satorix.bin_dir]) if Satorix.rails_app?
|
26
24
|
end
|
27
25
|
|
28
26
|
|
@@ -39,57 +37,59 @@ module Satorix
|
|
39
37
|
|
40
38
|
|
41
39
|
def run_scan
|
42
|
-
|
43
|
-
|
40
|
+
command = %w[rubocop --require rubocop-performance --display-cop-names --extra-details --display-style-guide --parallel]
|
41
|
+
command.concat(%w[--require rubocop-rails]) if Satorix.rails_app?
|
44
42
|
|
43
|
+
run_command(command)
|
44
|
+
end
|
45
45
|
|
46
|
-
private ######################################################################################################
|
47
46
|
|
47
|
+
private
|
48
48
|
|
49
|
-
def rubocop_config_file
|
50
|
-
File.join(Satorix.app_dir, '.rubocop.yml')
|
51
|
-
end
|
52
49
|
|
50
|
+
def rubocop_config_file
|
51
|
+
File.join(Satorix.app_dir, '.rubocop.yml')
|
52
|
+
end
|
53
53
|
|
54
|
-
def save_rubocop_config(config)
|
55
|
-
File.open(rubocop_config_file, 'w') { |f| f.write(config) }
|
56
|
-
end
|
57
54
|
|
55
|
+
def save_rubocop_config(config)
|
56
|
+
File.open(rubocop_config_file, 'w') { |f| f.write(config) }
|
57
|
+
end
|
58
58
|
|
59
|
-
def config_exist?
|
60
|
-
File.exist? rubocop_config_file
|
61
|
-
end
|
62
59
|
|
60
|
+
def config_exist?
|
61
|
+
File.exist? rubocop_config_file
|
62
|
+
end
|
63
63
|
|
64
|
-
def ruby_version
|
65
|
-
version = run_command 'bundle platform --ruby', quiet: true
|
66
|
-
version.match(/\d+\.\d+\.\d+/)[0]
|
67
|
-
end
|
68
64
|
|
65
|
+
def ruby_version
|
66
|
+
version = run_command(%w[bundle platform --ruby], quiet: true)
|
67
|
+
version.match(/\d+\.\d+\.\d+/)[0]
|
68
|
+
end
|
69
69
|
|
70
|
-
def config_content_default
|
71
|
-
<<~CONTENT
|
72
|
-
AllCops:
|
73
|
-
TargetRubyVersion: #{ ruby_version }
|
74
|
-
Exclude:
|
75
|
-
- '**/tmp/**/*'
|
76
|
-
- '**/templates/**/*'
|
77
|
-
- '**/vendor/**/*'
|
78
|
-
CONTENT
|
79
|
-
end
|
80
70
|
|
71
|
+
def config_content_default
|
72
|
+
<<~CONTENT
|
73
|
+
AllCops:
|
74
|
+
TargetRubyVersion: #{ ruby_version }
|
75
|
+
Exclude:
|
76
|
+
- '**/tmp/**/*'
|
77
|
+
- '**/templates/**/*'
|
78
|
+
- '**/vendor/**/*'
|
79
|
+
CONTENT
|
80
|
+
end
|
81
81
|
|
82
|
-
def config_content_rails
|
83
|
-
<<~CONTENT
|
84
|
-
inherit_gem:
|
85
|
-
rubocop-rails_config:
|
86
|
-
- config/rails.yml
|
87
82
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
83
|
+
def config_content_rails
|
84
|
+
<<~CONTENT
|
85
|
+
inherit_gem:
|
86
|
+
rubocop-rails_config:
|
87
|
+
- config/rails.yml
|
92
88
|
|
89
|
+
AllCops:
|
90
|
+
TargetRubyVersion: #{ ruby_version }
|
91
|
+
CONTENT
|
92
|
+
end
|
93
93
|
|
94
94
|
end
|
95
95
|
end
|
@@ -2,15 +2,18 @@ module Satorix
|
|
2
2
|
module Shared
|
3
3
|
module Console
|
4
4
|
|
5
|
-
|
6
5
|
require 'benchmark'
|
7
6
|
require 'English' # http://ruby-doc.org/stdlib-2.0.0/libdoc/English/rdoc/English.html
|
8
7
|
require 'shellwords'
|
9
8
|
|
10
|
-
|
11
9
|
extend self
|
12
10
|
|
13
11
|
|
12
|
+
def colorize(text, color = nil)
|
13
|
+
"\033[#{ colors[color] }m#{ text }\033[0m"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
14
17
|
def colors
|
15
18
|
Hash.new(39).merge(red: '0;31', light_red: '1;31',
|
16
19
|
green: '0;32', light_green: '1;32',
|
@@ -22,8 +25,15 @@ module Satorix
|
|
22
25
|
end
|
23
26
|
|
24
27
|
|
25
|
-
def
|
26
|
-
|
28
|
+
def humanize_time(seconds)
|
29
|
+
return 'less than 1 second' if seconds < 1
|
30
|
+
[[60, :second], [60, :minute], [24, :hour], [1000, :day]].map do |count, name|
|
31
|
+
if seconds > 0
|
32
|
+
seconds, n = seconds.divmod(count)
|
33
|
+
n = n.to_i
|
34
|
+
"#{ n } #{ name }#{ 's' if n > 1 }" if n > 0
|
35
|
+
end
|
36
|
+
end.compact.reverse.join(' ')
|
27
37
|
end
|
28
38
|
|
29
39
|
|
@@ -66,28 +76,31 @@ module Satorix
|
|
66
76
|
end
|
67
77
|
|
68
78
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
n = n.to_i
|
75
|
-
"#{ n } #{ name }#{ 's' if n > 1 }" if n > 0
|
76
|
-
end
|
77
|
-
end.compact.reverse.join(' ')
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
# This method is used *EVERYWHERE*.
|
82
|
-
# Seemingly small changes can have far-ranging and extreme consequences.
|
83
|
-
# Modify only with extreme caution.
|
79
|
+
# The preferred way to use this method is by passing an array containing the command.
|
80
|
+
# This will ensure that items are properly escaped.
|
81
|
+
# It is also possible to use nested arrays. See tests for example use cases.
|
82
|
+
#
|
83
|
+
# If you want to see how your string command translates into an arry, you can use shellsplit method.
|
84
84
|
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
|
90
|
-
|
85
|
+
# For example:
|
86
|
+
# 'ruby -v'.shellsplit
|
87
|
+
# => ["ruby", "-v"]
|
88
|
+
#
|
89
|
+
# If, for some reason, you need to supply a string that is already escaped or should not be escaped, it is
|
90
|
+
# possible to supply a string argument instead of an array. If you do this, you will need to supply
|
91
|
+
# an additional parameter of string_verified_safe, to ensure that the operation is deliberate.
|
92
|
+
def run_command(command, filtered_text: [], quiet: false, string_verified_safe: false)
|
93
|
+
# This method is used *EVERYWHERE*.
|
94
|
+
# Seemingly small changes can have far-ranging and extreme consequences.
|
95
|
+
# Modify only with extreme caution.
|
96
|
+
#
|
97
|
+
# Note: Many applications (like echo and the Flynn CLI) append a newline to their output.
|
98
|
+
# If you are using the command result, it may be desirable to chomp the trailing
|
99
|
+
# newline. It is left to the implementing call to handle this, as it proved
|
100
|
+
# cumbersome to handle in this method in a way that worked perfectly in all cases.
|
101
|
+
raise('Potentially unsafe or problematic command. Please refer to the method documentation for more information.') if command.is_a?(String) && !string_verified_safe
|
102
|
+
|
103
|
+
command = normalized_command(command)
|
91
104
|
logged_command = logged_command(command, filtered_text)
|
92
105
|
log_command(logged_command) unless quiet
|
93
106
|
|
@@ -114,43 +127,53 @@ module Satorix
|
|
114
127
|
end
|
115
128
|
|
116
129
|
|
117
|
-
private
|
130
|
+
private
|
118
131
|
|
119
132
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
133
|
+
def bash(command)
|
134
|
+
['bash -c', escaped_command(command), '2>&1'].join(' ')
|
135
|
+
end
|
124
136
|
|
125
137
|
|
126
|
-
|
127
|
-
|
128
|
-
|
138
|
+
def logged_command(command, filtered_text)
|
139
|
+
filtered_text = [filtered_text].flatten.delete_if { |text| text.nil? || text.strip.empty? }
|
140
|
+
unescaped_command = command.shellsplit.join(' ')
|
141
|
+
unescaped_command.gsub(Regexp.union(filtered_text.sort_by(&:length).reverse), '[MASKED]')
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
def escaped_command(command)
|
146
|
+
command.shellescape
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def normalized_command(command)
|
151
|
+
command.is_a?(Array) ? command.flatten.shelljoin : command
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
def handle_run_command_error(logged_command, quiet)
|
156
|
+
error_message = "\nAn error has occurred while running the following command:\n#{ logged_command }\n"
|
157
|
+
quiet ? abort : log_error_and_abort(error_message)
|
158
|
+
end
|
129
159
|
|
130
160
|
|
131
161
|
# http://stackoverflow.com/questions/1197224/source-shell-script-into-environment-within-a-ruby-script
|
132
162
|
# TODO : reduce / consolidate?
|
133
163
|
# Read in the bash environment, after an optional command. Returns Array of key/value pairs.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
164
|
+
def bash_env(cmd = nil)
|
165
|
+
env_cmd = bash("#{ cmd + ';' if cmd } printenv")
|
166
|
+
env = `#{ env_cmd }`
|
167
|
+
env.split(/\n/).map { |l| l.split(/=/, 2) }
|
168
|
+
end
|
139
169
|
|
140
170
|
|
141
171
|
# http://stackoverflow.com/questions/1197224/source-shell-script-into-environment-within-a-ruby-script
|
142
172
|
# TODO : reduce / consolidate?
|
143
173
|
# Source a given file, and compare environment before and after. Returns Hash of any keys that have changed.
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
def handle_run_command_error(logged_command, quiet)
|
150
|
-
error_message = "\nAn error has occurred while running the following command:\n#{ logged_command }\n"
|
151
|
-
quiet ? abort : log_error_and_abort(error_message)
|
152
|
-
end
|
153
|
-
|
174
|
+
def bash_source(file)
|
175
|
+
Hash[bash_env("source #{ File.realpath file }") - bash_env]
|
176
|
+
end
|
154
177
|
|
155
178
|
end
|
156
179
|
end
|
data/lib/satorix/version.rb
CHANGED
@@ -3,13 +3,10 @@ module Satorix
|
|
3
3
|
module Deploy
|
4
4
|
module IeGemServer
|
5
5
|
|
6
|
-
|
7
6
|
require 'fileutils'
|
8
7
|
|
9
|
-
|
10
8
|
include Satorix::Shared::Console
|
11
9
|
|
12
|
-
|
13
10
|
extend self
|
14
11
|
|
15
12
|
|
@@ -22,7 +19,7 @@ module Satorix
|
|
22
19
|
|
23
20
|
|
24
21
|
def build_gem
|
25
|
-
run_command
|
22
|
+
run_command(%w[rake build])
|
26
23
|
end
|
27
24
|
|
28
25
|
|
@@ -32,7 +29,7 @@ module Satorix
|
|
32
29
|
|
33
30
|
|
34
31
|
def gem_build_directory
|
35
|
-
File.join
|
32
|
+
File.join(Satorix.app_dir, 'pkg')
|
36
33
|
end
|
37
34
|
|
38
35
|
|
@@ -42,37 +39,36 @@ module Satorix
|
|
42
39
|
|
43
40
|
|
44
41
|
def install_geminabox_gem
|
45
|
-
run_command
|
42
|
+
run_command(['gem', 'install', 'geminabox', '--source', 'https://gems.iexposure.com', '--no-document', '--bindir', Satorix.bin_dir])
|
46
43
|
end
|
47
44
|
|
48
45
|
|
49
46
|
def prepare_gem_build_directory
|
50
|
-
run_command
|
47
|
+
run_command(['rm', '-rf', gem_build_directory], quiet: true)
|
51
48
|
FileUtils.mkdir_p gem_build_directory
|
52
49
|
end
|
53
50
|
|
54
51
|
|
55
52
|
def publish_gem(gem)
|
56
|
-
run_command
|
57
|
-
filtered_text: [ie_gem_server_user_name, ie_gem_server_password]
|
53
|
+
run_command(['gem', 'inabox', gem, '--host', ie_gem_server_host],
|
54
|
+
filtered_text: [ie_gem_server_user_name, ie_gem_server_password])
|
58
55
|
rescue RuntimeError
|
59
56
|
# To prevent the display of an ugly stacktrace.
|
60
57
|
abort "\nGem was not published!"
|
61
58
|
end
|
62
59
|
|
63
60
|
|
64
|
-
private
|
61
|
+
private
|
65
62
|
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
def ie_gem_server_password
|
65
|
+
ENV['IE_GEM_SERVER_PASSWORD']
|
66
|
+
end
|
71
67
|
|
72
|
-
def ie_gem_server_user_name
|
73
|
-
ENV['IE_GEM_SERVER_USER_NAME']
|
74
|
-
end
|
75
68
|
|
69
|
+
def ie_gem_server_user_name
|
70
|
+
ENV['IE_GEM_SERVER_USER_NAME']
|
71
|
+
end
|
76
72
|
|
77
73
|
end
|
78
74
|
end
|
@@ -3,13 +3,10 @@ module Satorix
|
|
3
3
|
module Deploy
|
4
4
|
module Rubygems
|
5
5
|
|
6
|
-
|
7
6
|
require 'fileutils'
|
8
7
|
|
9
|
-
|
10
8
|
include Satorix::Shared::Console
|
11
9
|
|
12
|
-
|
13
10
|
extend self
|
14
11
|
|
15
12
|
|
@@ -21,59 +18,58 @@ module Satorix
|
|
21
18
|
end
|
22
19
|
|
23
20
|
|
24
|
-
private
|
21
|
+
private
|
25
22
|
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def build_gem
|
25
|
+
Dir.chdir(Satorix.app_dir) do
|
26
|
+
run_command(%w[bundle exec rake build])
|
27
|
+
end
|
30
28
|
end
|
31
|
-
end
|
32
|
-
|
33
29
|
|
34
|
-
def built_gems
|
35
|
-
Dir.glob(File.join(gem_build_directory, '*.gem')).select { |e| File.file? e }
|
36
|
-
end
|
37
30
|
|
31
|
+
def built_gems
|
32
|
+
Dir.glob(File.join(gem_build_directory, '*.gem')).select { |e| File.file? e }
|
33
|
+
end
|
38
34
|
|
39
|
-
def gem_build_directory
|
40
|
-
File.join Satorix.app_dir, 'pkg'
|
41
|
-
end
|
42
35
|
|
36
|
+
def gem_build_directory
|
37
|
+
File.join(Satorix.app_dir, 'pkg')
|
38
|
+
end
|
43
39
|
|
44
|
-
def generate_rubygems_configuration_file
|
45
|
-
path = File.join(Dir.home, '.gem')
|
46
|
-
FileUtils.mkdir_p(path) unless File.exist?(path)
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
41
|
+
def generate_rubygems_configuration_file
|
42
|
+
path = File.join(Dir.home, '.gem')
|
43
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
52
44
|
|
45
|
+
file = File.join(path, 'credentials')
|
46
|
+
File.open(file, 'w') { |f| f.write rubygems_configuration_file_contents }
|
47
|
+
FileUtils.chmod 0600, file
|
48
|
+
end
|
53
49
|
|
54
|
-
def prepare_gem_build_directory
|
55
|
-
run_command "rm -rf #{ gem_build_directory }"
|
56
|
-
FileUtils.mkdir_p gem_build_directory
|
57
|
-
end
|
58
50
|
|
51
|
+
def prepare_gem_build_directory
|
52
|
+
run_command(['rm', '-rf', gem_build_directory])
|
53
|
+
FileUtils.mkdir_p gem_build_directory
|
54
|
+
end
|
59
55
|
|
60
|
-
def publish_gem(gem)
|
61
|
-
run_command "gem push #{ gem } --config-file #{ File.join(Dir.home, '.gem', 'credentials') }"
|
62
|
-
rescue RuntimeError
|
63
|
-
# To prevent the display of an ugly stacktrace.
|
64
|
-
abort "\nGem was not published!"
|
65
|
-
end
|
66
56
|
|
57
|
+
def publish_gem(gem)
|
58
|
+
run_command(['gem', 'push', gem, '--config-file', File.join(Dir.home, '.gem', 'credentials')])
|
59
|
+
rescue RuntimeError
|
60
|
+
# To prevent the display of an ugly stacktrace.
|
61
|
+
abort "\nGem was not published!"
|
62
|
+
end
|
67
63
|
|
68
|
-
def rubygems_api_key
|
69
|
-
ENV['SATORIX_CI_RUBYGEMS_API_KEY']
|
70
|
-
end
|
71
64
|
|
65
|
+
def rubygems_api_key
|
66
|
+
ENV['SATORIX_CI_RUBYGEMS_API_KEY']
|
67
|
+
end
|
72
68
|
|
73
|
-
def rubygems_configuration_file_contents
|
74
|
-
"---\n:rubygems_api_key: #{ rubygems_api_key }"
|
75
|
-
end
|
76
69
|
|
70
|
+
def rubygems_configuration_file_contents
|
71
|
+
"---\n:rubygems_api_key: #{ rubygems_api_key }"
|
72
|
+
end
|
77
73
|
|
78
74
|
end
|
79
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: satorix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satorix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake-ruby
|