dynflow 0.7.4 → 0.7.5
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.
- data/lib/dynflow/action.rb +28 -11
- data/lib/dynflow/execution_plan.rb +1 -1
- data/lib/dynflow/execution_plan/steps/plan_step.rb +2 -2
- data/lib/dynflow/testing/dummy_planned_action.rb +1 -1
- data/lib/dynflow/testing/factories.rb +1 -1
- data/lib/dynflow/testing/mimic.rb +3 -0
- data/lib/dynflow/version.rb +1 -1
- data/test/execution_plan_test.rb +10 -0
- data/test/support/code_workflow_example.rb +1 -0
- metadata +2 -2
data/lib/dynflow/action.rb
CHANGED
@@ -49,9 +49,9 @@ module Dynflow
|
|
49
49
|
nil
|
50
50
|
end
|
51
51
|
|
52
|
-
ERROR
|
53
|
-
SUSPEND
|
54
|
-
Phase
|
52
|
+
ERROR = Object.new
|
53
|
+
SUSPEND = Object.new
|
54
|
+
Phase = Algebrick.type do
|
55
55
|
Executable = type do
|
56
56
|
variants Plan = atom,
|
57
57
|
Run = atom,
|
@@ -140,10 +140,11 @@ module Dynflow
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
def set_plan_context(execution_plan, trigger)
|
143
|
+
def set_plan_context(execution_plan, trigger, from_subscription)
|
144
144
|
phase! Plan
|
145
|
-
@execution_plan
|
146
|
-
@trigger
|
145
|
+
@execution_plan = Type! execution_plan, ExecutionPlan
|
146
|
+
@trigger = Type! trigger, Action, NilClass
|
147
|
+
@from_subscription = Type! from_subscription, TrueClass, FalseClass
|
147
148
|
end
|
148
149
|
|
149
150
|
def trigger
|
@@ -151,6 +152,11 @@ module Dynflow
|
|
151
152
|
@trigger
|
152
153
|
end
|
153
154
|
|
155
|
+
def from_subscription?
|
156
|
+
phase! Plan
|
157
|
+
@from_subscription
|
158
|
+
end
|
159
|
+
|
154
160
|
def execution_plan
|
155
161
|
phase! Plan, Present
|
156
162
|
@execution_plan
|
@@ -271,7 +277,7 @@ module Dynflow
|
|
271
277
|
# Use #plan_self and #plan_action methods to plan actions.
|
272
278
|
# It can use DB in this phase.
|
273
279
|
def plan(*args)
|
274
|
-
if
|
280
|
+
if from_subscription?
|
275
281
|
# if the action is triggered by subscription, by default use the
|
276
282
|
# input of parent action.
|
277
283
|
# should be replaced by referencing the input from input format
|
@@ -340,7 +346,7 @@ module Dynflow
|
|
340
346
|
|
341
347
|
def plan_action(action_class, *args)
|
342
348
|
phase! Plan
|
343
|
-
@execution_plan.add_plan_step(action_class, self).execute(@execution_plan,
|
349
|
+
@execution_plan.add_plan_step(action_class, self).execute(@execution_plan, self, false, *args)
|
344
350
|
end
|
345
351
|
|
346
352
|
# DSL for run phase
|
@@ -358,7 +364,7 @@ module Dynflow
|
|
358
364
|
throw ERROR
|
359
365
|
end
|
360
366
|
|
361
|
-
def with_error_handling(&block)
|
367
|
+
def with_error_handling(propagate_error = nil, &block)
|
362
368
|
raise "wrong state #{self.state}" unless [:skipping, :running].include?(self.state)
|
363
369
|
|
364
370
|
begin
|
@@ -378,6 +384,10 @@ module Dynflow
|
|
378
384
|
else
|
379
385
|
raise "wrong state #{self.state}"
|
380
386
|
end
|
387
|
+
|
388
|
+
if propagate_error && self.state == :error
|
389
|
+
raise(@step.error.exception)
|
390
|
+
end
|
381
391
|
end
|
382
392
|
|
383
393
|
def set_error(error)
|
@@ -392,7 +402,10 @@ module Dynflow
|
|
392
402
|
phase! Plan
|
393
403
|
self.state = :running
|
394
404
|
save_state
|
395
|
-
|
405
|
+
|
406
|
+
# when the error occurred inside the planning, catch that
|
407
|
+
# before getting out of the planning phase
|
408
|
+
with_error_handling(!root_action?) do
|
396
409
|
concurrence do
|
397
410
|
world.middleware.execute(:plan, self, *args) do |*new_args|
|
398
411
|
plan(*new_args)
|
@@ -407,7 +420,7 @@ module Dynflow
|
|
407
420
|
@execution_plan.switch_flow(Flows::Concurrence.new([trigger_flow].compact)) do
|
408
421
|
subscribed_actions.each do |action_class|
|
409
422
|
new_plan_step = @execution_plan.add_plan_step(action_class, self)
|
410
|
-
new_plan_step.execute(@execution_plan, self, *args)
|
423
|
+
new_plan_step.execute(@execution_plan, self, true, *args)
|
411
424
|
end
|
412
425
|
end
|
413
426
|
end
|
@@ -475,5 +488,9 @@ module Dynflow
|
|
475
488
|
value.replace not_serializable: true
|
476
489
|
raise e
|
477
490
|
end
|
491
|
+
|
492
|
+
def root_action?
|
493
|
+
@trigger.nil?
|
494
|
+
end
|
478
495
|
end
|
479
496
|
end
|
@@ -152,7 +152,7 @@ module Dynflow
|
|
152
152
|
world.transaction_adapter.transaction do
|
153
153
|
world.middleware.execute(:plan_phase, root_plan_step.action_class) do
|
154
154
|
with_planning_scope do
|
155
|
-
root_plan_step.execute(self, nil, *args)
|
155
|
+
root_plan_step.execute(self, nil, false, *args)
|
156
156
|
|
157
157
|
if @dependency_graph.unresolved?
|
158
158
|
raise "Some dependencies were not resolved: #{@dependency_graph.inspect}"
|
@@ -36,11 +36,11 @@ module Dynflow
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# @return [Action]
|
39
|
-
def execute(execution_plan, trigger, *args)
|
39
|
+
def execute(execution_plan, trigger, from_subscription, *args)
|
40
40
|
unless @action
|
41
41
|
raise "The action was not initialized, you might forgot to call initialize_action method"
|
42
42
|
end
|
43
|
-
@action.set_plan_context(execution_plan, trigger)
|
43
|
+
@action.set_plan_context(execution_plan, trigger, from_subscription)
|
44
44
|
Type! execution_plan, ExecutionPlan
|
45
45
|
with_meta_calculation(@action) do
|
46
46
|
@action.execute(*args)
|
data/lib/dynflow/version.rb
CHANGED
data/test/execution_plan_test.rb
CHANGED
@@ -166,6 +166,16 @@ module Dynflow
|
|
166
166
|
|
167
167
|
end
|
168
168
|
|
169
|
+
describe 'error in planning phase' do
|
170
|
+
let :execution_plan do
|
171
|
+
world.plan(Support::CodeWorkflowExample::IncomingIssues, [:fail] + issues_data)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'stops the planning right after the first error occurred' do
|
175
|
+
execution_plan.steps.size.must_equal 2
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
169
179
|
describe 'multi dependencies' do
|
170
180
|
let :execution_plan do
|
171
181
|
world.plan(Support::CodeWorkflowExample::Commit, 'sha' => 'abc123')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|