satorix-rails 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/deploy/mock_deploy.rb +8 -11
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/test/bare_bones.rb +0 -5
- data/lib/rails/generators/templates/custom_ci_job/satorix/CI/test/info.rb +44 -43
- data/lib/satorix/rails/version.rb +1 -1
- data/satorix/CI/deploy/rubygems.rb +69 -74
- 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: 435a13aeb52a37926e1c05131e9ade2acef2a753076fd973cdcec8fc42a1dbbc
|
4
|
+
data.tar.gz: 5809274213b07e1bcdc4f573efabd0f2f0c3d67105f6f25e5eff09f6e80c077b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc01af9987e38d189dee15d4b4d5ee89c9ef0a443beed6f23d6b2a869b381273563355dd378754615ad784f30c3574cb7e8c4b04dcd7739a3918388fb77577fd
|
7
|
+
data.tar.gz: 46fa05b77b27a9e5c8892aa23c8d87f052adcac05004886966d769c05c35a6152280e0b766056318c11a89ce23cdd98fd411c9e19592d5b9b3dd60d83322b804
|
data/Gemfile.lock
CHANGED
@@ -3,10 +3,8 @@ module Satorix
|
|
3
3
|
module Deploy
|
4
4
|
module MockDeploy
|
5
5
|
|
6
|
-
|
7
6
|
include Satorix::Shared::Console
|
8
7
|
|
9
|
-
|
10
8
|
extend self
|
11
9
|
|
12
10
|
|
@@ -17,19 +15,18 @@ module Satorix
|
|
17
15
|
end
|
18
16
|
|
19
17
|
|
20
|
-
private
|
18
|
+
private
|
21
19
|
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
def turbines_to_speed
|
22
|
+
batnap
|
23
|
+
puts 'Roger. Ready to move out.'
|
24
|
+
end
|
27
25
|
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def batnap
|
28
|
+
sleep(rand(6))
|
29
|
+
end
|
33
30
|
|
34
31
|
end
|
35
32
|
end
|
@@ -5,21 +5,16 @@ module Satorix
|
|
5
5
|
# This is the simplest possible implementation of a custom job.
|
6
6
|
module BareBones
|
7
7
|
|
8
|
-
|
9
8
|
extend self
|
10
9
|
|
11
10
|
# go() is the method that will be called during the CI run.
|
12
11
|
# You can add your own logic to do whatever you want.
|
13
12
|
def go
|
14
|
-
# Uncomment the line below if you want to execute in the context of the app's buildpack.
|
15
|
-
# Satorix::CI::Test::Shared::BuildpackManager.go
|
16
13
|
puts "\n\nRunning BareBones#go..."
|
17
14
|
end
|
18
15
|
|
19
|
-
|
20
16
|
end
|
21
17
|
|
22
|
-
|
23
18
|
end
|
24
19
|
end
|
25
20
|
end
|
@@ -3,17 +3,13 @@ module Satorix
|
|
3
3
|
module Test
|
4
4
|
module Info
|
5
5
|
|
6
|
-
|
7
6
|
include Satorix::Shared::Console
|
8
7
|
|
9
|
-
|
10
8
|
extend self
|
11
9
|
|
12
10
|
# go() is the method that will be called during the CI run.
|
13
11
|
# You can add your own logic to do whatever you want.
|
14
12
|
def go
|
15
|
-
# Uncomment the line below if you want to execute in the context of the app's buildpack.
|
16
|
-
# Satorix::CI::Test::Shared::BuildpackManager.go
|
17
13
|
|
18
14
|
log_bench('Describing logging...') do
|
19
15
|
describe_log
|
@@ -22,7 +18,7 @@ module Satorix
|
|
22
18
|
end
|
23
19
|
|
24
20
|
log_bench('Describing console commands...') do
|
25
|
-
|
21
|
+
describe_unsafe_run_command_string
|
26
22
|
describe_run_command_array
|
27
23
|
describe_run_command_filtered
|
28
24
|
describe_run_command_quiet
|
@@ -33,62 +29,67 @@ module Satorix
|
|
33
29
|
end
|
34
30
|
|
35
31
|
|
36
|
-
private
|
32
|
+
private
|
37
33
|
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
def describe_environment_variables
|
36
|
+
puts "Remember, #{ ENV['GITLAB_USER_EMAIL'] }, that you have access to all of the environment variables ",
|
37
|
+
' described at https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables'
|
38
|
+
end
|
43
39
|
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
def describe_log
|
42
|
+
log 'The log() method writes a message to the log'
|
43
|
+
colors.keys.each { |color| log "You can provide an optional color, like :#{ color }", color }
|
44
|
+
end
|
49
45
|
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
47
|
+
def describe_log_error
|
48
|
+
log_error 'The log_error() method writes an error to the log'
|
49
|
+
end
|
54
50
|
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
def describe_log_error_and_abort
|
53
|
+
log_error 'The log_error_and_abort() method writes an error to the log and aborts the job'
|
54
|
+
rescue SystemExit => e
|
55
|
+
puts 'Rescuing from the error, to continue the tutorial.',
|
56
|
+
e.inspect
|
57
|
+
end
|
62
58
|
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
def describe_unsafe_run_command_string
|
61
|
+
# It is possible to use a string command that is assumed to be already escaped and will not be escaped further.
|
62
|
+
# See below for safer alternate options.
|
63
|
+
# Please see the run_command documentation in the satorix gem for more information and examples.
|
64
|
+
run_command "echo 'We can run string console commands that have already been properly escaped with the run_command() method and the `string_verified_safe: true` option. This is best avoided!'",
|
65
|
+
string_verified_safe: true
|
66
|
+
end
|
68
67
|
|
69
|
-
def describe_run_command_array
|
70
|
-
run_command ['echo', "'We can safely run array console commands with the run_command() method'"]
|
71
|
-
end
|
72
68
|
|
69
|
+
def describe_run_command_array
|
70
|
+
# It is preferred to use an array command, especially for anything containing dynamic input. Escaping will be taken care of for you.
|
71
|
+
# Please see the run_command documentation in the satorix gem for more information and examples.
|
72
|
+
run_command ['echo', 'We can safely run unescaped array console commands with the run_command() method. This is ideal!']
|
73
|
+
end
|
73
74
|
|
74
|
-
def describe_run_command_quiet
|
75
|
-
run_command "echo 'This will not be displayed'", quiet: true
|
76
|
-
end
|
77
75
|
|
76
|
+
def describe_run_command_quiet
|
77
|
+
run_command ['echo', 'This will not be displayed (but will return the output).'], quiet: true
|
78
|
+
end
|
78
79
|
|
79
|
-
def describe_run_command_filtered
|
80
|
-
run_command "echo 'You can filter secrets, like 1234 and 5678 (unless you explicitly display them)'", filtered_text: %w(1234 5678)
|
81
|
-
end
|
82
80
|
|
81
|
+
def describe_run_command_filtered
|
82
|
+
run_command ['echo', 'You can filter sensitive text from the logs, like 1234 and 5678 (the original output will be returned).'], filtered_text: %w(1234 5678)
|
83
|
+
end
|
83
84
|
|
84
|
-
def describe_run_command_with_error
|
85
|
-
run_command 'false'
|
86
|
-
rescue SystemExit
|
87
|
-
puts 'Commands that exit with a non-zero return code abort operation, unless rescued.',
|
88
|
-
'Rescuing from the error, to continue the tutorial.',
|
89
|
-
e.inspect
|
90
|
-
end
|
91
85
|
|
86
|
+
def describe_run_command_with_error
|
87
|
+
run_command %w[false]
|
88
|
+
rescue SystemExit
|
89
|
+
puts 'Commands that exit with a non-zero return code abort operation, unless rescued.',
|
90
|
+
'Rescuing from the error, to continue the tutorial.',
|
91
|
+
e.inspect
|
92
|
+
end
|
92
93
|
|
93
94
|
end
|
94
95
|
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,113 +18,111 @@ 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
29
|
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def gem_build_directory
|
40
|
-
File.join Satorix.app_dir, 'pkg'
|
41
|
-
end
|
31
|
+
def built_gems
|
32
|
+
Dir.glob(File.join(gem_build_directory, '*.gem')).select { |e| File.file? e }
|
33
|
+
end
|
42
34
|
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
def gem_build_directory
|
37
|
+
File.join Satorix.app_dir, 'pkg'
|
38
|
+
end
|
47
39
|
|
48
|
-
file = File.join(path, 'credentials')
|
49
|
-
File.open(file, 'w') { |f| f.write rubygems_configuration_file_contents }
|
50
|
-
FileUtils.chmod 0600, file
|
51
|
-
end
|
52
40
|
|
41
|
+
def generate_rubygems_configuration_file
|
42
|
+
path = File.join(Dir.home, '.gem')
|
43
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
53
44
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
58
49
|
|
59
50
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
abort "\nGem was not published!"
|
65
|
-
end
|
51
|
+
def prepare_gem_build_directory
|
52
|
+
run_command(['rm', '-rf', gem_build_directory])
|
53
|
+
FileUtils.mkdir_p gem_build_directory
|
54
|
+
end
|
66
55
|
|
67
56
|
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
71
63
|
|
72
64
|
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
def rubygems_api_key
|
66
|
+
ENV['SATORIX_CI_RUBYGEMS_API_KEY']
|
67
|
+
end
|
76
68
|
|
77
69
|
|
78
|
-
|
70
|
+
def rubygems_configuration_file_contents
|
71
|
+
"---\n:rubygems_api_key: #{ rubygems_api_key }"
|
72
|
+
end
|
79
73
|
|
80
74
|
|
81
|
-
|
82
|
-
run_command 'git config user.name Satorix'
|
83
|
-
run_command 'git config user.email satorix@iexposure.com'
|
84
|
-
run_command 'git config push.default simple'
|
85
|
-
end
|
75
|
+
# To be used for rake release - START
|
86
76
|
|
77
|
+
def configure_git
|
78
|
+
run_command(%w[git config user.name Satorix])
|
79
|
+
run_command(%w[git config user.email satorix@iexposure.com])
|
80
|
+
run_command(%w[git config push.default simple])
|
81
|
+
end
|
87
82
|
|
88
|
-
def configure_ssh
|
89
|
-
run_command 'whoami'
|
90
|
-
run_command 'printenv'
|
91
83
|
|
92
|
-
|
93
|
-
|
84
|
+
def configure_ssh
|
85
|
+
run_command(%w[whoami])
|
86
|
+
run_command(%w[printenv])
|
94
87
|
|
95
|
-
|
96
|
-
|
97
|
-
FileUtils.chmod 0600, public_key_file
|
98
|
-
run_command "cat #{ public_key_file }"
|
88
|
+
path = File.join(Dir.home, '.ssh')
|
89
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
99
90
|
|
100
|
-
|
101
|
-
|
102
|
-
|
91
|
+
public_key_file = File.join(path, 'id_rsa.pub')
|
92
|
+
File.open(public_key_file, 'w') { |f| f.write ssh_public_key }
|
93
|
+
FileUtils.chmod 0600, public_key_file
|
94
|
+
run_command(['cat', public_key_file])
|
103
95
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
run_command "cat #{ config_file }"
|
96
|
+
private_key_file = File.join(path, 'id_rsa')
|
97
|
+
File.open(private_key_file, 'w') { |f| f.write ssh_private_key }
|
98
|
+
FileUtils.chmod 0600, private_key_file
|
108
99
|
|
109
|
-
|
110
|
-
|
111
|
-
|
100
|
+
config_file = File.join(path, 'config')
|
101
|
+
File.open(config_file, 'w') { |f| f.write "IdentityFile #{ private_key_file }" }
|
102
|
+
FileUtils.chmod 0600, config_file
|
103
|
+
run_command(['cat', config_file])
|
112
104
|
|
105
|
+
system 'eval `ssh-agent -s`'
|
106
|
+
run_command(['ssh-add', private_key_file])
|
107
|
+
end
|
113
108
|
|
114
|
-
def rake_release
|
115
|
-
run_command 'bundle exec rake release'
|
116
|
-
end
|
117
109
|
|
110
|
+
def rake_release
|
111
|
+
run_command(%w[bundle exec rake release])
|
112
|
+
end
|
118
113
|
|
119
|
-
def ssh_private_key
|
120
|
-
ENV['SATORIX_CI_SSH_PRIVATE_KEY']
|
121
|
-
end
|
122
114
|
|
115
|
+
def ssh_private_key
|
116
|
+
ENV['SATORIX_CI_SSH_PRIVATE_KEY']
|
117
|
+
end
|
123
118
|
|
124
|
-
def ssh_public_key
|
125
|
-
ENV['SATORIX_CI_SSH_PUBLIC_KEY']
|
126
|
-
end
|
127
119
|
|
120
|
+
def ssh_public_key
|
121
|
+
ENV['SATORIX_CI_SSH_PUBLIC_KEY']
|
122
|
+
end
|
128
123
|
|
129
|
-
# To be used for rake release - END
|
130
124
|
|
125
|
+
# To be used for rake release - END
|
131
126
|
|
132
127
|
end
|
133
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: satorix-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satorix
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
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: passenger
|