trailblazer-activity-dsl-linear 1.2.4 → 1.2.6
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CHANGES.md +18 -0
- data/lib/trailblazer/activity/dsl/linear/helper/path.rb +21 -6
- data/lib/trailblazer/activity/dsl/linear/normalizer.rb +1 -0
- data/lib/trailblazer/activity/dsl/linear/sequence/builder.rb +2 -1
- data/lib/trailblazer/activity/dsl/linear/sequence/compiler.rb +51 -34
- data/lib/trailblazer/activity/dsl/linear/strategy.rb +1 -1
- data/lib/trailblazer/activity/dsl/linear/version.rb +1 -1
- data/lib/trailblazer/activity/dsl/linear/zeitwerk.rb +34 -0
- data/trailblazer-activity-dsl-linear.gemspec +3 -3
- metadata +12 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e586cfffe36a34eb165699f525802629709dc0934d193a8bcbc460c33e63a4a0
|
4
|
+
data.tar.gz: 965ee6e76f86fa2e57fb11fff9c9e511ce655e72e01e431ed72a9bc338aeedd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 354cd6aa6b514f1b5e43b7b3b04a39f237e7d0dbb7b0ee4ffff876e7ed381fca59393e78b945b1a6d558678d770c84150770273164357d45a6b698d8f040952d
|
7
|
+
data.tar.gz: 1cebc503caa1c55d6753e233c519eeb0337583dc3216fa5fb5829bc7286dde95ad3b752bef876b762f94846d07ff21dd06d68306d5e72133d226f80819d64b9a
|
data/.github/workflows/ci.yml
CHANGED
@@ -5,10 +5,10 @@ jobs:
|
|
5
5
|
strategy:
|
6
6
|
fail-fast: false
|
7
7
|
matrix:
|
8
|
-
ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', 'head', 'jruby']
|
8
|
+
ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', "3.3", 'head', 'jruby']
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
steps:
|
11
|
-
- uses: actions/checkout@
|
11
|
+
- uses: actions/checkout@v4
|
12
12
|
- uses: ruby/setup-ruby@v1
|
13
13
|
with:
|
14
14
|
ruby-version: ${{ matrix.ruby }}
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# 1.2.6
|
2
|
+
|
3
|
+
* Speed up compile time of activities by ~ 1.3x by not using `Intermediate::Compiler`
|
4
|
+
but compiling the `Activity::Circuit` and `Schema` directly. This also saves runtime
|
5
|
+
memory.
|
6
|
+
|
7
|
+
# 1.2.5
|
8
|
+
|
9
|
+
* Fix a bug where, within a helper `Path()`, the last step couldn't
|
10
|
+
explicitly define additional `Output()`, e.g. for `:failure`.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
... => Path(connect_to: Track(:success)) do
|
14
|
+
step :upload,
|
15
|
+
Output(Trailblazer::Activity::Left, :failure) => Track(:failure) # FIXME: this configuration gets lost.
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
1
19
|
# 1.2.4
|
2
20
|
|
3
21
|
* Fix a bug where using `fail_fast: true` (same with `:pass_fast`) would result in a
|
@@ -97,14 +97,29 @@ module Trailblazer
|
|
97
97
|
# Connect last row of the {sequence} to the given step via its {Id}
|
98
98
|
# Useful when steps needs to be inserted in between {Start} and {connect Id()}.
|
99
99
|
private def connect_for_sequence(sequence, connect_to:)
|
100
|
-
|
100
|
+
last_step_on_path = sequence[-1]
|
101
|
+
output_searches = last_step_on_path[2]
|
102
|
+
|
103
|
+
last_step_outputs =
|
104
|
+
output_searches.collect do |search_strategy|
|
105
|
+
# TODO: introduce {search_strategy.to_h} so we don't need to execute it here.
|
106
|
+
output, _ = search_strategy.(sequence, last_step_on_path) # FIXME: the Forward() proc contains the row's Output, and the only current way to retrieve it is calling the search strategy. It should be Forward#to_h
|
107
|
+
output
|
108
|
+
end
|
109
|
+
|
110
|
+
# we want to reconnect the last step's {:success} output, everything else we keep.
|
111
|
+
success_output = last_step_outputs.find { |output| output.to_h[:semantic] == :success } or raise
|
112
|
+
|
113
|
+
# FIXME: what about End()?
|
114
|
+
success_search = Sequence::Search.ById(success_output, connect_to.value) if connect_to.instance_of?(Linear::Normalizer::OutputTuples::Id)
|
115
|
+
success_search = Sequence::Search.Forward(success_output, connect_to.color) if connect_to.instance_of?(Linear::Normalizer::OutputTuples::Track) # FIXME: use existing mapping logic!
|
116
|
+
|
117
|
+
success_output_index = last_step_outputs.index(success_output)
|
101
118
|
|
102
|
-
#
|
103
|
-
searches = [Sequence::Search.ById(output, connect_to.value)] if connect_to.instance_of?(Linear::Normalizer::OutputTuples::Id)
|
104
|
-
searches = [Sequence::Search.Forward(output, connect_to.color)] if connect_to.instance_of?(Linear::Normalizer::OutputTuples::Track) # FIXME: use existing mapping logic!
|
119
|
+
output_searches[success_output_index] = success_search # replace the success search strategy. # DISCUSS: a bit cryptical with this index.
|
105
120
|
|
106
|
-
row =
|
107
|
-
row = row[0..1] + [
|
121
|
+
row = last_step_on_path
|
122
|
+
row = row[0..1] + [output_searches] + [row[3]] # FIXME: not mutating an array is so hard: we only want to replace the "searches" element, index 2
|
108
123
|
row = Sequence::Row[*row]
|
109
124
|
|
110
125
|
sequence[0..-2] + [row]
|
@@ -3,7 +3,8 @@ module Trailblazer
|
|
3
3
|
module DSL
|
4
4
|
module Linear
|
5
5
|
class Sequence
|
6
|
-
#
|
6
|
+
# Run a normalizer for a user DSL input, and then apply the new step using the ADDS interface
|
7
|
+
# to the sequence.
|
7
8
|
module Builder
|
8
9
|
# @return Sequence
|
9
10
|
def self.call(method, argument, options, **kws, &block)
|
@@ -8,51 +8,68 @@ module Trailblazer
|
|
8
8
|
module_function
|
9
9
|
|
10
10
|
# Default strategy to find out what's a stop event is to inspect the TaskRef's {data[:stop_event]}.
|
11
|
-
def find_termini(
|
12
|
-
|
13
|
-
.find_all { |
|
14
|
-
.collect { |
|
11
|
+
def find_termini(sequence)
|
12
|
+
sequence
|
13
|
+
.find_all { |_, _, _, data| data[:stop_event] }
|
14
|
+
.collect { |_, task, _, data| [task, data.fetch(:semantic)] }
|
15
15
|
.to_h
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
intermediate_wiring.first.first.id
|
18
|
+
def find_start_task(sequence)
|
19
|
+
sequence[0][1]
|
21
20
|
end
|
22
21
|
|
23
|
-
def call(sequence, find_stops: method(:find_termini), find_start: method(:
|
24
|
-
|
25
|
-
sequence.inject([[], []]) do |(implementations, intermediates), seq_row|
|
26
|
-
_magnetic_to, task, connections, data = seq_row
|
27
|
-
id = data[:id]
|
22
|
+
def call(sequence, find_stops: Compiler.method(:find_termini), find_start: method(:find_start_task))
|
23
|
+
config = Activity::Schema::Intermediate::Compiler::DEFAULT_CONFIG
|
28
24
|
|
29
|
-
|
30
|
-
connections = find_connections(seq_row, connections, sequence)
|
25
|
+
nodes_attributes = []
|
31
26
|
|
32
|
-
|
33
|
-
|
27
|
+
wiring = sequence.collect do |seq_row|
|
28
|
+
_magnetic_to, task, connections, data = seq_row
|
34
29
|
|
35
|
-
|
36
|
-
[
|
37
|
-
Schema::Intermediate::TaskRef(id, data),
|
38
|
-
# Compute outputs.
|
39
|
-
connections.collect { |output, target_id| Schema::Intermediate::Out(output.semantic, target_id) }
|
40
|
-
]
|
41
|
-
]
|
30
|
+
id = data[:id]
|
42
31
|
|
43
|
-
|
44
|
-
|
32
|
+
# execute all {Search}s for one sequence row.
|
33
|
+
connections = find_connections(seq_row, connections, sequence)
|
45
34
|
|
46
|
-
|
47
|
-
terminus_to_semantic = find_stops.(intermediate_wiring)
|
35
|
+
circuit_connections = connections.collect { |output, target_task| [output.signal, target_task] }.to_h
|
48
36
|
|
49
|
-
|
50
|
-
|
37
|
+
extensions = (seq_row[3][:extensions] || [])
|
38
|
+
# FIXME: move that to {Intermediate::Compiler}?
|
39
|
+
config = extensions.inject(config) { |cfg, ext| ext.(config: cfg, id: id, task: task) } # {ext} must return new config hash.
|
51
40
|
|
52
|
-
|
53
|
-
|
41
|
+
# nodes_attributes:
|
42
|
+
outputs = connections.keys
|
43
|
+
nodes_attributes << [
|
44
|
+
id,
|
45
|
+
task,
|
46
|
+
data,
|
47
|
+
outputs
|
48
|
+
]
|
49
|
+
|
50
|
+
[
|
51
|
+
task,
|
52
|
+
circuit_connections
|
53
|
+
]
|
54
|
+
end.to_h
|
55
|
+
|
56
|
+
termini = find_stops.(sequence) # {task => semantic}
|
57
|
+
start_task = find_start.(sequence)
|
54
58
|
|
55
|
-
|
59
|
+
circuit = Trailblazer::Activity::Circuit.new(
|
60
|
+
wiring,
|
61
|
+
termini.keys, # termini
|
62
|
+
start_task: start_task
|
63
|
+
)
|
64
|
+
|
65
|
+
# activity_outputs = [Activity::Output(steps[last_step_i], :success)]
|
66
|
+
activity_outputs = termini.collect { |terminus, semantic| Activity::Output(terminus, semantic) }
|
67
|
+
|
68
|
+
|
69
|
+
nodes = Schema::Nodes(nodes_attributes)
|
70
|
+
|
71
|
+
Schema.new(circuit, activity_outputs, nodes, config)
|
72
|
+
end
|
56
73
|
|
57
74
|
# Execute all search strategies for a row, retrieve outputs and
|
58
75
|
# their respective target IDs.
|
@@ -64,9 +81,9 @@ module Trailblazer
|
|
64
81
|
|
65
82
|
[
|
66
83
|
output,
|
67
|
-
target_seq_row
|
84
|
+
target_seq_row[1]
|
68
85
|
]
|
69
|
-
end
|
86
|
+
end.to_h
|
70
87
|
end
|
71
88
|
end # Compiler
|
72
89
|
end # Sequence
|
@@ -62,6 +62,7 @@ module Trailblazer
|
|
62
62
|
|
63
63
|
private def recompile_activity(sequence)
|
64
64
|
schema = Sequence::Compiler.(sequence)
|
65
|
+
|
65
66
|
Activity.new(schema)
|
66
67
|
end
|
67
68
|
|
@@ -112,7 +113,6 @@ module Trailblazer
|
|
112
113
|
TaskWrap.invoke(self, *args, **kws)
|
113
114
|
end
|
114
115
|
end # class << self
|
115
|
-
# FIXME: do we want class << self?!
|
116
116
|
|
117
117
|
module DSL
|
118
118
|
module_function
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Trailblazer::Activity::DSL::Linear
|
2
|
+
module Zeitwerk
|
3
|
+
module Strategy
|
4
|
+
# DISCUSS: rename to {Finalize}?
|
5
|
+
# Don't recompile, just collect sequence steps.
|
6
|
+
private def recompile_activity_for(type, *args, &block)
|
7
|
+
sequence = apply_step_on_sequence_builder(type, *args, &block)
|
8
|
+
|
9
|
+
@state.update!(:sequence) { |*| sequence }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Compile the final {Activity} via the sequence.
|
13
|
+
def finalize!
|
14
|
+
sequence = @state.get(:sequence)
|
15
|
+
# puts "~~~~~~~~~ finalizing #{self.inspect}"
|
16
|
+
recompile!(sequence)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module DSL
|
21
|
+
module Build
|
22
|
+
module_function
|
23
|
+
def Build(strategy, **options, &block)
|
24
|
+
activity_class = super
|
25
|
+
puts "yoo"
|
26
|
+
activity_class.finalize!
|
27
|
+
|
28
|
+
activity_class
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end # Zeitwerk
|
34
|
+
end
|
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
end
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "trailblazer-activity", ">= 0.
|
20
|
+
spec.add_dependency "trailblazer-activity", ">= 0.17.0", "< 0.18.0"
|
21
21
|
spec.add_dependency "trailblazer-declarative", ">= 0.0.1", "< 0.1.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "minitest"
|
24
|
+
spec.add_development_dependency "minitest"#, ">= 5.15.0", "< 5.16.0"
|
25
25
|
spec.add_development_dependency "rake"
|
26
|
-
spec.add_development_dependency "trailblazer-core-utils", "0.0.
|
26
|
+
spec.add_development_dependency "trailblazer-core-utils", "0.0.4"
|
27
27
|
|
28
28
|
spec.required_ruby_version = ">= 2.5.0"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-activity-dsl-linear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: trailblazer-activity
|
@@ -16,20 +15,20 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
18
|
+
version: 0.17.0
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
21
|
+
version: 0.18.0
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
28
|
+
version: 0.17.0
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
31
|
+
version: 0.18.0
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: trailblazer-declarative
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,20 +69,14 @@ dependencies:
|
|
70
69
|
requirements:
|
71
70
|
- - ">="
|
72
71
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
74
|
-
- - "<"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 5.16.0
|
72
|
+
version: '0'
|
77
73
|
type: :development
|
78
74
|
prerelease: false
|
79
75
|
version_requirements: !ruby/object:Gem::Requirement
|
80
76
|
requirements:
|
81
77
|
- - ">="
|
82
78
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
84
|
-
- - "<"
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 5.16.0
|
79
|
+
version: '0'
|
87
80
|
- !ruby/object:Gem::Dependency
|
88
81
|
name: rake
|
89
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,15 +97,14 @@ dependencies:
|
|
104
97
|
requirements:
|
105
98
|
- - '='
|
106
99
|
- !ruby/object:Gem::Version
|
107
|
-
version: 0.0.
|
100
|
+
version: 0.0.4
|
108
101
|
type: :development
|
109
102
|
prerelease: false
|
110
103
|
version_requirements: !ruby/object:Gem::Requirement
|
111
104
|
requirements:
|
112
105
|
- - '='
|
113
106
|
- !ruby/object:Gem::Version
|
114
|
-
version: 0.0.
|
115
|
-
description:
|
107
|
+
version: 0.0.4
|
116
108
|
email:
|
117
109
|
- apotonick@gmail.com
|
118
110
|
executables: []
|
@@ -147,6 +139,7 @@ files:
|
|
147
139
|
- lib/trailblazer/activity/dsl/linear/sequence/search.rb
|
148
140
|
- lib/trailblazer/activity/dsl/linear/strategy.rb
|
149
141
|
- lib/trailblazer/activity/dsl/linear/version.rb
|
142
|
+
- lib/trailblazer/activity/dsl/linear/zeitwerk.rb
|
150
143
|
- lib/trailblazer/activity/fast_track.rb
|
151
144
|
- lib/trailblazer/activity/path.rb
|
152
145
|
- lib/trailblazer/activity/railway.rb
|
@@ -155,7 +148,6 @@ homepage: https://trailblazer.to/2.1/docs/activity
|
|
155
148
|
licenses:
|
156
149
|
- LGPL-3.0
|
157
150
|
metadata: {}
|
158
|
-
post_install_message:
|
159
151
|
rdoc_options: []
|
160
152
|
require_paths:
|
161
153
|
- lib
|
@@ -170,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
162
|
- !ruby/object:Gem::Version
|
171
163
|
version: '0'
|
172
164
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
174
|
-
signing_key:
|
165
|
+
rubygems_version: 3.6.0.dev
|
175
166
|
specification_version: 4
|
176
167
|
summary: 'The #step DSL for Trailblazer activities.'
|
177
168
|
test_files: []
|