A platform for community discussion. Free, open, simple.
DEV: Reduce repetition with shorthand workflow hashes (#43727)
Régis Hanola8b749f029c2
diff --git a/plugins/discourse-workflows/app/models/discourse_workflows/execution.rb b/plugins/discourse-workflows/app/models/discourse_workflows/execution.rbindex 35470c57e1f..0f5d9d89ffd 100644--- a/plugins/discourse-workflows/app/models/discourse_workflows/execution.rb+++ b/plugins/discourse-workflows/app/models/discourse_workflows/execution.rb@@ -22,7 +22,7 @@ module DiscourseWorkflowsafter_create { ExecutionStat.log(workflow_id) unless rate_limited? }- scope :for_workflow, ->(workflow_id) { workflow_id ? where(workflow_id: workflow_id) : all }+ scope :for_workflow, ->(workflow_id) { workflow_id ? where(workflow_id:) : all }scope :recent, ->(period = 7.days) { where("created_at >= ?", period.ago) }scope :successful, -> { where(status: :success) }scope :with_duration,@@ -41,15 +41,15 @@ module DiscourseWorkflowsdef self.create_pending_manual!(workflow:, trigger_node_id:, trigger_data:)transaction docreate!(- workflow: workflow,+ workflow:,workflow_version_id: workflow.version_id,- trigger_node_id: trigger_node_id,- trigger_data: trigger_data,+ trigger_node_id:,+ trigger_data:,status: :pending,execution_mode: :manual,).tap do |execution|ExecutionData.create!(- execution: execution,+ execution:,workflow_data: WorkflowSnapshot.from_workflow(workflow, published: false).to_h,)end@@ -61,15 +61,15 @@ module DiscourseWorkflowsdef self.create_pending_step!(workflow:, node_id:, trigger_data: {}, run_data: {})transaction docreate!(- workflow: workflow,+ workflow:,workflow_version_id: workflow.version_id,trigger_node_id: node_id,- trigger_data: trigger_data,+ trigger_data:,status: :pending,execution_mode: :manual,).tap do |execution|ExecutionData.create!(- execution: execution,+ execution:,workflow_data: WorkflowSnapshot.from_workflow(workflow, published: false).to_h,data: {"entries" => {@@ -109,7 +109,7 @@ module DiscourseWorkflowsenddef self.claim_for_resume(execution, resume_token: execution.resume_token)- scope = where(id: execution.id, status: :waiting, resume_token: resume_token)+ scope = where(id: execution.id, status: :waiting, resume_token:)now = Time.currentaffected = scope.update_all(status: statuses[:running], updated_at: now)@@ -168,18 +168,12 @@ module DiscourseWorkflowsaffected =self.class- .where(- id: id,- status: :waiting,- resume_token: resume_token,- waiting_until: waiting_until,- timeout_action: timeout_action,- )+ .where(id:, status: :waiting, resume_token:, waiting_until:, timeout_action:).update_all(status: self.class.statuses[:error],error: message,finished_at: Time.current,- run_time_ms: run_time_ms,+ run_time_ms:,waiting_node_id: nil,waiting_until: nil,resume_token: nil,diff --git a/plugins/discourse-workflows/app/services/discourse_workflows/webhook/receive.rb b/plugins/discourse-workflows/app/services/discourse_workflows/webhook/receive.rbindex f1e90e08f66..631792b3f3c 100644--- a/plugins/discourse-workflows/app/services/discourse_workflows/webhook/receive.rb+++ b/plugins/discourse-workflows/app/services/discourse_workflows/webhook/receive.rb@@ -28,7 +28,7 @@ module DiscourseWorkflowsdef webhook_urlif execution_id.present?DiscourseWorkflows::WaitingExecution.webhook_url_with_signature(- execution_id: execution_id,+ execution_id:,signature: token,suffix: webhook_suffix,)@@ -43,15 +43,15 @@ module DiscourseWorkflowsdef webhook_requestDiscourseWorkflows::WebhookRequest.new(method: http_method,- path: path,- headers: headers,+ path:,+ headers:,params: path_params,query: query_params,- body: body,- raw_body: raw_body,+ body:,+ raw_body:,ip: remote_ip,- ips: ips,- webhook_url: webhook_url,+ ips:,+ webhook_url:,)endend@@ -160,7 +160,7 @@ module DiscourseWorkflowsreturn [] unless workflowreturn [] unless trigger_node- [PublishedTrigger.new(workflow: workflow, workflow_version: nil, trigger_node: trigger_node)]+ [PublishedTrigger.new(workflow:, workflow_version: nil, trigger_node:)]enddef fetch_waiting_node(waiting_execution:)@@ -201,15 +201,15 @@ module DiscourseWorkflowsDiscourseWorkflows::WaitingExecution.resume_claimed(claimed_execution,webhook_context.resume_items,- webhook_context: webhook_context,+ webhook_context:,){- execution: execution,+ execution:,response_mode: parameters["response_mode"],response_code: parameters["response_code"],response_data: parameters["response_data"],response_parameters: parameters,- webhook_context: webhook_context,+ webhook_context:,}end@@ -240,11 +240,7 @@ module DiscourseWorkflowsnode = workflow_version.nodes.find { |candidate| candidate["name"] == webhook.node_name }return nil unless node- PublishedTrigger.new(- workflow: workflow,- workflow_version: workflow_version,- trigger_node: node,- )+ PublishedTrigger.new(workflow:, workflow_version:, trigger_node: node)enddef filter_authenticated_nodes(webhook_nodes:, params:)@@ -256,8 +252,8 @@ module DiscourseWorkflowsresult =Webhook::Action::AuthenticateNode.call(node: published_trigger.trigger_node,- params: params,- credentials: credentials,+ params:,+ credentials:,)if result == Webhook::Action::AuthenticateNode::AUTHENTICATED@@ -332,15 +328,15 @@ module DiscourseWorkflowsDiscourseWorkflows::TriggerDispatcher.execute(published_trigger,trigger_data: webhook_context.request.item_json,- webhook_context: webhook_context,+ webhook_context:,)first ||= {- execution: execution,- response_mode: response_mode,+ execution:,+ response_mode:,response_code: parameters["response_code"],response_data: parameters["response_data"],response_parameters: parameters,- webhook_context: webhook_context,+ webhook_context:,}endfirst@@ -360,7 +356,7 @@ module DiscourseWorkflowsexecution_mode: :manual,draft_execution: true,workflow_snapshot: claimed_webhook_test_listener.workflow_snapshot,- webhook_context: webhook_context,+ webhook_context:,)execution =Executor.new(@@ -371,12 +367,12 @@ module DiscourseWorkflows).run{- execution: execution,+ execution:,response_mode: node_response_mode(node),response_code: parameters["response_code"],response_data: parameters["response_data"],response_parameters: parameters,- webhook_context: webhook_context,+ webhook_context:,}enddiff --git a/plugins/discourse-workflows/app/services/discourse_workflows/workflow/execute.rb b/plugins/discourse-workflows/app/services/discourse_workflows/workflow/execute.rbindex c8b95261a08..dca004b7ff2 100644--- a/plugins/discourse-workflows/app/services/discourse_workflows/workflow/execute.rb+++ b/plugins/discourse-workflows/app/services/discourse_workflows/workflow/execute.rb@@ -61,9 +61,9 @@ module DiscourseWorkflowsdef run_workflow(trigger_node:, workflow:, workflow_version:, params:, user:)options =Executor::ExecutionOptions.new(- user: user,+ user:,execution_mode: params.execution_mode.to_sym,- workflow_version: workflow_version,+ workflow_version:,job_id: params.job_id,)Executor.new(workflow, trigger_node["id"], params.trigger_data, options).rundiff --git a/plugins/discourse-workflows/lib/discourse_workflows/executor.rb b/plugins/discourse-workflows/lib/discourse_workflows/executor.rbindex cc0b7c77c3e..672132a3b23 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/executor.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/executor.rb@@ -45,7 +45,7 @@ module DiscourseWorkflowsworkflow: @workflow,trigger_data: @trigger_data,user: @options.user,- workflow_nodes: workflow_nodes,+ workflow_nodes:,workflow_name: workflow_version&.name,workflow_call_caller: @options.workflow_call_caller,)@@ -66,27 +66,27 @@ module DiscourseWorkflowsenddef self.resume(execution, response_items, user: nil, webhook_context: nil)- build_resume_executor(execution, user: user, webhook_context: webhook_context).resume_from(+ build_resume_executor(execution, user:, webhook_context:).resume_from(execution,response_items,)enddef self.resume_with_error(execution, error, user: nil)- build_resume_executor(execution, user: user).resume_from_error(execution, error)+ build_resume_executor(execution, user:).resume_from_error(execution, error)enddef self.build_resume_executor(execution, user:, webhook_context: nil)workflow_call_caller = WorkflowCallContinuation.caller_metadata_for(execution)options =ExecutionOptions.new(- user: user,+ user:,execution_mode: execution.execution_mode.to_sym,workflow_snapshot: build_resume_snapshot!(execution),- webhook_context: webhook_context,+ webhook_context:,workflow_call_stack: WorkflowCallContinuation.workflow_call_stack_for(execution),workflow_call_child: workflow_call_caller.present?,- workflow_call_caller: workflow_call_caller,+ workflow_call_caller:,)new(execution.workflow, execution.trigger_node_id, execution.trigger_data, options)end@@ -164,7 +164,7 @@ module DiscourseWorkflowsstep&.add_metadata("handled_error", error_metadata(error))step&.succeed!(output: all_items)step&.apply_updates!("error" => nil)- @store.publish_progress(step: step) if step+ @store.publish_progress(step:) if step@context.store_node_output(waiting_node, all_items)@context.store_node_run(waiting_node,@@ -176,7 +176,7 @@ module DiscourseWorkflowsroute_downstream(waiting_node, handled_outputs)elsestep&.fail!(error.message)- @store.publish_progress(step: step) if step+ @store.publish_progress(step:) if stepraise errorendend@@ -214,7 +214,7 @@ module DiscourseWorkflowsstep = record_step(node, [])step.succeed!(output: output_groups.flatten(1))step.add_metadata("cached", true)- @store.publish_progress(step: step)+ @store.publish_progress(step:)route_downstream(node, output_groups)end@@ -436,7 +436,7 @@ module DiscourseWorkflowsjs_elapsed = (sandbox_budget_tracker.current_elapsed_ms - js_elapsed_before).round(1)step.add_metadata("js_elapsed_ms", js_elapsed) if js_elapsed > 0runtime_state.step_metadata.each { |key, value| step.add_metadata(key, value) }- @store.publish_progress(step: step)+ @store.publish_progress(step:)endend@@ -460,7 +460,7 @@ module DiscourseWorkflowsstep.add_metadata(DiscourseWorkflows::FormCompletion::METADATA_KEY,- DiscourseWorkflows::FormCompletion.for_node(node, resolver: resolver),+ DiscourseWorkflows::FormCompletion.for_node(node, resolver:),)end@@ -479,8 +479,8 @@ module DiscourseWorkflows"in workflow #{@context.workflow.id}, passing through node '#{node.name}'",)step = record_step(node, input_items)- step.skip!(output: input_items, reason: reason)- @store.publish_progress(step: step)+ step.skip!(output: input_items, reason:)+ @store.publish_progress(step:)@context.store_node_output(node, input_items)@context.store_node_run(node, inputs: [input_items], outputs: [input_items])enqueue_downstream(node, 0, input_items)@@ -489,8 +489,8 @@ module DiscourseWorkflowsdef handle_node_issues(node, input_items, issues)reason = issues.map { |i| "#{i[:path]}: #{i[:message]}" }.join(", ")step = record_step(node, input_items)- step.skip!(output: input_items, reason: reason)- @store.publish_progress(step: step)+ step.skip!(output: input_items, reason:)+ @store.publish_progress(step:)@context.store_node_output(node, input_items)@context.store_node_run(node, inputs: [input_items], outputs: [input_items])enqueue_downstream(node, 0, input_items)@@ -500,7 +500,7 @@ module DiscourseWorkflowsstep = record_step(node, input_items)step.succeed!(output: pinned_items)step.add_metadata("pinned", true)- @store.publish_progress(step: step)+ @store.publish_progress(step:)@context.store_node_output(node, pinned_items)@context.store_node_run(node,@@ -557,16 +557,16 @@ module DiscourseWorkflows)NodeExecutionContext.new(input_items: primary_input_items(input_groups),- input_groups: input_groups,+ input_groups:,parameters: node.parameters,credentials: node.credentials,node_settings: DiscourseWorkflows::NodeData.direct_settings(node),webhook_id: node.webhook_id,property_schema: node_type_class.property_schema,credential_schema: node_type_class.credentials,- node_context: node_context,+ node_context:,user: @options.user,- resolver: resolver,+ resolver:,vars: preloaded_vars,workflow: @workflow,workflow_version: @options.workflow_version,@@ -582,17 +582,17 @@ module DiscourseWorkflowsworkflow_snapshot: @snapshot,webhook_context: @options.webhook_context,workflow_call_stack: @workflow_call_stack,- runtime_state: runtime_state,+ runtime_state:,static_data_state: @context.static_data_state,)enddef normalize_result(result, node, ports, input_groups)source = "#{node.name} (#{node.type})"- ItemContract.validate_output_arrays!(result, source: source, ports: ports)+ ItemContract.validate_output_arrays!(result, source:, ports:)apply_item_linking_defaults!(result, input_groups:)- ItemContract.validate_output_arrays!(result, source: source, ports: ports)+ ItemContract.validate_output_arrays!(result, source:, ports:)resultend@@ -857,20 +857,14 @@ module DiscourseWorkflowsif explicit_required_inputs.is_a?(Integer){- connected_inputs: connected_inputs,+ connected_inputs:,inputs_to_wait_for: [],minimum_input_count: explicit_required_inputs,}elsif explicit_required_inputs.present?- {- connected_inputs: connected_inputs,- inputs_to_wait_for: Array(explicit_required_inputs).map(&:to_i),- }+ { connected_inputs:, inputs_to_wait_for: Array(explicit_required_inputs).map(&:to_i) }else- {- connected_inputs: connected_inputs,- inputs_to_wait_for: (required_inputs + connected_inputs).uniq,- }+ { connected_inputs:, inputs_to_wait_for: (required_inputs + connected_inputs).uniq }endendend@@ -900,17 +894,9 @@ module DiscourseWorkflowsenddef record_step(node, input_items, output: [], status: Step::RUNNING, error: nil)- step =- Step.build(- node: node,- position: @steps.size,- input: input_items,- output: output,- status: status,- error: error,- )+ step = Step.build(node:, position: @steps.size, input: input_items, output:, status:, error:)@steps << step- @store.publish_progress(step: step)+ @store.publish_progress(step:)stepend@@ -928,7 +914,7 @@ module DiscourseWorkflows"output" => response_items,"finished_at" => Time.current.iso8601,)- @store.publish_progress(step: step)+ @store.publish_progress(step:)enddef begin_wait!(wait_request)@@ -959,7 +945,7 @@ module DiscourseWorkflows@store.pause_waiting_execution!(node: @waiting_node,waiting_until: resolved,- timeout_action: timeout_action,+ timeout_action:,steps: @steps,)@@ -976,7 +962,7 @@ module DiscourseWorkflowsexecution = @store.pause_waiting_execution!(node: @waiting_node, steps: @steps)DiscourseWorkflows::WorkflowCallContinuation.begin_child_call!(- execution: execution,+ execution:,node: @waiting_node,request: wait_request,)@@ -1141,11 +1127,7 @@ module DiscourseWorkflowsdef node_dependencies(node)parameters = NodeData.parameters(node)credentials =- NodeData.split(- parameters: parameters,- credentials: NodeData.credentials(node),- node_type: node.type,- )[+ NodeData.split(parameters:, credentials: NodeData.credentials(node), node_type: node.type)["credentials"]dependencies = []diff --git a/plugins/discourse-workflows/lib/discourse_workflows/executor/execution_store.rb b/plugins/discourse-workflows/lib/discourse_workflows/executor/execution_store.rbindex 84814a3ae27..00e713da917 100644--- a/plugins/discourse-workflows/lib/discourse_workflows/executor/execution_store.rb+++ b/plugins/discourse-workflows/lib/discourse_workflows/executor/execution_store.rb@@ -37,7 +37,7 @@ module DiscourseWorkflows@workflow_snapshot.to_h["nodes"],workflow_name: @workflow_snapshot.workflow_name,)- persist_execution!(status: :running, trigger_data: trigger_data)+ persist_execution!(status: :running, trigger_data:)return false if @duplicate_jobreset_collaborators!@@ -95,7 +95,7 @@ module DiscourseWorkflowswaiting_until: nil,timeout_action: nil,)- execution.trigger_error_workflow(error, steps: steps)+ execution.trigger_error_workflow(error, steps:)publish_execution_run_data(force: @options.draft_execution || @options.workflow_snapshot.present?,)@@ -107,7 +107,7 @@ module DiscourseWorkflowsenddef create_execution_with_status(status, trigger_data: self.trigger_data)- persist_execution!(status: status, trigger_data: trigger_data, finished_at: Time.current)+ persist_execution!(status:, trigger_data:, finished_at: Time.current)enddef create_rate_limited_execution@@ -119,9 +119,9 @@ module DiscourseWorkflowsexecution.update!(status: :waiting,waiting_node_id: node.id,- waiting_until: waiting_until,+ waiting_until:,resume_token: @execution_context.resume_token,- timeout_action: timeout_action,+ timeout_action:,)save!(steps)end@@ -142,7 +142,7 @@ module DiscourseWorkflowsenddef publish_progress(step: nil, refresh: false)- ExecutionProgressPublisher.publish(execution, step: step, refresh: refresh)+ ExecutionProgressPublisher.publish(execution, step:, refresh:)endprivate@@ -155,11 +155,11 @@ module DiscourseWorkflowsworkflow_id: workflow.id,workflow_version_id: execution_workflow_version_id,trigger_node_id: @trigger_node_id,- status: status,- trigger_data: trigger_data,+ status:,+ trigger_data:,execution_mode: @execution_mode,started_at: @execution.started_at || Time.current,- finished_at: finished_at,+ finished_at:,}if @options.job_id.present?diff --git a/plugins/discourse-workflows/spec/integration/execution_lifecycle_spec.rb b/plugins/discourse-workflows/spec/integration/execution_lifecycle_spec.rbindex aaeea3529e3..a7f0b54a59f 100644--- a/plugins/discourse-workflows/spec/integration/execution_lifecycle_spec.rb+++ b/plugins/discourse-workflows/spec/integration/execution_lifecycle_spec.rb@@ -46,7 +46,7 @@ RSpec.describe "Workflow execution lifecycle" dostub_request(:get, checkpoint_url).to_raise(Sidekiq::Shutdown).then.to_return(http_success)execution =DiscourseWorkflows::Execution.create_pending_manual!(- workflow: workflow,+ workflow:,trigger_node_id: "trigger-1",trigger_data: {},diff --git a/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_waiting_execution_spec.rb b/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_waiting_execution_spec.rbindex 8019dfde81e..9e80b71afc7 100644--- a/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_waiting_execution_spec.rb+++ b/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_waiting_execution_spec.rb@@ -9,7 +9,7 @@ RSpec.describe Jobs::DiscourseWorkflows::ResumeWaitingExecution dofab!(:execution) doFabricate(:discourse_workflows_execution,- workflow: workflow,+ workflow:,status: :waiting,waiting_until: 1.minute.ago,resume_token: "wait-token",diff --git a/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_webhook_waiting_spec.rb b/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_webhook_waiting_spec.rbindex 282b1ad1604..7646fdd8004 100644--- a/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_webhook_waiting_spec.rb+++ b/plugins/discourse-workflows/spec/jobs/regular/discourse_workflows/resume_webhook_waiting_spec.rb@@ -9,7 +9,7 @@ RSpec.describe Jobs::DiscourseWorkflows::ResumeWebhookWaiting dofab!(:execution) doFabricate(:discourse_workflows_execution,- workflow: workflow,+ workflow:,status: :waiting,resume_token: "wait-token",)diff --git a/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/execution_store_spec.rb b/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/execution_store_spec.rbindex d088fab78cc..4d33ec0725d 100644--- a/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/execution_store_spec.rb+++ b/plugins/discourse-workflows/spec/lib/discourse_workflows/executor/execution_store_spec.rb@@ -5,19 +5,15 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore dolet(:trigger_data) { { "topic_id" => 1 } }let(:execution_context) do- DiscourseWorkflows::Executor::ExecutionContext.new(- workflow: workflow,- trigger_data: trigger_data,- user: nil,- )+ DiscourseWorkflows::Executor::ExecutionContext.new(workflow:, trigger_data:, user: nil)endlet(:options) { DiscourseWorkflows::Executor::ExecutionOptions.new }let(:store) dodescribed_class.new(trigger_node_id: "node_1",- execution_context: execution_context,+ execution_context:,execution_mode: :normal,- options: options,+ options:,)end@@ -44,7 +40,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore domessages =MessageBus.track_publish("/discourse-workflows/execution/#{execution.id}") do- store.publish_progress(step: step)+ store.publish_progress(step:)endexpect(messages.length).to eq(1)@@ -92,7 +88,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do),]- store.finish!(steps: steps)+ store.finish!(steps:)parsed = store.execution.execution_data.dataexpect(parsed["context"]["node_a"]).to eq([{ "json" => { "x" => 1 } }])@@ -111,7 +107,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do)steps = [DiscourseWorkflows::Executor::Step.build(- node: node,+ node:,position: 0,input: input_groups.first,status: DiscourseWorkflows::Executor::Step::SUCCESS,@@ -121,7 +117,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore domessages =MessageBus.track_publish("/discourse-workflows/workflow/#{workflow.id}") do- store.finish!(steps: steps)+ store.finish!(steps:)endexpect(messages.length).to eq(1)@@ -160,7 +156,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do),]- store.finish!(steps: steps)+ store.finish!(steps:)entry = store.execution.execution_data.data.dig("entries", "1", 0)expect(entry.dig("input", 0, "json", "body")).to include(@@ -192,7 +188,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do),]- store.finish!(steps: steps)+ store.finish!(steps:)entry = store.execution.execution_data.data.dig("entries", "1", 0)expect(entry["input"]).to include(@@ -230,7 +226,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do)end- store.finish!(steps: steps)+ store.finish!(steps:)data = store.execution.execution_data.dataentry = data.dig("entries", "node-0", 0)@@ -257,11 +253,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore doit "persists the requested timeout action" dowaiting_until = 15.minutes.from_now- store.pause_waiting_execution!(- node: node,- waiting_until: waiting_until,- timeout_action: "fail",- )+ store.pause_waiting_execution!(node:, waiting_until:, timeout_action: "fail")expect(store.execution.reload).to have_attributes(status: "waiting",@@ -272,7 +264,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore doendit "keeps timeout action nil when existing callers omit it" do- store.pause_waiting_execution!(node: node)+ store.pause_waiting_execution!(node:)expect(store.execution.reload.timeout_action).to be_nilend@@ -282,7 +274,7 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore dointerrupt_checkpoint = -> { raise Sidekiq::Shutdown }DiscourseWorkflows::ExecutionData.set_callback(:save, :before, interrupt_checkpoint)- expect { store.pause_waiting_execution!(node: node) }.to raise_error(Sidekiq::Shutdown)+ expect { store.pause_waiting_execution!(node:) }.to raise_error(Sidekiq::Shutdown)expect(store.execution.reload).to have_attributes(status: "running", waiting_node_id: nil)expect(store.execution.execution_data).to be_nil@@ -376,31 +368,27 @@ RSpec.describe DiscourseWorkflows::Executor::ExecutionStore do)steps = [DiscourseWorkflows::Executor::Step.build(- node: node,+ node:,position: 0,input: [],status: DiscourseWorkflows::Executor::Step::WAITING,output: output_groups.first,),]- store.finish!(steps: steps)+ store.finish!(steps:)existing_data = store.execution.execution_data.data.deep_dupexisting_data["node_contexts"] = { "node_a" => { "counter" => 1 } }store.execution.execution_data.update!(data: existing_data)store.execution.update!(status: :waiting, waiting_node_id: "1")restored_context =- DiscourseWorkflows::Executor::ExecutionContext.new(- workflow: workflow,- trigger_data: trigger_data,- user: nil,- )+ DiscourseWorkflows::Executor::ExecutionContext.new(workflow:, trigger_data:, user: nil)restored =described_class.new(trigger_node_id: "node_1",execution_context: restored_context,execution_mode: :normal,- options: options,+ options:,)restored.resume!(store.execution)diff --git a/plugins/discourse-workflows/spec/models/discourse_workflows/execution_spec.rb b/plugins/discourse-workflows/spec/models/discourse_workflows/execution_spec.rbindex 2efd862af69..3a766f50f72 100644--- a/plugins/discourse-workflows/spec/models/discourse_workflows/execution_spec.rb+++ b/plugins/discourse-workflows/spec/models/discourse_workflows/execution_spec.rb@@ -6,7 +6,7 @@ RSpec.describe DiscourseWorkflows::Execution dofab!(:execution) doFabricate(:discourse_workflows_execution,- workflow: workflow,+ workflow:,status: :waiting,resume_token: "tok-abc",)@@ -36,9 +36,7 @@ RSpec.describe DiscourseWorkflows::Execution dodescribe ".claim_pending" dofab!(:workflow, :discourse_workflows_workflow)- fab!(:execution) do- Fabricate(:discourse_workflows_execution, workflow: workflow, status: :pending)- end+ fab!(:execution) { Fabricate(:discourse_workflows_execution, workflow:, status: :pending) }it "starts a pending execution once" doclaimed = described_class.claim_pending(execution)@@ -56,7 +54,7 @@ RSpec.describe DiscourseWorkflows::Execution dofab!(:execution) doFabricate(:discourse_workflows_execution,- workflow: workflow,+ workflow:,status: :waiting,waiting_node_id: "node-1",waiting_until: 1.minute.ago,@@ -134,11 +132,11 @@ RSpec.describe DiscourseWorkflows::Execution dodef build_step(node_type: "action:code", started_at: nil, finished_at: nil)node = Struct.new(:id, :name, :type).new(SecureRandom.uuid, "Node", node_type)DiscourseWorkflows::Executor::Step.build(- node: node,+ node:,position: 0,input: [],- started_at: started_at,- finished_at: finished_at,+ started_at:,+ finished_at:,)end@@ -203,9 +201,9 @@ RSpec.describe DiscourseWorkflows::Execution dobefore { SiteSetting.workflow_executions_retention_days = 30 }def fabricate_at(status, created_at)- execution = Fabricate(:discourse_workflows_execution, workflow: workflow, status: status)- Fabricate(:discourse_workflows_execution_data, execution: execution)- described_class.where(id: execution.id).update_all(created_at: created_at)+ execution = Fabricate(:discourse_workflows_execution, workflow:, status:)+ Fabricate(:discourse_workflows_execution_data, execution:)+ described_class.where(id: execution.id).update_all(created_at:)executionend@@ -257,7 +255,7 @@ RSpec.describe DiscourseWorkflows::Execution dodescribed_class.purge_old- expect(described_class.where(workflow: workflow, status: :success)).to be_empty+ expect(described_class.where(workflow:, status: :success)).to be_emptyendendenddiff --git a/plugins/discourse-workflows/spec/services/discourse_workflows/webhook/receive_spec.rb b/plugins/discourse-workflows/spec/services/discourse_workflows/webhook/receive_spec.rbindex 98d01e73336..e4bf45247e2 100644--- a/plugins/discourse-workflows/spec/services/discourse_workflows/webhook/receive_spec.rb+++ b/plugins/discourse-workflows/spec/services/discourse_workflows/webhook/receive_spec.rb@@ -76,7 +76,7 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive dolet(:signature) doDiscourseWorkflows::WaitingExecution.resume_signature(execution_id: waiting_execution.id,- resume_token: resume_token,+ resume_token:,)end@@ -84,7 +84,7 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive do{execution_id: waiting_execution.id,token: signature,- webhook_suffix: webhook_suffix,+ webhook_suffix:,http_method: "POST",body: {"foo" => "bar",@@ -120,7 +120,7 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive do"webhook_url" =>DiscourseWorkflows::WaitingExecution.webhook_url(execution_id: waiting_execution.id,- resume_token: resume_token,+ resume_token:,),)end@@ -152,8 +152,8 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive doexpect(result).to run_successfullyexpect(result[:sync_result]).to include(execution: waiting_execution,- response_mode: response_mode,- response_code: response_code,+ response_mode:,+ response_code:,)expect(waiting_execution.reload).to be_successend@@ -329,10 +329,7 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive doit "returns a synchronous result without enqueuing a job" doexpect(result).to run_successfullyexpect(Jobs::DiscourseWorkflows::ExecuteWorkflow.jobs).to be_empty- expect(result[:sync_result]).to include(- response_mode: "last_node",- response_code: response_code,- )+ expect(result[:sync_result]).to include(response_mode: "last_node", response_code:)expect(result[:sync_result][:execution]).to have_attributes(workflow_id: workflow.id,status: "success",@@ -343,10 +340,10 @@ RSpec.describe DiscourseWorkflows::Webhook::Receive docontext "when triggering a test webhook" dolet(:test_listener_id) { nil }- let(:params) { super().merge(test_webhook: true, test_listener_id: test_listener_id) }+ let(:params) { super().merge(test_webhook: true, test_listener_id:) }let(:listener) doDiscourseWorkflows::WebhookTestListener.create!(- workflow: workflow,+ workflow:,user: admin,trigger_node: workflow.find_node("webhook-1"),)