tinyci 0.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- 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/.yardopts +1 -0
- data/CHANGELOG.md +5 -0
- data/Dockerfile +3 -2
- data/Gemfile +2 -1
- data/Gemfile.lock +67 -39
- 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 -78
- 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 +28 -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 +30 -22
- metadata +106 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 526fd2468b417c2c5088f77c324eaca880eecf9eccf7fb75aa0ad279b785a585
|
4
|
+
data.tar.gz: 5570305c5a976543d57ae8e28d6f7cb0e571d05c7d40474e51c37719ffff0375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bc5e896f22b5d3756182d17c7f0710ecfeed5568f25dd2f44fd23dbb59bb776a77a06a0245f910677cd568142e854f88c7d4c73046c469d94ddf4132f5a36fc
|
7
|
+
data.tar.gz: 1db45990545fb13e6ad81dafdb4864970c949dade3f51dac26606156ad28729d9e9ae9324d5d1a69aa09271b2ecceb8b2fa44537d1ab4a2cd82f63a2931e5932
|
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
|
-
|
1
|
+
3.0.2
|
data/.tinyci.yml
CHANGED
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.4.2 - May 28, 2019
|
2
|
+
Make hook installer use relative path, so installed hooks will not need to be rewritten when tinyci is updated
|
3
|
+
Add --absolute-path option to install for the old behavior, needed in testing etc
|
4
|
+
0.4.1 - May 28, 2019
|
5
|
+
Fix .yaropts to include all markdown files
|
1
6
|
0.4 - May 27, 2019
|
2
7
|
New, terser configuration format
|
3
8
|
`after_all` hook
|
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,28 +1,37 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tinyci (0.
|
4
|
+
tinyci (0.5.1)
|
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.
|
11
|
-
coderay (1.1.
|
15
|
+
byebug (11.1.1)
|
16
|
+
coderay (1.1.3)
|
12
17
|
diff-lcs (1.3)
|
13
18
|
docile (1.3.1)
|
14
|
-
ffi (1.
|
15
|
-
|
19
|
+
ffi (1.15.4)
|
20
|
+
file-tail (1.2.0)
|
21
|
+
tins (~> 1.0)
|
22
|
+
formatador (0.3.0)
|
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.18.0)
|
20
29
|
formatador (>= 0.2.4)
|
21
30
|
listen (>= 2.7, < 4.0)
|
22
31
|
lumberjack (>= 1.0.12, < 2.0)
|
23
32
|
nenv (~> 0.1)
|
24
33
|
notiffany (~> 0.0)
|
25
|
-
pry (>= 0.
|
34
|
+
pry (>= 0.13.0)
|
26
35
|
shellany (~> 0.0)
|
27
36
|
thor (>= 0.18.1)
|
28
37
|
guard-compat (1.2.1)
|
@@ -30,77 +39,96 @@ 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.
|
39
|
-
method_source (0.
|
42
|
+
jaro_winkler (1.5.4)
|
43
|
+
json (2.3.0)
|
44
|
+
listen (3.7.0)
|
45
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
46
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
47
|
+
lumberjack (1.2.8)
|
48
|
+
method_source (1.0.0)
|
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)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
pry
|
54
|
+
parallel (1.19.1)
|
55
|
+
parser (2.7.0.2)
|
56
|
+
ast (~> 2.4.0)
|
57
|
+
pry (0.14.1)
|
58
|
+
coderay (~> 1.1)
|
59
|
+
method_source (~> 1.0)
|
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
|
-
|
54
|
-
|
55
|
-
rb-
|
66
|
+
rainbow (3.0.0)
|
67
|
+
rake (13.0.1)
|
68
|
+
rb-fsevent (0.11.0)
|
69
|
+
rb-inotify (0.10.1)
|
56
70
|
ffi (~> 1.0)
|
57
|
-
redcarpet (3.
|
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.
|
71
|
+
redcarpet (3.5.1)
|
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 (
|
84
|
-
|
104
|
+
thor (1.1.0)
|
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
|
118
|
+
guard (= 2.18.0)
|
92
119
|
guard-rspec
|
93
120
|
pry
|
94
121
|
pry-byebug
|
95
122
|
pry-doc
|
96
123
|
rake
|
97
|
-
redcarpet
|
124
|
+
redcarpet (>= 3.5.1)
|
98
125
|
rspec (>= 3.8.0)
|
99
126
|
rspec-nc
|
127
|
+
rubocop
|
100
128
|
simplecov
|
101
129
|
terminal-notifier (= 1.7.2)
|
102
130
|
tinyci!
|
103
131
|
yard
|
104
132
|
|
105
133
|
BUNDLED WITH
|
106
|
-
2.
|
134
|
+
2.2.22
|
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
|