Skip to content

Commit 242e36c

Browse files
fix(project): include trigger reply fields in version hash
1 parent fd58873 commit 242e36c

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

.changeset/quiet-seals-battle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@openfn/project': patch
3+
'@openfn/cli': patch
4+
---
5+
6+
Include `webhook_reply` and `cron_cursor_job_id` in workflow version hashes so CLI deploy stays aligned with Lightning.

packages/project/src/util/version.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ export const generateHash = (
5454
'body',
5555
].sort();
5656

57-
const triggerKeys = ['type', 'cron_expression', 'enabled'].sort();
57+
const triggerKeys = [
58+
'type',
59+
'cron_expression',
60+
'enabled',
61+
'webhook_reply',
62+
'cron_cursor_job_id',
63+
].sort();
5864

5965
const edgeKeys = [
6066
'name', // generated

packages/project/test/util/version-workflow.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,51 @@ test('hash a trigger', (t) => {
384384
t.not(generateHash(webhook), generateHash(cronExpression));
385385
});
386386

387+
test('hash changes when webhook_reply changes', (t) => {
388+
const wf1 = generateWorkflow(
389+
`@name wf-1
390+
@id workflow-id
391+
t(type=webhook)-x(expression=x)
392+
`
393+
);
394+
const wf2 = generateWorkflow(
395+
`@name wf-1
396+
@id workflow-id
397+
t(type=webhook)-x(expression=x)
398+
`
399+
);
400+
401+
(wf1.steps[0] as any).openfn.webhook_reply = 'before_start';
402+
(wf2.steps[0] as any).openfn.webhook_reply = 'after_completion';
403+
404+
t.not(generateHash(wf1), generateHash(wf2));
405+
});
406+
407+
test('hash changes when cron_cursor_job_id changes', (t) => {
408+
const wf1 = generateWorkflow(
409+
`@name wf-1
410+
@id workflow-id
411+
t(type=cron,cron_expression="1")-a
412+
a-b
413+
`
414+
);
415+
const wf2 = generateWorkflow(
416+
`@name wf-1
417+
@id workflow-id
418+
t(type=cron,cron_expression="1")-a
419+
a-b
420+
`
421+
);
422+
423+
const [trigger1, jobA1] = wf1.steps as any[];
424+
const [trigger2, , jobB2] = wf2.steps as any[];
425+
426+
trigger1.openfn.cron_cursor_job_id = jobA1.openfn.uuid;
427+
trigger2.openfn.cron_cursor_job_id = jobB2.openfn.uuid;
428+
429+
t.not(generateHash(wf1), generateHash(wf2));
430+
});
431+
387432
test('hash changes across an edge', (t) => {
388433
const basicEdge = generateWorkflow(
389434
`

0 commit comments

Comments
 (0)