paraduct 1.0.0.beta6 → 1.0.0

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
  SHA1:
3
- metadata.gz: 2ba1ed4f5fbdbe3c7eb441c902d19898ae379bd8
4
- data.tar.gz: 6e32754a0c902d9da9e2f9f221747bde855a2f61
3
+ metadata.gz: c7bca8c964aef5d616debd095e941a6c245054f5
4
+ data.tar.gz: 15cf9dfab4ca0740cae11ad468c59552ad866cb6
5
5
  SHA512:
6
- metadata.gz: 457ae25a822ca9b9ec1ae823bd7622fb240a408bd96c76ac05b11bac29b1bf81ce6a106d4f6b6b8a98502c900a6fdcfdbca6ffc5313c12965885564239b32ccc
7
- data.tar.gz: 1b8146e9246f13f894f6d26dcb8150b9811f502c532f8978066e7a85aae4f7b0620955c7f7bab8ec6382441d539247e2949f41f4dbdd032c7ad188e8d2bc16b9
6
+ metadata.gz: f3ef3f5048a86bfdd8319c8727bef4bed0cb7a006ab5f1b854d29ab7cb43ef3f6d83bf1fa11f06917152da6e8e9a9046444d08b7f8937d8b8cb503f9b35f9d49
7
+ data.tar.gz: c1faecc0467be7f3de7dea14e037de127b32ad63a3bf283ca28732438612a136e7476ed4a3ce0d811fab55a987506640add8eb47e9e27042091a676ae1297555
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ enabled: true
3
+ config_file: .rubocop.yml
@@ -0,0 +1,223 @@
1
+ # target_version:
2
+ # rubocop v0.37.1
3
+
4
+ # 自動生成されるものはチェック対象から除外する
5
+ AllCops:
6
+ Exclude:
7
+ - "vendor/**/*" # rubocop config/default.yml
8
+ - "db/schema.rb"
9
+ DisplayCopNames: true
10
+
11
+ ##################### Style ##################################
12
+
13
+ # レキシカルスコープの扱いが alias_method の方が自然。
14
+ # https://ernie.io/2014/10/23/in-defense-of-alias/ のように
15
+ # 問題になる場合は自分で緩める。
16
+ Style/Alias:
17
+ EnforcedStyle: prefer_alias_method
18
+
19
+ # redirect_to xxx and return のイディオムを維持したい
20
+ Style/AndOr:
21
+ EnforcedStyle: conditionals
22
+
23
+ # 日本語のコメントを許可する
24
+ Style/AsciiComments:
25
+ Enabled: false
26
+
27
+ # do .. end から更にメソッドチェーンすると見づらいので
28
+ # auto-correct せず、自分で修正する
29
+ # spec 内は見た目が綺麗になるので許可
30
+ Style/BlockDelimiters:
31
+ AutoCorrect: false
32
+ Exclude:
33
+ - "spec/**/*"
34
+
35
+ # option 等、明示的にハッシュにした方が分かりやすい場合もある
36
+ Style/BracesAroundHashParameters:
37
+ Enabled: false
38
+
39
+ # scope が違うとか親 module の存在確認が必要とかデメリットはあるが、
40
+ # namespace 付きのクラスはかなり頻繁に作るので簡単に書きたい。
41
+ Style/ClassAndModuleChildren:
42
+ Enabled: false
43
+
44
+ # Style/CollectionMethods 自体は無効になっているのだが、
45
+ # https://github.com/bbatsov/rubocop/issues/1084
46
+ # https://github.com/bbatsov/rubocop/issues/1334
47
+ # Performance/Detect がこの設定値を見るので PreferredMethods だけ変更しておく。
48
+ #
49
+ # デフォルト値から変えたのは
50
+ # find -> detect
51
+ # ActiveRecord の find と間違えやすいため
52
+ # reduce -> inject
53
+ # detect, reject, select と並べたときに韻を踏んでいるため。
54
+ # collect -> map を維持しているのは文字数が圧倒的に少ないため。
55
+ Style/CollectionMethods:
56
+ PreferredMethods:
57
+ detect: "detect"
58
+ find: "detect"
59
+ inject: "inject"
60
+ reduce: "inject"
61
+
62
+ # Hash#has_key? は許可したい
63
+ Style/DeprecatedHashMethods:
64
+ Enabled: false
65
+
66
+ # ドキュメントの無い public class を許可する
67
+ Style/Documentation:
68
+ Enabled: false
69
+
70
+ # !! のイディオムは積極的に使う
71
+ Style/DoubleNegation:
72
+ Enabled: false
73
+
74
+ # メソッドチェーンの改行は末尾に . を入れる
75
+ # REPL に貼り付けた際の暴発を防ぐため
76
+ Style/DotPosition:
77
+ EnforcedStyle: trailing
78
+
79
+ # 明示的に else で nil を返すのは分かりやすいので許可する
80
+ Style/EmptyElse:
81
+ EnforcedStyle: empty
82
+
83
+ # 桁揃えが綺麗にならないことが多いので migration は除外
84
+ Style/ExtraSpacing:
85
+ Exclude:
86
+ - "db/migrate/*.rb"
87
+
88
+ # いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
89
+ Style/FormatString:
90
+ EnforcedStyle: percent
91
+
92
+ # まだ対応するには早い
93
+ Style/FrozenStringLiteralComment:
94
+ Enabled: false
95
+
96
+ # if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
97
+ # NOTE: https://github.com/bbatsov/rubocop/commit/29945958034db13af9e8ff385ec58cb9eb464596
98
+ # の影響で、if 文の中身が 1 行の場合に警告されるようになっている。
99
+ # Style/IfUnlessModifier の設定見てくれないかなぁ? (v0.36.0)
100
+ Style/GuardClause:
101
+ MinBodyLength: 5
102
+
103
+ # rake タスクの順序の hash は rocket を許可する
104
+ Style/HashSyntax:
105
+ Exclude:
106
+ - "**/*.rake"
107
+ - "Rakefile"
108
+
109
+ # 平たくしてしまうと条件のグルーピングが脳内モデルとズレやすい
110
+ Style/IfInsideElse:
111
+ Enabled: false
112
+
113
+ # 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
114
+ Style/IfUnlessModifier:
115
+ Enabled: false
116
+
117
+ # special_inside_parentheses (default) と比べて
118
+ # * 横に長くなりづらい
119
+ # * メソッド名の長さが変わったときに diff が少ない
120
+ Style/IndentArray:
121
+ EnforcedStyle: consistent
122
+
123
+ # ({ と hash を開始した場合に ( の位置にインデントさせる
124
+ # そもそも {} が必要ない可能性が高いが Style/BracesAroundHashParameters はチェックしないことにしたので
125
+ Style/IndentHash:
126
+ EnforcedStyle: consistent
127
+
128
+ # private/protected は一段深くインデントする
129
+ Style/IndentationConsistency:
130
+ EnforcedStyle: rails
131
+
132
+ # scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
133
+ Style/Lambda:
134
+ Enabled: false
135
+
136
+ # 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
137
+ Style/NumericLiterals:
138
+ MinDigits: 7
139
+
140
+ # 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
141
+ # 名前付きキャプチャを使って参照したいので auto-correct しない
142
+ Style/PerlBackrefs:
143
+ AutoCorrect: false
144
+
145
+ # has_ から始まるメソッドは許可する
146
+ Style/PredicateName:
147
+ NamePrefixBlacklist:
148
+ - "is_"
149
+ - "have_"
150
+ NamePrefix:
151
+ - "is_"
152
+ - "have_"
153
+
154
+ # 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
155
+ Style/RedundantSelf:
156
+ Enabled: false
157
+
158
+ # 受け取り側で multiple assignment しろというのを明示
159
+ Style/RedundantReturn:
160
+ AllowMultipleReturnValues: true
161
+
162
+ # spec 内は見た目が綺麗になるので許可
163
+ Style/Semicolon:
164
+ Exclude:
165
+ - "spec/**/*"
166
+
167
+ # * 式展開したい場合に書き換えるのが面倒
168
+ # * 文章ではダブルクォートよりもシングルクォートの方が頻出する
169
+ # ことから EnforcedStyle: double_quotes 推奨
170
+ Style/StringLiterals:
171
+ EnforcedStyle: double_quotes
172
+
173
+ # auto-correct 時に Style/StringLiterals とカニバって無限ループになる (v0.28.0)
174
+ Style/StringLiteralsInInterpolation:
175
+ Enabled: false
176
+
177
+ # いくらなんでも inject { |a, e| } は短すぎるので分かりやすい名前をつけたい
178
+ Style/SingleLineBlockParams:
179
+ Enabled: false
180
+
181
+ # 複数行の場合はケツカンマを入れる
182
+ Style/TrailingCommaInLiteral:
183
+ EnforcedStyleForMultiline: comma
184
+
185
+ ##################### Lint ##################################
186
+
187
+ # * 同名のメソッドがある場合にローカル変数に `_` を付ける
188
+ # * 一時変数として `_` を付ける
189
+ # というテクニックは頻出する
190
+ Lint/UnderscorePrefixedVariableName:
191
+ Enabled: false
192
+
193
+ # 子クラスで実装させるつもりのメソッドで引っかかるので
194
+ Lint/UnusedMethodArgument:
195
+ Enabled: false
196
+
197
+ ##################### Metrics ##################################
198
+
199
+ # 30 まではギリギリ許せる範囲だった
200
+ Metrics/AbcSize:
201
+ Max: 30
202
+
203
+ # 6 は強すぎるので緩める
204
+ Metrics/CyclomaticComplexity:
205
+ Max: 10
206
+
207
+ # * 警告 120文字
208
+ # * 禁止 160文字
209
+ # のイメージ
210
+ Metrics/LineLength:
211
+ Max: 160
212
+ Exclude:
213
+ - "db/migrate/*.rb"
214
+
215
+ # 20 行超えるのは migration ファイル以外滅多に無い
216
+ Metrics/MethodLength:
217
+ Max: 20
218
+ Exclude:
219
+ - "db/migrate/*.rb"
220
+
221
+ # 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
222
+ Metrics/PerceivedComplexity:
223
+ Max: 8
@@ -0,0 +1,10 @@
1
+ inherit_from: ".onkcop.yml"
2
+
3
+ Style/WordArray:
4
+ Enabled: false
5
+
6
+ Metrics/AbcSize:
7
+ Max: 40
8
+
9
+ Metrics/MethodLength:
10
+ Max: 40
@@ -1,5 +1,8 @@
1
1
  ## master
