-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: allow each job in a workflow to use a different adaptor version
Basically instead of looking up the adaptor version from the global list of options, we calculate the version for each step and pass that through to execution
- Loading branch information
1 parent
d5a740b
commit 3cacfbe
Showing
8 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,6 +201,31 @@ test('should reset job ids for each call', (t) => { | |
t.is(second.workflow.steps['job-1'].expression, 'x'); | ||
}); | ||
|
||
test('should write adaptor versions', (t) => { | ||
const plan = { | ||
workflow: { | ||
steps: [ | ||
{ | ||
id: 'x', | ||
expression: '.', | ||
adaptor: '[email protected]', | ||
}, | ||
{ | ||
id: 'y', | ||
expression: '.', | ||
adaptor: '[email protected]', | ||
}, | ||
], | ||
}, | ||
options: {}, | ||
}; | ||
|
||
const { workflow } = compilePlan(plan); | ||
const { x, y } = workflow.steps; | ||
t.deepEqual(x.linker, { x: { version: '1.0' } }); | ||
t.deepEqual(y.linker, { y: { version: '1.0' } }); | ||
}); | ||
|
||
test('should set the start to steps[0]', (t) => { | ||
const plan: ExecutionPlan = { | ||
workflow: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -598,6 +598,106 @@ test('run from an adaptor', async (t) => { | |
t.deepEqual(result, { data: 22 }); | ||
}); | ||
|
||
test('run a workflow using the repo and load the default version', async (t) => { | ||
const expression = ` | ||
import result from 'ultimate-answer'; | ||
export default [() => result]; | ||
`; | ||
const plan = { | ||
workflow: { | ||
steps: [ | ||
{ | ||
id: 'a', | ||
expression, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const result: any = await run( | ||
plan, | ||
{}, | ||
{ | ||
linker: { | ||
repo: path.resolve('test/__repo__'), | ||
}, | ||
} | ||
); | ||
|
||
t.deepEqual(result, 43); | ||
}); | ||
|
||
test('run a workflow using the repo using a specific version', async (t) => { | ||
const expression = ` | ||
import result from 'ultimate-answer'; | ||
export default [() => result]; | ||
`; | ||
const plan = { | ||
workflow: { | ||
steps: [ | ||
{ | ||
id: 'a', | ||
expression, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const result: any = await run( | ||
plan, | ||
{}, | ||
{ | ||
linker: { | ||
repo: path.resolve('test/__repo__'), | ||
modules: { | ||
'ultimate-answer': { version: '1.0.0' }, | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
t.deepEqual(result, 42); | ||
}); | ||
|
||
test('run a workflow using the repo with multiple versions of the same adaptor', async (t) => { | ||
const plan = { | ||
workflow: { | ||
steps: [ | ||
{ | ||
id: 'a', | ||
expression: `import result from 'ultimate-answer'; | ||
export default [(s) => { s.data.a = result; return s;}];`, | ||
adaptor: '[email protected]', | ||
next: { b: true }, | ||
}, | ||
{ | ||
id: 'b', | ||
expression: `import result from 'ultimate-answer'; | ||
export default [(s) => { s.data.b = result; return s;}];`, | ||
adaptor: '[email protected]', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const result: any = await run( | ||
plan, | ||
{}, | ||
{ | ||
linker: { | ||
repo: path.resolve('test/__repo__'), | ||
}, | ||
} | ||
); | ||
|
||
t.deepEqual(result, { | ||
data: { | ||
a: 42, | ||
b: 43, | ||
}, | ||
}); | ||
}); | ||
|
||
// https://github.com/OpenFn/kit/issues/520 | ||
test('run from an adaptor with error', async (t) => { | ||
const expression = ` | ||
|