Skip to content

Comments

Building Workflows#121

Closed
adam-fowler wants to merge 17 commits intomainfrom
workflow-resultbuilder
Closed

Building Workflows#121
adam-fowler wants to merge 17 commits intomainfrom
workflow-resultbuilder

Conversation

@adam-fowler
Copy link
Member

This is a possible direction for building workflows.

Each workflow job is responsible for spawning its subsequent jobs. When you register a workflow job you have to indicate what the next workflow job will be. This does not make it easy to build workflows so I have added a result builder which does all the hard work for you.

let workflowName = jobQueue.registerWorkflow(name: "basic") {
    WorkflowJob(name: "convert-to-int") { (input: String, context) in
        return Int(input)!
    }
    WorkflowJob(name: "divide-by-two") { (input: Int, context) in
        return Double(input) / 2.0
    }
    WorkflowJob(name: "saveResult") { (input: Double, context) in
        jobQueue.queue.setMetadata(key: "\(context.workflowID).result", value: input)
    }
}
_ = try await jobQueue.pushWorkflow(workflowName, parameters: "25")

This does not include any branching at this point but this should be doable using the WorkflowNextJob enum, which can be expanded for more options.

@adam-fowler adam-fowler marked this pull request as draft January 26, 2026 19:40
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 86.81818% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.63%. Comparing base (0b79a4a) to head (42cba1d).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Workflows/WorkflowStep.swift 37.50% 20 Missing ⚠️
Sources/Workflows/WorkflowBuilder.swift 83.87% 5 Missing ⚠️
Sources/Workflows/WorkflowName.swift 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
- Coverage   86.81%   86.63%   -0.19%     
==========================================
  Files          25       31       +6     
  Lines        1320     1556     +236     
==========================================
+ Hits         1146     1348     +202     
- Misses        174      208      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adam-fowler adam-fowler changed the title Building Workflows with a result builder Building Workflows Feb 1, 2026
@adam-fowler
Copy link
Member Author

Moving this to a separate repo for the moment

@adam-fowler adam-fowler closed this Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant