ruby_workspace_manager 0.4.0 → 0.6.0

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.
@@ -5,9 +5,20 @@ require "etc"
5
5
 
6
6
  module Rwm
7
7
  class TaskRunner
8
- Result = Struct.new(:package_name, :task, :success, :output, :skipped, keyword_init: true)
8
+ Result = Struct.new(:package_name, :task, :status, :output, keyword_init: true) do
9
+ def passed? = status == :passed
10
+ def failed? = status == :failed
11
+ def skipped? = status == :skipped
12
+ def dep_skipped? = status == :dep_skipped
13
+ def errored? = status == :errored
14
+ def success? = passed? || skipped?
15
+ end
9
16
 
10
- NO_TASK_PATTERN = /Don't know how to build task/
17
+ NO_TASK_PATTERN = /
18
+ don.t\s+know\s+how\s+to\s+build\s+task
19
+ |
20
+ rake\s+--tasks
21
+ /ix
11
22
 
12
23
  attr_reader :results
13
24
 
@@ -60,28 +71,38 @@ module Rwm
60
71
 
61
72
  pending.delete(pkg)
62
73
  running[pkg.name] = Thread.new do
63
- result = run_single(pkg, &command_proc)
64
- mutex.synchronize do
65
- @results << result
66
- running.delete(pkg.name)
67
- if result.success
68
- completed << pkg.name
69
- else
70
- skip_names = @graph.transitive_dependents(pkg.name)
71
- .select { |n| package_names.include?(n) }
72
- skip_names.each do |name|
73
- skip_pkg = pending.find { |p| p.name == name }
74
- if skip_pkg
75
- pending.delete(skip_pkg)
76
- skipped << name
77
- @results << Result.new(
78
- package_name: name, task: "skipped",
79
- success: false, output: "Skipped due to failed dependency: #{pkg.name}"
80
- )
74
+ begin
75
+ result = run_single(pkg, &command_proc)
76
+ rescue => e
77
+ result = Result.new(
78
+ package_name: pkg.name, task: "error",
79
+ status: :errored, output: "Error: #{e.class}: #{e.message}"
80
+ )
81
+ ensure
82
+ next unless result # thread was killed before completing
83
+
84
+ mutex.synchronize do
85
+ @results << result
86
+ running.delete(pkg.name)
87
+ if result.success?
88
+ completed << pkg.name
89
+ else
90
+ skip_names = @graph.transitive_dependents(pkg.name)
91
+ .select { |n| package_names.include?(n) }
92
+ skip_names.each do |name|
93
+ skip_pkg = pending.find { |p| p.name == name }
94
+ if skip_pkg
95
+ pending.delete(skip_pkg)
96
+ skipped << name
97
+ @results << Result.new(
98
+ package_name: name, task: "skipped",
99
+ status: :dep_skipped, output: "Skipped due to failed dependency: #{pkg.name}"
100
+ )
101
+ end
81
102
  end
82
103
  end
104
+ condition.broadcast
83
105
  end
84
- condition.broadcast
85
106
  end
86
107
  end
87
108
  end
@@ -107,11 +128,11 @@ module Rwm
107
128
  end
108
129
 
109
130
  def success?
110
- @results.all?(&:success)
131
+ @results.none? { |r| r.failed? || r.errored? }
111
132
  end
112
133
 
113
134
  def failed_results
114
- @results.select { |r| !r.success }
135
+ @results.select { |r| r.failed? || r.errored? }
115
136
  end
116
137
 
117
138
  private
@@ -135,13 +156,12 @@ module Rwm
135
156
 
136
157
  # Detect "task not found" and treat as skipped, not failed
137
158
  if !status.success? && stderr.match?(NO_TASK_PATTERN)
138
- Rwm.debug("#{pkg.name}: task not found, skipping")
159
+ Rwm.debug("#{pkg.name}: task not found (matched: #{stderr.lines.first&.chomp})")
139
160
  return Result.new(
140
161
  package_name: pkg.name,
141
162
  task: cmd.join(" "),
142
- success: true,
143
- output: "",
144
- skipped: true
163
+ status: :skipped,
164
+ output: ""
145
165
  )
146
166
  end
147
167
 
@@ -154,7 +174,7 @@ module Rwm
154
174
  Result.new(
155
175
  package_name: pkg.name,
156
176
  task: cmd.join(" "),
157
- success: status.success?,
177
+ status: status.success? ? :passed : :failed,
158
178
  output: output
159
179
  )
160
180
  end
data/lib/rwm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rwm
4
- VERSION = "0.4.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_workspace_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siddharth Bhatt
@@ -43,6 +43,7 @@ files:
43
43
  - lib/rwm/git_hooks.rb
44
44
  - lib/rwm/overcommit.rb
45
45
  - lib/rwm/package.rb
46
+ - lib/rwm/rails.rb
46
47
  - lib/rwm/rake.rb
47
48
  - lib/rwm/task_cache.rb
48
49
  - lib/rwm/task_runner.rb