tinyci 0.4.2 → 0.5
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/.gitignore +2 -2
- data/.rspec +2 -0
- data/.rubocop.yml +17 -2
- data/.ruby-version +1 -1
- data/.tinyci.yml +3 -1
- data/Dockerfile +3 -2
- data/Gemfile +2 -1
- data/Gemfile.lock +56 -29
- data/Guardfile +5 -3
- data/Rakefile +3 -1
- data/bin/tinyci +3 -2
- data/lib/pidfile.rb +28 -39
- data/lib/tinyci/builders/script_builder.rb +2 -0
- data/lib/tinyci/builders/test_builder.rb +3 -1
- data/lib/tinyci/cli.rb +159 -79
- data/lib/tinyci/cli_ssh_delegator.rb +111 -0
- data/lib/tinyci/compactor.rb +26 -26
- data/lib/tinyci/config.rb +22 -23
- data/lib/tinyci/config_transformer.rb +14 -16
- data/lib/tinyci/executor.rb +14 -12
- data/lib/tinyci/git_utils.rb +87 -18
- data/lib/tinyci/hookers/script_hooker.rb +26 -27
- data/lib/tinyci/installer.rb +23 -21
- data/lib/tinyci/log_viewer.rb +87 -0
- data/lib/tinyci/logging.rb +5 -5
- data/lib/tinyci/multi_logger.rb +30 -21
- data/lib/tinyci/path_utils.rb +44 -0
- data/lib/tinyci/runner.rb +95 -78
- data/lib/tinyci/scheduler.rb +44 -42
- data/lib/tinyci/subprocesses.rb +41 -32
- data/lib/tinyci/symbolize.rb +3 -1
- data/lib/tinyci/testers/script_tester.rb +2 -0
- data/lib/tinyci/testers/test_tester.rb +2 -0
- data/lib/tinyci/version.rb +3 -1
- data/lib/yard_plugin.rb +9 -1
- data/tinyci.gemspec +29 -22
- metadata +87 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d07c0c3a6bf3981f3be16033ee0ab5bc708c3a17ef03657644af3701164aef3e
|
4
|
+
data.tar.gz: 9c60154d9910f6338ae397ff477188d49fc8bdcdb5b3bdc131a1586e93936553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f35bdecd2f6e8d9038d1244859a8ec4ba82404ff889799604a6701a9cfdabdc392c09c90a83a3f30eddd6456295ac095a3de02997ff58b5a64d2ad012144cba
|
7
|
+
data.tar.gz: f5e2df0e0debc915b95ab4e35e99afebb8c6f7a17224151c04c4fbca5ecbcba3e4de069cb966182f083590101357cc2690889e0acc7ec393583d273a1fe4314f
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'spec/**/*'
|
4
|
+
- 'lib/pidfile.rb'
|
2
5
|
TargetRubyVersion: 2.5
|
3
|
-
|
4
|
-
|
6
|
+
|
7
|
+
Layout/LineLength:
|
5
8
|
Max: 100
|
9
|
+
AutoCorrect: true
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
ExcludedMethods: ['describe', 'context']
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
Max: 25
|
16
|
+
|
17
|
+
Metrics/ClassLength:
|
18
|
+
Max: 150
|
6
19
|
|
20
|
+
Metrics/AbcSize:
|
21
|
+
Max: 20
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/.tinyci.yml
CHANGED
data/Dockerfile
CHANGED
@@ -7,7 +7,7 @@ RUN apk add --no-cache \
|
|
7
7
|
RUN git config --global user.email "you@example.com"
|
8
8
|
RUN git config --global user.name "Your Name"
|
9
9
|
|
10
|
-
WORKDIR /tmp
|
10
|
+
WORKDIR /tmp
|
11
11
|
ADD Gemfile Gemfile
|
12
12
|
ADD Gemfile.lock Gemfile.lock
|
13
13
|
ADD tinyci.gemspec tinyci.gemspec
|
@@ -15,8 +15,9 @@ ADD lib/tinyci/version.rb lib/tinyci/version.rb
|
|
15
15
|
ADD lib/tinyci/logo.txt lib/tinyci/logo.txt
|
16
16
|
|
17
17
|
RUN gem update bundler
|
18
|
+
RUN bundle config set no-cache 'true'
|
18
19
|
|
19
|
-
RUN bundle install --
|
20
|
+
RUN bundle install --jobs=$(nproc)
|
20
21
|
|
21
22
|
ADD . /tinyci
|
22
23
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tinyci (0.
|
4
|
+
tinyci (0.5)
|
5
|
+
file-tail
|
6
|
+
git_clone_url
|
7
|
+
net-ssh
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: https://rubygems.org/
|
8
11
|
specs:
|
12
|
+
ast (2.4.0)
|
13
|
+
awesome_print (1.8.0)
|
9
14
|
barrier (1.0.2)
|
10
|
-
byebug (11.
|
15
|
+
byebug (11.1.1)
|
11
16
|
coderay (1.1.2)
|
12
17
|
diff-lcs (1.3)
|
13
18
|
docile (1.3.1)
|
14
|
-
ffi (1.
|
19
|
+
ffi (1.12.1)
|
20
|
+
file-tail (1.2.0)
|
21
|
+
tins (~> 1.0)
|
15
22
|
formatador (0.2.5)
|
16
23
|
fuubar (2.3.2)
|
17
24
|
rspec-core (~> 3.0)
|
18
25
|
ruby-progressbar (~> 1.4)
|
19
|
-
|
26
|
+
git_clone_url (2.0.0)
|
27
|
+
uri-ssh_git (>= 2.0)
|
28
|
+
guard (2.16.1)
|
20
29
|
formatador (>= 0.2.4)
|
21
30
|
listen (>= 2.7, < 4.0)
|
22
31
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -30,63 +39,80 @@ GEM
|
|
30
39
|
guard (~> 2.1)
|
31
40
|
guard-compat (~> 1.1)
|
32
41
|
rspec (>= 2.99.0, < 4.0)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
rb-
|
37
|
-
|
38
|
-
lumberjack (1.0
|
42
|
+
jaro_winkler (1.5.4)
|
43
|
+
json (2.3.0)
|
44
|
+
listen (3.2.1)
|
45
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
46
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
47
|
+
lumberjack (1.2.0)
|
39
48
|
method_source (0.9.2)
|
40
49
|
nenv (0.3.0)
|
41
|
-
|
50
|
+
net-ssh (5.2.0)
|
51
|
+
notiffany (0.1.3)
|
42
52
|
nenv (~> 0.1)
|
43
53
|
shellany (~> 0.0)
|
54
|
+
parallel (1.19.1)
|
55
|
+
parser (2.7.0.2)
|
56
|
+
ast (~> 2.4.0)
|
44
57
|
pry (0.12.2)
|
45
58
|
coderay (~> 1.1.0)
|
46
59
|
method_source (~> 0.9.0)
|
47
|
-
pry-byebug (3.
|
60
|
+
pry-byebug (3.8.0)
|
48
61
|
byebug (~> 11.0)
|
49
62
|
pry (~> 0.10)
|
50
63
|
pry-doc (1.0.0)
|
51
64
|
pry (~> 0.11)
|
52
65
|
yard (~> 0.9.11)
|
53
|
-
|
66
|
+
rainbow (3.0.0)
|
67
|
+
rake (13.0.1)
|
54
68
|
rb-fsevent (0.10.3)
|
55
|
-
rb-inotify (0.10.
|
69
|
+
rb-inotify (0.10.1)
|
56
70
|
ffi (~> 1.0)
|
57
71
|
redcarpet (3.4.0)
|
58
|
-
rspec (3.
|
59
|
-
rspec-core (~> 3.
|
60
|
-
rspec-expectations (~> 3.
|
61
|
-
rspec-mocks (~> 3.
|
62
|
-
rspec-core (3.
|
63
|
-
rspec-support (~> 3.
|
64
|
-
rspec-expectations (3.
|
72
|
+
rspec (3.9.0)
|
73
|
+
rspec-core (~> 3.9.0)
|
74
|
+
rspec-expectations (~> 3.9.0)
|
75
|
+
rspec-mocks (~> 3.9.0)
|
76
|
+
rspec-core (3.9.1)
|
77
|
+
rspec-support (~> 3.9.1)
|
78
|
+
rspec-expectations (3.9.0)
|
65
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.
|
80
|
+
rspec-support (~> 3.9.0)
|
81
|
+
rspec-mocks (3.9.1)
|
68
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
83
|
+
rspec-support (~> 3.9.0)
|
70
84
|
rspec-nc (0.3.0)
|
71
85
|
rspec (>= 3)
|
72
86
|
terminal-notifier (>= 1.4)
|
73
|
-
rspec-support (3.
|
87
|
+
rspec-support (3.9.2)
|
88
|
+
rubocop (0.79.0)
|
89
|
+
jaro_winkler (~> 1.5.1)
|
90
|
+
parallel (~> 1.10)
|
91
|
+
parser (>= 2.7.0.1)
|
92
|
+
rainbow (>= 2.2.2, < 4.0)
|
93
|
+
ruby-progressbar (~> 1.7)
|
94
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
74
95
|
ruby-progressbar (1.10.0)
|
75
|
-
ruby_dep (1.5.0)
|
76
96
|
shellany (0.0.1)
|
77
97
|
simplecov (0.16.1)
|
78
98
|
docile (~> 1.1)
|
79
99
|
json (>= 1.8, < 3)
|
80
100
|
simplecov-html (~> 0.10.0)
|
81
101
|
simplecov-html (0.10.2)
|
102
|
+
sync (0.5.0)
|
82
103
|
terminal-notifier (1.7.2)
|
83
|
-
thor (0.
|
84
|
-
|
104
|
+
thor (1.0.1)
|
105
|
+
tins (1.24.0)
|
106
|
+
sync
|
107
|
+
unicode-display_width (1.6.1)
|
108
|
+
uri-ssh_git (2.0.0)
|
109
|
+
yard (0.9.24)
|
85
110
|
|
86
111
|
PLATFORMS
|
87
112
|
ruby
|
88
113
|
|
89
114
|
DEPENDENCIES
|
115
|
+
awesome_print
|
90
116
|
barrier
|
91
117
|
fuubar
|
92
118
|
guard-rspec
|
@@ -97,10 +123,11 @@ DEPENDENCIES
|
|
97
123
|
redcarpet
|
98
124
|
rspec (>= 3.8.0)
|
99
125
|
rspec-nc
|
126
|
+
rubocop
|
100
127
|
simplecov
|
101
128
|
terminal-notifier (= 1.7.2)
|
102
129
|
tinyci!
|
103
130
|
yard
|
104
131
|
|
105
132
|
BUNDLED WITH
|
106
|
-
2.
|
133
|
+
2.1.4
|
data/Guardfile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
interactor :off
|
2
4
|
|
3
|
-
guard :rspec, cmd:
|
5
|
+
guard :rspec, cmd: 'bundle exec rspec', all_after_pass: true, all_on_start: true do
|
4
6
|
watch(%r{^lib\/tinyci\/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
5
|
-
watch(%r{spec\/support\/.+}) {
|
7
|
+
watch(%r{spec\/support\/.+}) { 'spec' }
|
8
|
+
ignore(%r{spec\/support\/repos})
|
6
9
|
watch(%r{^spec\/.+_spec\.rb$})
|
7
|
-
ignore 'coverage'
|
8
10
|
end
|
data/Rakefile
CHANGED
data/bin/tinyci
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
lib = File.expand_path('
|
4
|
+
lib = File.expand_path('../lib', __dir__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
|
6
7
|
require 'tinyci/cli'
|
7
8
|
|
8
|
-
result = TinyCI::CLI.parse!
|
9
|
+
result = TinyCI::CLI.new.parse!
|
9
10
|
|
10
11
|
exit result ? 1 : 0
|
data/lib/pidfile.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class PidFile
|
2
4
|
attr_reader :pidfile, :piddir, :pidpath
|
3
5
|
|
@@ -6,24 +8,21 @@ class PidFile
|
|
6
8
|
VERSION = '0.3.0'
|
7
9
|
|
8
10
|
DEFAULT_OPTIONS = {
|
9
|
-
:
|
10
|
-
:
|
11
|
-
}
|
11
|
+
pidfile: File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME)) + '.pid',
|
12
|
+
piddir: '/var/run'
|
13
|
+
}.freeze
|
12
14
|
|
13
15
|
def initialize(*args)
|
14
16
|
opts = {}
|
15
17
|
|
16
18
|
#----- set options -----#
|
17
|
-
|
18
|
-
|
19
|
-
when args.length == 1 && args[0].class == Hash then
|
19
|
+
if args.empty?
|
20
|
+
elsif args.length == 1 && args[0].class == Hash
|
20
21
|
arg = args.shift
|
21
22
|
|
22
|
-
if arg.class == Hash
|
23
|
-
opts = arg
|
24
|
-
end
|
23
|
+
opts = arg if arg.class == Hash
|
25
24
|
else
|
26
|
-
raise ArgumentError,
|
25
|
+
raise ArgumentError, 'new() expects hash or hashref as argument'
|
27
26
|
end
|
28
27
|
|
29
28
|
opts = DEFAULT_OPTIONS.merge opts
|
@@ -34,14 +33,14 @@ class PidFile
|
|
34
33
|
@fh = nil
|
35
34
|
|
36
35
|
#----- Does the pidfile or pid exist? -----#
|
37
|
-
if
|
36
|
+
if pidfile_exists?
|
38
37
|
if self.class.running?(@pidpath)
|
39
38
|
raise DuplicateProcessError, "TinyCI is already running, process #{self.class.pid} will test your commit, don't worry!"
|
40
|
-
|
39
|
+
|
41
40
|
exit! # exit without removing the existing pidfile
|
42
41
|
end
|
43
42
|
|
44
|
-
|
43
|
+
release
|
45
44
|
end
|
46
45
|
|
47
46
|
#----- create the pidfile -----#
|
@@ -58,18 +57,14 @@ class PidFile
|
|
58
57
|
def pid
|
59
58
|
return @pid unless @pid.nil?
|
60
59
|
|
61
|
-
if
|
62
|
-
@pid = open(self.pidpath, 'r').read.to_i
|
63
|
-
else
|
64
|
-
@pid = nil
|
65
|
-
end
|
60
|
+
@pid = (open(pidpath, 'r').read.to_i if pidfile_exists?)
|
66
61
|
end
|
67
62
|
|
68
63
|
# Boolean stating whether this process is alive and running
|
69
64
|
def alive?
|
70
|
-
return false unless
|
65
|
+
return false unless pid && (pid == Process.pid)
|
71
66
|
|
72
|
-
self.class.process_exists?(
|
67
|
+
self.class.process_exists?(pid)
|
73
68
|
end
|
74
69
|
|
75
70
|
# does the pidfile exist?
|
@@ -88,7 +83,7 @@ class PidFile
|
|
88
83
|
|
89
84
|
# returns the modification time of the pidfile
|
90
85
|
def locktime
|
91
|
-
File.mtime(
|
86
|
+
File.mtime(pidpath)
|
92
87
|
end
|
93
88
|
|
94
89
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
|
@@ -96,37 +91,33 @@ class PidFile
|
|
96
91
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
|
97
92
|
|
98
93
|
# Returns the PID, if any, of the instantiating process
|
99
|
-
def self.pid(path=nil)
|
100
|
-
if pidfile_exists?(path)
|
101
|
-
open(path, 'r').read.to_i
|
102
|
-
end
|
94
|
+
def self.pid(path = nil)
|
95
|
+
open(path, 'r').read.to_i if pidfile_exists?(path)
|
103
96
|
end
|
104
97
|
|
105
98
|
# class method for determining the existence of pidfile
|
106
|
-
def self.pidfile_exists?(path=nil)
|
99
|
+
def self.pidfile_exists?(path = nil)
|
107
100
|
path ||= File.join(DEFAULT_OPTIONS[:piddir], DEFAULT_OPTIONS[:pidfile])
|
108
101
|
|
109
102
|
File.exist?(path)
|
110
103
|
end
|
111
104
|
|
112
105
|
# boolean stating whether the calling program is already running
|
113
|
-
def self.running?(path=nil)
|
106
|
+
def self.running?(path = nil)
|
114
107
|
calling_pid = nil
|
115
108
|
path ||= File.join(DEFAULT_OPTIONS[:piddir], DEFAULT_OPTIONS[:pidfile])
|
116
109
|
|
117
|
-
if pidfile_exists?(path)
|
118
|
-
calling_pid = pid(path)
|
119
|
-
end
|
110
|
+
calling_pid = pid(path) if pidfile_exists?(path)
|
120
111
|
|
121
112
|
process_exists?(calling_pid)
|
122
113
|
end
|
123
114
|
|
124
|
-
private
|
115
|
+
private
|
125
116
|
|
126
117
|
# Writes the process ID to the pidfile and defines @pid as such
|
127
118
|
def create_pidfile
|
128
119
|
# Once the filehandle is created, we don't release until the process dies.
|
129
|
-
@fh = open(
|
120
|
+
@fh = open(pidpath, 'w')
|
130
121
|
@fh.flock(File::LOCK_EX | File::LOCK_NB) || raise
|
131
122
|
@pid = Process.pid
|
132
123
|
@fh.puts @pid
|
@@ -136,15 +127,13 @@ private
|
|
136
127
|
|
137
128
|
# removes the pidfile.
|
138
129
|
def remove_pidfile
|
139
|
-
File.unlink(
|
130
|
+
File.unlink(pidpath) if pidfile_exists?
|
140
131
|
end
|
141
132
|
|
142
133
|
def self.process_exists?(process_id)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
false
|
148
|
-
end
|
134
|
+
Process.kill(0, process_id)
|
135
|
+
true
|
136
|
+
rescue Errno::ESRCH, TypeError # "PID is NOT running or is zombied
|
137
|
+
false
|
149
138
|
end
|
150
139
|
end
|