tinyci 0.4.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 681e4adfd06fa23631e109ffd7a2194fe9786f18d9b87a8f849bdefd42bc9fce
4
- data.tar.gz: ff3c5937f01bcb140b1f5ac893e03c9c49368abf6175c9fdea9da6882ae10732
3
+ metadata.gz: d07c0c3a6bf3981f3be16033ee0ab5bc708c3a17ef03657644af3701164aef3e
4
+ data.tar.gz: 9c60154d9910f6338ae397ff477188d49fc8bdcdb5b3bdc131a1586e93936553
5
5
  SHA512:
6
- metadata.gz: 5d63a10bc859f14e0384fcd176ecef59389ee6943705562acee4abeb59196192d22fec8bfa5146fea9f3d3007da632de1f7eaa05023691967cf64b5ffb33044c
7
- data.tar.gz: 86e146bbe8300458390ad469dd4913e75e8dd72e3bfb2a52060cf3e269f4faddb5133243b7449e76fbaf2d6e49cbecdd6609c7111dbadf7e50a4c88490164fe0
6
+ metadata.gz: 3f35bdecd2f6e8d9038d1244859a8ec4ba82404ff889799604a6701a9cfdabdc392c09c90a83a3f30eddd6456295ac095a3de02997ff58b5a64d2ad012144cba
7
+ data.tar.gz: f5e2df0e0debc915b95ab4e35e99afebb8c6f7a17224151c04c4fbca5ecbcba3e4de069cb966182f083590101357cc2690889e0acc7ec393583d273a1fe4314f
data/.gitignore CHANGED
@@ -1,7 +1,6 @@
1
1
  doc
2
2
  .yardoc
3
- spec/support/repos/*
4
- !*.git.tar.gz
3
+ spec/support/repos/*.git
5
4
  spec/examples.txt
6
5
  tmp
7
6
  pkg
@@ -10,3 +9,4 @@ coverage
10
9
  .DS_Store
11
10
  rubocop.txt
12
11
  spec/support/tmp
12
+ builds
data/.rspec CHANGED
@@ -3,3 +3,5 @@
3
3
  --order random
4
4
  --format Fuubar
5
5
  --format Nc
6
+ --tag ~slow
7
+ --tag ~brittle
@@ -1,6 +1,21 @@
1
1
  AllCops:
2
+ Exclude:
3
+ - 'spec/**/*'
4
+ - 'lib/pidfile.rb'
2
5
  TargetRubyVersion: 2.5
3
-
4
- Metrics/LineLength:
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
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.6.5
@@ -1,2 +1,4 @@
1
1
  build: docker build -t tinyci .
2
- test: docker run tinyci bundle exec rspec --format documentation
2
+ test: docker run --rm tinyci bundle exec rspec --format documentation
3
+ hooks:
4
+ after_all: rm -rf <%= export %>
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 --no-cache --jobs=4
20
+ RUN bundle install --jobs=$(nproc)
20
21
 
21
22
  ADD . /tinyci
22
23
 
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
- source "https://rubygems.org"
2
+
3
+ source 'https://rubygems.org'
3
4
 
4
5
  gemspec
@@ -1,22 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tinyci (0.4.2)
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.0.1)
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.10.0)
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
- guard (2.15.0)
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
- json (2.2.0)
34
- listen (3.1.5)
35
- rb-fsevent (~> 0.9, >= 0.9.4)
36
- rb-inotify (~> 0.9, >= 0.9.7)
37
- ruby_dep (~> 1.2)
38
- lumberjack (1.0.13)
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
- notiffany (0.1.1)
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.7.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
- rake (12.3.2)
66
+ rainbow (3.0.0)
67
+ rake (13.0.1)
54
68
  rb-fsevent (0.10.3)
55
- rb-inotify (0.10.0)
69
+ rb-inotify (0.10.1)
56
70
  ffi (~> 1.0)
57
71
  redcarpet (3.4.0)
58
- rspec (3.8.0)
59
- rspec-core (~> 3.8.0)
60
- rspec-expectations (~> 3.8.0)
61
- rspec-mocks (~> 3.8.0)
62
- rspec-core (3.8.0)
63
- rspec-support (~> 3.8.0)
64
- rspec-expectations (3.8.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.8.0)
67
- rspec-mocks (3.8.0)
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.8.0)
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.8.0)
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.20.3)
84
- yard (0.9.19)
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.0.1
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: "bundle exec rspec", all_after_pass: true, all_on_start: true do
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\/.+}) { "spec" }
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
@@ -1 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
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('../../lib', __FILE__)
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
@@ -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
- :pidfile => File.basename($0, File.extname($0)) + ".pid",
10
- :piddir => '/var/run',
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
- case
18
- when args.length == 0 then
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, "new() expects hash or hashref as argument"
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 self.pidfile_exists?
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
- self.release
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 self.pidfile_exists?
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 self.pid && (self.pid == Process.pid)
65
+ return false unless pid && (pid == Process.pid)
71
66
 
72
- self.class.process_exists?(self.pid)
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(self.pidpath)
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(self.pidpath, "w")
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(self.pidpath) if self.pidfile_exists?
130
+ File.unlink(pidpath) if pidfile_exists?
140
131
  end
141
132
 
142
133
  def self.process_exists?(process_id)
143
- begin
144
- Process.kill(0, process_id)
145
- true
146
- rescue Errno::ESRCH, TypeError # "PID is NOT running or is zombied
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tinyci/executor'
2
4
 
3
5
  module TinyCI
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tinyci/executor'
2
4
 
3
5
  module TinyCI
4
6
  module Builders
5
- class TestBuilder < TinyCI::Executor
7
+ class TestBuilder < TinyCI::Executor
6
8
  def build
7
9
  raise 'Simulated build failed' if @config[:result] == false
8
10
  end