Skip to content
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
9 changes: 9 additions & 0 deletions integration-tests/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/integration-tests-cli

## 1.0.27

### Patch Changes

- Updated dependencies [cb21649]
- Updated dependencies [d3213e6]
- @openfn/lightning-mock@2.4.27
- @openfn/project@0.18.1

## 1.0.26

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-cli",
"private": true,
"version": "1.0.26",
"version": "1.0.27",
"description": "CLI integration tests",
"author": "Open Function Group <admin@openfn.org>",
"license": "ISC",
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/cli

## 1.39.3

### Patch Changes

Fix an issue where `openfn project deploy --new` drops UUIDs on workflows

- Updated dependencies [d3213e6]
- @openfn/project@0.18.1

## 1.39.2

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "1.39.2",
"version": "1.39.3",
"description": "CLI devtools for the OpenFn toolchain",
"engines": {
"node": ">=18",
Expand Down Expand Up @@ -55,9 +55,9 @@
"@openfn/compiler": "workspace:*",
"@openfn/deploy": "workspace:*",
"@openfn/describe-package": "workspace:*",
"@openfn/lexicon": "workspace:^",
"@openfn/lexicon": "workspace:*",
"@openfn/logger": "workspace:*",
"@openfn/project": "workspace:^",
"@openfn/project": "workspace:*",
"@openfn/runtime": "workspace:*",
"chalk": "^5.6.2",
"chokidar": "^3.6.0",
Expand All @@ -75,4 +75,4 @@
"dist",
"README.md"
]
}
}
8 changes: 8 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/lightning-mock

## 2.4.27

### Patch Changes

- cb21649: Tighten validation on provisioner to ensure ids on entities
- Updated dependencies [d3213e6]
- @openfn/project@0.18.1