2
- [full changelog](http://github.com/sue445/paraduct/compare/v0.0.3...master)
2
+ [full changelog](http://github.com/sue445/paraduct/compare/v1.0.0...master)
3
+
4
+ ## v1.0.0
5
+ [full changelog](http://github.com/sue445/paraduct/compare/v0.0.3...v1.0.0)
3
6
 
4
7
  ### Breaking changes :bomb:
5
8
  * Stop convert key capitalize
@@ -15,9 +18,10 @@
15
18
  * Add start command logging
16
19
  * https://github.com/sue445/paraduct/pull/89
17
20
 
18
- ### some refactorings
21
+ ### Refactorings
19
22
  * https://github.com/sue445/paraduct/pull/79
20
23
  * https://github.com/sue445/paraduct/pull/80
24
+ * https://github.com/sue445/paraduct/pull/90
21
25
 
22
26
  ## v0.0.3
23
27
  [full changelog](http://github.com/sue445/paraduct/compare/v0.0.2...v0.0.3)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in paraduct.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -62,9 +62,9 @@ $ paraduct test
62
62
  ## .paraduct.yml Format
63
63
  ```yaml
64
64
  script: |-
65
- echo "NAME1=${NAME1}, NAME2=${NAME2}"
65
+ echo "[START] NAME1=${NAME1}, NAME2=${NAME2}"
66
66
  after_script: |-
67
- echo "Build is finished"
67
+ echo "[END] NAME1=${NAME1}, NAME2=${NAME2}"
68
68
  work_dir: tmp/paraduct_workspace
69
69
  variables:
70
70
  NAME1:
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
- require 'yard'
3
+ require "yard"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'paraduct/cli'
3
+ require "paraduct/cli"
4
4
 
5
5
  Paraduct::CLI.start
@@ -2,24 +2,24 @@ require "active_support"
2
2
  require "active_support/deprecation"
3
3
  require "active_support/core_ext"
4
4
  require "pathname"
5
- require 'paraduct/version'
5
+ require "paraduct/version"
6
6
  require "colorize"
7
7
 
8
8
  module Paraduct
9
- autoload :ColoredLabelLogger, 'paraduct/colored_label_logger'
10
- autoload :Configuration , 'paraduct/configuration'
11
- autoload :Errors , 'paraduct/errors'
12
- autoload :ParallelRunner , 'paraduct/parallel_runner'
13
- autoload :Runner , 'paraduct/runner'
14
- autoload :SyncUtils , 'paraduct/sync_utils'
15
- autoload :TestResponse , 'paraduct/test_response'
16
- autoload :VariableConverter , 'paraduct/variable_converter'
9
+ autoload :ColoredLabelLogger, "paraduct/colored_label_logger"
10
+ autoload :Configuration, "paraduct/configuration"
11
+ autoload :Errors, "paraduct/errors"
12
+ autoload :ParallelRunner, "paraduct/parallel_runner"
13
+ autoload :Runner, "paraduct/runner"
14
+ autoload :SyncUtils, "paraduct/sync_utils"
15
+ autoload :TestResponse, "paraduct/test_response"
16
+ autoload :VariableConverter, "paraduct/variable_converter"
17
17
 
18
18
  class << self
19
19
  def configuration
20
20
  Paraduct::Configuration.instance
21
21
  end
22
- alias :config :configuration
22
+ alias_method :config, :configuration
23
23
 
24
24
  def logger
25
25
  @logger ||= ActiveSupport::Logger.new(STDOUT)
@@ -1,5 +1,5 @@
1
- require 'paraduct'
2
- require 'thor'
1
+ require "paraduct"
2
+ require "thor"
3
3
 
4
4
  module Paraduct
5
5
  class CLI < Thor
@@ -20,7 +20,7 @@ module Paraduct
20
20
  :light_magenta,
21
21
  :light_red,
22
22
  :light_blue,
23
- ]
23
+ ].freeze
24
24
  def self.next_color
25
25
  @color_index ||= -1
26
26
  @color_index = (@color_index + 1) % COLORS.length
@@ -62,8 +62,8 @@ module Paraduct
62
62
 
63
63
  private
64
64
 
65
- def config_data
66
- @config_data ||= YAML.load_file(config_file).with_indifferent_access
67
- end
65
+ def config_data
66
+ @config_data ||= YAML.load_file(config_file).with_indifferent_access
67
+ end
68
68
  end
69
69
  end
@@ -23,7 +23,7 @@ START matrix test
23
23
  runner = Paraduct::Runner.new(
24
24
  params: params,
25
25
  base_job_dir: base_job_dir,
26
- job_id: index + 1,
26
+ job_id: index + 1
27
27
  )
28
28
  pool.process do
29
29
  runner.logger.info "[START] params: #{runner.formatted_params}"
@@ -44,7 +44,7 @@ START matrix test
44
44
  params: runner.params,
45
45
  formatted_params: runner.formatted_params,
46
46
  successful: successful,
47
- stdout: stdout,
47
+ stdout: stdout
48
48
  )
49
49
  end
50
50
  end
@@ -67,7 +67,7 @@ START matrix test
67
67
  runner.logger.error "exitstatus=#{e.status}, #{e.inspect}"
68
68
  [e.message, false]
69
69
 
70
- rescue Exception => e
70
+ rescue => e
71
71
  runner.logger.error "Unknown error: #{e.inspect}"
72
72
  runner.logger.error e.backtrace.join("\n")
73
73
  [nil, false]
@@ -25,7 +25,7 @@ module Paraduct
25
25
  # @raise [Paraduct::Errors::ProcessError] command exited error status
26
26
  def perform(script)
27
27
  export_variables = @params.reverse_merge("PARADUCT_JOB_ID" => @job_id, "PARADUCT_JOB_NAME" => job_name)
28
- variable_string = export_variables.map{ |key, value| %(export #{key}="#{value}";) }.join(" ")
28
+ variable_string = export_variables.map { |key, value| %(export #{key}="#{value}";) }.join(" ")
29
29
 
30
30
  Array.wrap(script).inject("") do |stdout, command|
31
31
  stdout << run_command("#{variable_string} #{command}")
@@ -38,11 +38,11 @@ module Paraduct
38
38
  end
39
39
 
40
40
  def job_name
41
- @params.map { |key, value| "#{key}_#{value}" }.join("_").gsub(%r([/ ]), "_")
41
+ @params.map { |key, value| "#{key}_#{value}" }.join("_").gsub(%r{[/ ]}, "_")
42
42
  end
43
43
 
44
44
  def formatted_params
45
- @params.map{ |key, value| "#{key}=#{value}" }.join(", ")
45
+ @params.map { |key, value| "#{key}=#{value}" }.join(", ")
46
46
  end
47
47
 
48
48
  def logger
@@ -57,31 +57,31 @@ module Paraduct
57
57
 
58
58
  private
59
59
 
60
- def run_command(command)
61
- full_stdout = ""
62
- exit_status = nil
63
-
64
- logger.info "run_command: #{command}"
65
-
66
- PTY.spawn(command) do |stdin, stdout, pid|
67
- stdout.close_write
68
- stdin.sync = true
69
-
70
- begin
71
- stdin.each do |line|
72
- line.strip!
73
- logger.info line
74
- full_stdout << "#{line}\n"
60
+ def run_command(command)
61
+ full_stdout = ""
62
+ exit_status = nil
63
+
64
+ logger.info "run_command: #{command}"
65
+
66
+ PTY.spawn(command) do |stdin, stdout, pid|
67
+ stdout.close_write
68
+ stdin.sync = true
69
+
70
+ begin
71
+ stdin.each do |line|
72
+ line.strip!
73
+ logger.info line
74
+ full_stdout << "#{line}\n"
75
+ end
76
+ rescue Errno::EIO # rubocop:disable Lint/HandleExceptions
77
+ ensure
78
+ _, exit_status = Process.waitpid2(pid)
75
79
  end
76
- rescue Errno::EIO
77
- ensure
78
- _, exit_status = Process.waitpid2(pid)
79
80
  end
80
- end
81
81
 
82
- raise Paraduct::Errors::ProcessError.new(full_stdout, exit_status) unless exit_status.success?
82
+ raise Paraduct::Errors::ProcessError.new(full_stdout, exit_status) unless exit_status.success?
83
83
 
84
- full_stdout
85
- end
84
+ full_stdout
85
+ end
86
86
  end
87
87
  end