Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker: allow steps to specify their own adaptor version #813

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-clocks-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/ws-worker': patch
---

Allow steps to specify their own adaptor version
12 changes: 10 additions & 2 deletions packages/ws-worker/src/util/convert-lightning-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,16 @@ export default (
const job = step as Job;
if (job.expression?.match(/(collections\.)/)) {
hasCollections = true;
job.adaptors ??= [];
job.adaptors.push(`@openfn/language-collections@${collectionsVersion}`);
if (
!job.adaptors?.find((v) =>
v.startsWith('@openfn/language-collections')
)
) {
job.adaptors ??= [];
job.adaptors.push(
`@openfn/language-collections@${collectionsVersion}`
);
}
}
});
return hasCollections;
Expand Down
31 changes: 30 additions & 1 deletion packages/ws-worker/test/util/convert-lightning-plan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,36 @@ test('append the collections adaptor to jobs that use it', (t) => {
t.deepEqual(b.adaptors, ['common', '@openfn/[email protected]']);
});

test('append the collections credential to jobs that use it', (t) => {
test('do not append the collections adaptor to jobs that already have it', (t) => {
const run: Partial<LightningPlan> = {
id: 'w',
jobs: [
createNode({
id: 'a',
body: 'collections.each("c", "k", (state) => state)',
adaptor: '@openfn/language-collections@latest',
}),
],
triggers: [{ id: 't', type: 'cron' }],
edges: [createEdge('t', 'a')],
};

const { plan } = convertPlan(run as LightningPlan, {
collectionsVersion: '1.0.0',
});

const [_t, a] = plan.workflow.steps;

// @ts-ignore
t.deepEqual(a.adaptors, ['@openfn/language-collections@latest']);

t.deepEqual(plan.workflow.credentials, {
collections_token: true,
collections_endpoint: true,
});
});

test('append the collections credential to workflows that use it', (t) => {
const run: Partial<LightningPlan> = {
id: 'w',
jobs: [
Expand Down
Loading