Skip to content

Commit

Permalink
Merge pull request #494 from OpenFn/release/next
Browse files Browse the repository at this point in the history
Release: worker 0.2.8 & CLI 0.4.9
  • Loading branch information
josephjclark authored Nov 21, 2023
2 parents 595fd3c + 35c6c42 commit 8778c01
Show file tree
Hide file tree
Showing 58 changed files with 2,737 additions and 975 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ WORKDIR /app/packages/ws-worker
# ------------------------------------------------------------------------------

EXPOSE 2222
CMD [ "node", "dist/start.js"]

# TODO: determine how to pass in the -l from `docker run` for running on mac m1
# CMD [ "pnpm", "start", "-l", "ws://host.docker.internal:4000"]
CMD [ "node", "./dist/start.js"]
28 changes: 28 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# @openfn/integration-tests-worker

## 1.0.20

### Patch Changes

- Updated dependencies [6f78b7a]
- Updated dependencies [4a17048]
- Updated dependencies [54d0017]
- Updated dependencies [6f78b7a]
- @openfn/engine-multi@0.2.0
- @openfn/ws-worker@0.2.9
- @openfn/lightning-mock@1.1.2

## 1.0.19

### Patch Changes

- Updated dependencies
- @openfn/ws-worker@0.2.8
- @openfn/lightning-mock@1.1.1

## 1.0.18

### Patch Changes

- Updated dependencies [9bf94f8]
- @openfn/lightning-mock@1.1.0
- @openfn/ws-worker@0.2.7

## 1.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.17",
"version": "1.0.20",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/src/factories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import crypto from 'node:crypto';

export const createAttempt = (triggers, jobs, edges, args) => ({
export const createAttempt = (triggers, jobs, edges, args = {}) => ({
id: crypto.randomUUID(),
triggers,
jobs,
Expand Down
60 changes: 60 additions & 0 deletions integration-tests/worker/test/autoinstall.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// stress test for autoinstall
// this could evolve into stress testing, benchmarking or artillery generally?
// Also I may skip this in CI after the issue is fixed

import test from 'ava';
import path from 'node:path';

import { initLightning, initWorker } from '../src/init';
import { createAttempt, createJob } from '../src/factories';

const generate = (adaptor, version) => {
const specifier = `@openfn/language-${adaptor}@${version}`;
const job = createJob({
body: `fn(() => ({ data: "${adaptor}" }))`,
adaptor: specifier,
});
return createAttempt([], [job], []);
};

let lightning;
let worker;

const run = async (attempt) => {
return new Promise<any>(async (done, reject) => {
lightning.on('attempt:complete', (evt) => {
if (attempt.id === evt.attemptId) {
done(lightning.getResult(attempt.id));
}
});

lightning.enqueueAttempt(attempt);
});
};

test.before(async () => {
const lightningPort = 4321;

lightning = initLightning(lightningPort);

({ worker } = await initWorker(lightningPort, {
repoDir: path.resolve('tmp/repo/autoinstall'),
}));
});

test.after(async () => {
lightning.destroy();
await worker.destroy();
});

test('autoinstall three things at once', async (t) => {
const a = generate('common', '1.11.1');
const b = generate('http', '5.0.0');
const c = generate('googlesheets', '2.2.2');

const [ra, rb, rc] = await Promise.all([run(a), run(b), run(c)]);

t.is(ra.data, 'common');
t.is(rb.data, 'http');
t.is(rc.data, 'googlesheets');
});
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/cli

## 0.4.9

### Patch Changes

- Updated dependencies [3c2de85]
- @openfn/runtime@0.2.0
- @openfn/deploy@0.2.10

## 0.4.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "0.4.8",
"version": "0.4.9",
"description": "CLI devtools for the openfn toolchain.",
"engines": {
"node": ">=18",
Expand Down
6 changes: 6 additions & 0 deletions packages/deploy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/deploy

## 0.2.10

### Patch Changes

- 3c2de85: Remove the `enabled` flag from Jobs, and add to Triggers and Edges

## 0.2.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/deploy",
"version": "0.2.9",
"version": "0.2.10",
"description": "Deploy projects to Lightning instances",
"type": "module",
"exports": {
Expand Down
10 changes: 5 additions & 5 deletions packages/deploy/src/stateTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function mergeJobs(
name: specJob.name,
adaptor: specJob.adaptor,
body: specJob.body,
enabled: pickValue(specJob, stateJob || {}, 'enabled', true),
},
];
}
Expand All @@ -50,7 +49,6 @@ function mergeJobs(
name: specJob.name,
adaptor: specJob.adaptor,
body: specJob.body,
enabled: pickValue(specJob, stateJob, 'enabled', true),
},
];
}
Expand All @@ -73,11 +71,11 @@ function pickValue(
key: string,
defaultValue: any
): any {
if (typeof first[key] !== 'undefined') {
if (key in first) {
return first[key];
}

if (second && typeof second[key] !== 'undefined') {
if (key in second) {
return second[key];
}

Expand All @@ -96,7 +94,7 @@ function mergeTriggers(
triggerKey,
{
id: crypto.randomUUID(),
...pickKeys(specTrigger, ['type']),
...pickKeys(specTrigger, ['type', 'enabled']),
...(specTrigger.type === 'cron'
? { cron_expression: specTrigger.cron_expression }
: {}),
Expand All @@ -115,6 +113,7 @@ function mergeTriggers(
id: stateTrigger!.id,
...{
type: pickValue(specTrigger!, stateTrigger!, 'type', 'webhook'),
enabled: pickValue(specTrigger!, stateTrigger!, 'enabled', true),
...(specTrigger!.type === 'cron'
? { cron_expression: specTrigger!.cron_expression }
: {}),
Expand Down Expand Up @@ -146,6 +145,7 @@ function mergeEdges(
id,
condition: specEdge.condition ?? null,
target_job_id: jobs[specEdge.target_job ?? -1]?.id ?? '',
enabled: pickValue(specEdge, stateEdge || {}, 'enabled', true),
},
{
source_job_id: jobs[specEdge.source_job ?? -1]?.id,
Expand Down
4 changes: 3 additions & 1 deletion packages/deploy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export type Job = {
id?: string;
name: string;
adaptor: string;
enabled?: boolean;
body: string;
delete?: boolean;
};
Expand All @@ -12,6 +11,7 @@ export type Trigger = {
type?: string;
cron_expression?: string;
delete?: boolean;
enabled?: boolean;
};

export type StateEdge = {
Expand All @@ -20,13 +20,15 @@ export type StateEdge = {
source_job_id: string | null;
source_trigger_id: string | null;
target_job_id: string;
enabled?: boolean;
};

export type SpecEdge = {
condition: string | null;
source_job?: string | null;
source_trigger?: string | null;
target_job: string | null;
enabled?: boolean;
};

export type WorkflowSpec = {
Expand Down
Loading

0 comments on commit 8778c01

Please sign in to comment.