Skip to content

Commit 6b4a5fa

Browse files
Merge pull request #613 from OpenFn/release/next
Next Release
2 parents d5a740b + 8c94a9d commit 6b4a5fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+851
-360
lines changed

integration-tests/worker/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @openfn/integration-tests-worker
22

3+
## 1.0.36
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [4f5f1dd]
8+
- Updated dependencies [58e0d11]
9+
- Updated dependencies [58e0d11]
10+
- @openfn/engine-multi@1.1.0
11+
- @openfn/ws-worker@1.0.1
12+
- @openfn/lightning-mock@2.0.1
13+
314
## 1.0.35
415

516
### Patch Changes

integration-tests/worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@openfn/integration-tests-worker",
33
"private": true,
4-
"version": "1.0.35",
4+
"version": "1.0.36",
55
"description": "Lightning WOrker integration tests",
66
"author": "Open Function Group <[email protected]>",
77
"license": "ISC",

integration-tests/worker/test/runs.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const humanMb = (sizeInBytes: number) => Math.round(sizeInBytes / 1024 / 1024);
4444
const run = async (t, attempt) => {
4545
return new Promise<any>(async (done, reject) => {
4646
lightning.on('step:complete', ({ payload }) => {
47+
t.is(payload.reason, 'success');
48+
4749
// TODO friendlier job names for this would be nice (rather than run ids)
4850
t.log(
4951
`run ${payload.step_id} done in ${payload.duration / 1000}s [${humanMb(
@@ -192,7 +194,7 @@ test.serial('run parallel jobs', async (t) => {
192194
// });
193195
});
194196

195-
test('run a http adaptor job', async (t) => {
197+
test.serial('run a http adaptor job', async (t) => {
196198
const job = createJob({
197199
adaptor: '@openfn/[email protected]',
198200
body: `get("https://jsonplaceholder.typicode.com/todos/1");
@@ -212,3 +214,37 @@ test('run a http adaptor job', async (t) => {
212214
completed: false,
213215
});
214216
});
217+
218+
test.serial('use different versions of the same adaptor', async (t) => {
219+
// http@5 exported an axios global - so run this job and validate that the global is there
220+
const job1 = createJob({
221+
body: `import { axios } from "@openfn/language-http";
222+
fn((s) => {
223+
if (!axios) {
224+
throw new Error('AXIOS NOT FOUND')
225+
}
226+
return s;
227+
})`,
228+
adaptor: '@openfn/[email protected]',
229+
});
230+
231+
// http@6 no longer exports axios - so throw an error if we see it
232+
const job2 = createJob({
233+
body: `import { axios } from "@openfn/language-http";
234+
fn((s) => {
235+
if (axios) {
236+
throw new Error('AXIOS FOUND')
237+
}
238+
return s;
239+
})`,
240+
adaptor: '@openfn/[email protected]',
241+
});
242+
243+
// Just for fun, run each job a couple of times to make sure that there's no wierd caching or ordering anything
244+
const steps = [job1, job2, job1, job2];
245+
const attempt = createRun([], steps, []);
246+
247+
const result = await run(t, attempt);
248+
t.log(result);
249+
t.falsy(result.errors);
250+
});

packages/cli/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @openfn/cli
22

3+
## 1.1.0
4+
5+
### Patch Changes
6+
7+
Allow multiple version of the same adaptor to run in the same workflow
8+
9+
- Updated dependencies [4f5f1dd]
10+
- @openfn/runtime@1.1.0
11+
312
## 1.0.0
413

514
### Major Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openfn/cli",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "CLI devtools for the openfn toolchain.",
55
"engines": {
66
"node": ">=18",

packages/engine-multi/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# engine-multi
22

3+
## 1.1.0
4+
5+
### Minor Changes
6+
7+
- 4f5f1dd: Support workflows with different versions of the same adaptor
8+
9+
### Patch Changes
10+
11+
- 58e0d11: Record adaptor versions as an array
12+
- Updated dependencies [4f5f1dd]
13+
- @openfn/runtime@1.1.0
14+
315
## 1.0.0
416

517
### Major Changes

packages/engine-multi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openfn/engine-multi",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Multi-process runtime engine",
55
"main": "dist/index.js",
66
"type": "module",

packages/engine-multi/src/api/autoinstall.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ const autoinstall = async (context: ExecutionContext): Promise<ModulePaths> => {
112112
}
113113

114114
if (!skipRepoValidation && !didValidateRepo) {
115-
// TODO what if this throws?
116-
// Whole server probably needs to crash, so throwing is probably appropriate
117115
// TODO do we need to do it on EVERY call? Can we not cache it?
118116
await ensureRepo(repoDir, logger);
119117
didValidateRepo = true;
@@ -137,12 +135,15 @@ const autoinstall = async (context: ExecutionContext): Promise<ModulePaths> => {
137135

138136
const v = version || 'unknown';
139137

140-
// Write the adaptor version to the context
141-
// This is a reasonably accurate, but not totally bulletproof, report
142-
// @ts-ignore
143-
context.versions[name] = v;
138+
// Write the adaptor version to the context for reporting later
139+
if (!context.versions[name]) {
140+
context.versions[name] = [];
141+
}
142+
if (!context.versions[name].includes(v)) {
143+
(context.versions[name] as string[]).push(v);
144+
}
144145

145-
paths[name] = {
146+
paths[a] = {
146147
path: `${repoDir}/node_modules/${alias}`,
147148
version: v,
148149
};
@@ -152,6 +153,18 @@ const autoinstall = async (context: ExecutionContext): Promise<ModulePaths> => {
152153
}
153154
}
154155

156+
// Write linker arguments back to the plan
157+
for (const step of plan.workflow.steps) {
158+
const job = step as unknown as Job;
159+
if (paths[job.adaptor!]) {
160+
const { name } = getNameAndVersion(job.adaptor!);
161+
// @ts-ignore
162+
job.linker = {
163+
[name]: paths[job.adaptor!],
164+
};
165+
}
166+
}
167+
155168
if (adaptorsToLoad.length) {
156169
// Add this to the queue
157170
const p = enqueue(adaptorsToLoad);

packages/engine-multi/src/api/execute.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ import {
1515
} from './lifecycle';
1616
import preloadCredentials from './preload-credentials';
1717
import { ExecutionError } from '../errors';
18+
import type { RunOptions } from '../worker/thread/run';
1819

1920
const execute = async (context: ExecutionContext) => {
2021
const { state, callWorker, logger, options } = context;
2122
try {
22-
// TODO catch and "throw" nice clean autoinstall errors
23-
const adaptorPaths = await autoinstall(context);
23+
await autoinstall(context);
2424

25-
// TODO catch and "throw" nice clean compile errors
2625
try {
2726
await compile(context);
2827
} catch (e: any) {
@@ -49,10 +48,9 @@ const execute = async (context: ExecutionContext) => {
4948
const whitelist = options.whitelist?.map((w) => w.toString());
5049

5150
const runOptions = {
52-
adaptorPaths,
53-
whitelist,
5451
statePropsToRemove: options.statePropsToRemove,
55-
};
52+
whitelist,
53+
} as RunOptions;
5654

5755
const workerOptions = {
5856
memoryLimitMb: options.memoryLimitMb,
@@ -109,13 +107,15 @@ const execute = async (context: ExecutionContext) => {
109107
jobError(context, evt);
110108
},
111109
[workerEvents.LOG]: (evt: workerEvents.LogEvent) => {
110+
// console.log(evt.log.name, evt.log.message);
112111
log(context, evt);
113112
},
114113
// TODO this is also untested
115114
[workerEvents.ERROR]: (evt: workerEvents.ErrorEvent) => {
116115
error(context, { workflowId: state.plan.id, error: evt.error });
117116
},
118117
};
118+
119119
return callWorker(
120120
'run',
121121
[state.plan, state.input || {}, runOptions || {}],

packages/engine-multi/src/api/lifecycle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const workflowStart = (
3838
// forward the event on to any external listeners
3939
context.emit(externalEvents.WORKFLOW_START, {
4040
threadId,
41+
versions: context.versions,
4142
});
4243
};
4344

@@ -81,7 +82,6 @@ export const jobStart = (
8182
context.emit(externalEvents.JOB_START, {
8283
jobId,
8384
threadId,
84-
versions: context.versions,
8585
});
8686
};
8787

0 commit comments

Comments
 (0)