Skip to content

Commit

Permalink
[KS-135] Add workflow spec job type
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier committed Apr 16, 2024
1 parent ee9e3a3 commit 658590c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-rivers-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@smartcontractkit/operator-ui': minor
---

Add support for Workflow Spec job types
5 changes: 5 additions & 0 deletions src/screens/Job/JobView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ const JOB_PAYLOAD__SPEC = gql`
gatewayConfig
createdAt
}
... on WorkflowSpec {
workflowID
workflowOwner
workflow
}
}
`

Expand Down
30 changes: 30 additions & 0 deletions src/screens/Job/generateJobDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,36 @@ externalJobID = "00000000-0000-0000-0000-0000000000001"
[gatewayConfig.NodeServerConfig]
Port = 8_080
`
const output = generateJobDefinition(job)
expect(output.definition).toEqual(expectedOutput)
})

it('generates a valid Workflow definition', () => {
const job: JobPayload_Fields = {
id: '1',
type: 'workflow',
schemaVersion: 1,
name: 'workflow test',
externalJobID: '00000000-0000-0000-0000-0000000000001',
maxTaskDuration: '10s',
spec: {
__typename: 'WorkflowSpec',
workflowID: '<workflow id>',
workflow: '<workflow spec>',
workflowOwner: '<workflow owner>',
},
observationSource: '',
...otherJobFields,
}

const expectedOutput = `type = "workflow"
schemaVersion = 1
name = "workflow test"
externalJobID = "00000000-0000-0000-0000-0000000000001"
workflowID = "<workflow id>"
workflow = "<workflow spec>"
workflowOwner = "<workflow owner>"
`
const output = generateJobDefinition(job)
expect(output.definition).toEqual(expectedOutput)
Expand Down
13 changes: 13 additions & 0 deletions src/screens/Job/generateJobDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ export const generateJobDefinition = (
...extractSpecFields(job.spec, 'gatewayConfig'),
}

break

case 'WorkflowSpec':
values = {
...extractJobFields(job),
...extractSpecFields(
job.spec,
'workflowID',
'workflow',
'workflowOwner',
),
}

break
default:
return { definition: '' }
Expand Down

0 comments on commit 658590c

Please sign in to comment.