## 2.4.26

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.4.26",
"version": "2.4.27",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
61 changes: 56 additions & 5 deletions packages/lightning-mock/src/api-rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,74 @@ export function validateProvisionPayload(
: Object.values(incoming.workflows ?? {});

for (const wf of wfList) {
const wfErrors: Record<string, any> = {};

if (!wf.id) {
wfErrors.id = ["This field can't be blank"];
}

const edgeErrors: Record<string, any> = {};
const edgeList: any[] = Array.isArray(wf.edges)
? wf.edges
: Object.values(wf.edges ?? {});

for (const edge of edgeList) {
const key = edge.id ?? '->';
const fieldErrors: Record<string, any> = {};

if (!edge.delete && !edge.source_trigger_id && !edge.source_job_id) {
const key = edge.id ?? '->';
edgeErrors[key] = {
source_job_id: ['source_job_id or source_trigger_id must be present'],
};
fieldErrors.source_job_id = [
'source_job_id or source_trigger_id must be present',
];
}
if (!edge.id) {
fieldErrors.id = ["This field can't be blank"];
}

if (Object.keys(fieldErrors).length > 0) {
edgeErrors[key] = fieldErrors;
}
}

if (Object.keys(edgeErrors).length > 0) {
wfErrors.edges = edgeErrors;
}

const jobErrors: Record<string, any> = {};
const jobList: any[] = Array.isArray(wf.jobs)
? wf.jobs
: Object.values(wf.jobs ?? {});

for (const job of jobList) {
if (!job.id) {
const key = job.name ?? 'unknown';
jobErrors[key] = { id: ["This field can't be blank"] };
}
}

if (Object.keys(jobErrors).length > 0) {
wfErrors.jobs = jobErrors;
}

const triggerErrors: Record<string, any> = {};
const triggerList: any[] = Array.isArray(wf.triggers)
? wf.triggers
: Object.values(wf.triggers ?? {});

for (const trigger of triggerList) {
if (!trigger.id) {
const key = trigger.type ?? 'unknown';
triggerErrors[key] = { id: ["This field can't be blank"] };
}
}

if (Object.keys(triggerErrors).length > 0) {
wfErrors.triggers = triggerErrors;
}

if (Object.keys(wfErrors).length > 0) {
const wfKey = wf.name ?? wf.id ?? 'unknown';
workflowErrors[wfKey] = { edges: edgeErrors };
workflowErrors[wfKey] = wfErrors;
}
}

Expand Down
112 changes: 111 additions & 1 deletion packages/lightning-mock/test/rest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ test('validateProvisionPayload: returns null for a valid edge with source_trigge
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [
{
Expand All @@ -110,6 +111,7 @@ test('validateProvisionPayload: returns null for a valid edge with source_job_id
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [
{
Expand All @@ -130,6 +132,7 @@ test('validateProvisionPayload: returns errors when edge has no source', (t) =>
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [
{
Expand Down Expand Up @@ -166,6 +169,7 @@ test('validateProvisionPayload: returns null for deleted edges', (t) => {
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [
{
Expand All @@ -183,11 +187,117 @@ test('validateProvisionPayload: returns null for deleted edges', (t) => {
test('validateProvisionPayload: returns null when there are no edges', (t) => {
const payload = {
id: 'proj-1',
workflows: [{ name: 'wf1', edges: [] }],
workflows: [{ id: 'wf-1', name: 'wf1', edges: [] }],
};
t.is(validateProvisionPayload(payload), null);
});

test('validateProvisionPayload: returns an error when a workflow has no id', (t) => {
const payload = {
id: 'proj-1',
workflows: [{ name: 'wf1', edges: [] }],
};
const result = validateProvisionPayload(payload);
t.deepEqual(result, {
errors: {
workflows: {
wf1: {
id: ["This field can't be blank"],
},
},
},
});
});

test('validateProvisionPayload: returns an error when an edge has no id', (t) => {
const payload = {
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [
{
source_trigger_id: 'trig-uuid',
target_job_id: 'job-uuid',
enabled: true,
},
],
},
],
};
const result = validateProvisionPayload(payload);
t.deepEqual(result, {
errors: {
workflows: {
wf1: {
edges: {
'->': {
id: ["This field can't be blank"],
},
},
},
},
},
});
});

test('validateProvisionPayload: returns an error when a job has no id', (t) => {
const payload = {
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [],
jobs: [{ name: 'Transform data' }],
},
],
};
const result = validateProvisionPayload(payload);
t.deepEqual(result, {
errors: {
workflows: {
wf1: {
jobs: {
'Transform data': {
id: ["This field can't be blank"],
},
},
},
},
},
});
});

test('validateProvisionPayload: returns an error when a trigger has no id', (t) => {
const payload = {
id: 'proj-1',
workflows: [
{
id: 'wf-1',
name: 'wf1',
edges: [],
triggers: [{ type: 'webhook', enabled: true }],
},
],
};
const result = validateProvisionPayload(payload);
t.deepEqual(result, {
errors: {
workflows: {
wf1: {
triggers: {
webhook: {
id: ["This field can't be blank"],
},
},
},
},
},
});
});

test.serial(
'should return 422 when a workflow edge has no source',
async (t) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/project/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/project

## 0.18.1

### Patch Changes

- d3213e6: Fix an issue where new workflows do not get assigned a UUID

## 0.18.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/project/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/project",
"version": "0.18.0",
"version": "0.18.1",
"description": "Read, serialize, replicate and sync OpenFn projects",
"scripts": {
"test": "pnpm ava",
Expand Down
2 changes: 1 addition & 1 deletion packages/project/src/serialize/to-app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const mapWorkflow = (
} as Provisioner.Workflow;

if (useUuids) {
wfState.id = (workflow.openfn?.uuid ?? randomUUID) as any;
wfState.id = (workflow.openfn?.uuid ?? randomUUID()) as any;
}

if (workflow.name) {
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/test/execute/step.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ test.serial('log duration of execution', async (t) => {

const duration = logger._find('success', /completed in/i);

t.regex(duration?.message, /y completed in \d\d?ms/i);
t.regex(duration?.message, /y completed in \d+(\.\d+)?(ms|s|m)/i);
});

test.serial('log memory usage', async (t) => {
Expand Down Expand Up @@ -303,8 +303,8 @@ test.serial('log memory usage with profiler and peak', async (t) => {
await execute(context, step, initialState);

const memory = logger._find('debug', /step memory usage/i);
// All we're looking for here is two strings of numbers in mb
t.regex(memory?.message, /peak (\d)+(.+)\d(\d?)mb/i);
// All we're looking for here is a number (optionally decimal) in mb
t.regex(memory?.message, /peak \d+(\.\d+)?mb/i);
});

test.serial('warn if a non-leaf step does not return state', async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.