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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c0c2cdfc2c4897dd17a0d9d3c19ea63a416726f8df3a35b355a344f7a966fd
4
- data.tar.gz: b77bd08bdab867aec1c9ec02057d8519b55c9b23ca0f504afc74bb6b83e01165
3
+ metadata.gz: 526fd2468b417c2c5088f77c324eaca880eecf9eccf7fb75aa0ad279b785a585
4
+ data.tar.gz: 5570305c5a976543d57ae8e28d6f7cb0e571d05c7d40474e51c37719ffff0375
5
5
  SHA512:
6
- metadata.gz: 66b4ef9b258a6381a78af29a69904d33655bb7d1970740449ad21c823fc084883bd12ce0d5bcdfaf1bdf364b49918156c27cc243797c6868fb0a35d8544c402e
7
- data.tar.gz: 60cd46b3b67adf5473202b6d392d5b6897c7f7deb4f5017fc2f57a6433e4af4d67cec99655d22c28478f05a648338d0165f65b46ef5c99abba048e8d0dc7e4aa
6
+ metadata.gz: 2bc5e896f22b5d3756182d17c7f0710ecfeed5568f25dd2f44fd23dbb59bb776a77a06a0245f910677cd568142e854f88c7d4c73046c469d94ddf4132f5a36fc
7
+ data.tar.gz: 1db45990545fb13e6ad81dafdb4864970c949dade3f51dac26606156ad28729d9e9ae9324d5d1a69aa09271b2ecceb8b2fa44537d1ab4a2cd82f63a2931e5932
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
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
- 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
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 3.0.2
data/.tinyci.yml CHANGED
@@ -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/.yardopts CHANGED
@@ -1 +1,2 @@
1
1
  --load lib/yard_plugin.rb
2
+ - '*.md'
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 --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
data/Gemfile.lock CHANGED
@@ -1,28 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tinyci (0.4)
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.0.1)
11
- coderay (1.1.2)
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.10.0)
15
- formatador (0.2.5)
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
- guard (2.15.0)
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.9.12)
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
- 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)
39
- method_source (0.9.2)
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
- 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)
44
- pry (0.12.2)
45
- coderay (~> 1.1.0)
46
- method_source (~> 0.9.0)
47
- pry-byebug (3.7.0)
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
- rake (12.3.2)
54
- rb-fsevent (0.10.3)
55
- rb-inotify (0.10.0)
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.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)
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.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.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.0.1
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: "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
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
- :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