@shipfox/api-workflows 5.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +89 -0
- package/dist/core/agent-defaults.d.ts +17 -0
- package/dist/core/agent-defaults.d.ts.map +1 -0
- package/dist/core/agent-defaults.js +21 -0
- package/dist/core/agent-defaults.js.map +1 -0
- package/dist/core/agent-tool-capability-warning.d.ts +4 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
- package/dist/core/agent-tool-capability-warning.js +15 -17
- package/dist/core/agent-tool-capability-warning.js.map +1 -1
- package/dist/core/agent-tools.d.ts +11 -9
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js +23 -18
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/checkout.d.ts +21 -7
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js +23 -11
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
- package/dist/core/entities/workflow-run-attempt.js.map +1 -1
- package/dist/core/job-execution.d.ts +3 -1
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +14 -12
- package/dist/core/job-execution.js.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
- package/dist/core/job-transition/derive-job-success.js +1 -1
- package/dist/core/job-transition/derive-job-success.js.map +1 -1
- package/dist/core/listener-execution-materialization.d.ts +3 -3
- package/dist/core/listener-execution-materialization.d.ts.map +1 -1
- package/dist/core/listener-execution-materialization.js +3 -4
- package/dist/core/listener-execution-materialization.js.map +1 -1
- package/dist/core/run-workflow.d.ts +12 -1
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js +13 -8
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/core/step-config/agent.d.ts +8 -8
- package/dist/core/step-config/agent.d.ts.map +1 -1
- package/dist/core/step-config/agent.js +12 -10
- package/dist/core/step-config/agent.js.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.js +4 -4
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.d.ts +4 -4
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +6 -6
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/core/step-config/run.d.ts +1 -1
- package/dist/core/step-config/run.d.ts.map +1 -1
- package/dist/core/step-config/run.js.map +1 -1
- package/dist/core/workflow-run-creation.d.ts +3 -3
- package/dist/core/workflow-run-creation.d.ts.map +1 -1
- package/dist/core/workflow-run-creation.js +3 -4
- package/dist/core/workflow-run-creation.js.map +1 -1
- package/dist/db/db.d.ts +16 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/job-listeners.d.ts +7 -1
- package/dist/db/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js +10 -5
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/runner-lease-table.d.ts +5 -5
- package/dist/db/runner-lease-table.d.ts.map +1 -1
- package/dist/db/runner-lease-table.js +3 -2
- package/dist/db/runner-lease-table.js.map +1 -1
- package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
- package/dist/db/schema/workflow-run-attempts.js +2 -1
- package/dist/db/schema/workflow-run-attempts.js.map +1 -1
- package/dist/db/schema/workflow-runs.js +1 -1
- package/dist/db/schema/workflow-runs.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +5 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +14 -7
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
- package/dist/db/workflow-runs/jobs.js +3 -1
- package/dist/db/workflow-runs/jobs.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +9 -2
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +12 -9
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-rerun.js +3 -1
- package/dist/db/workflow-runs/run-rerun.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/checkout-token.d.ts +14 -1
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
- package/dist/presentation/dto/checkout-token.js.map +1 -1
- package/dist/presentation/index.d.ts +1 -1
- package/dist/presentation/index.d.ts.map +1 -1
- package/dist/presentation/index.js +1 -1
- package/dist/presentation/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +18 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +113 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
- package/dist/presentation/routes/agent-runtime-config.js +59 -57
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
- package/dist/presentation/routes/cancel-run.d.ts +2 -1
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
- package/dist/presentation/routes/cancel-run.js +37 -34
- package/dist/presentation/routes/cancel-run.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts +8 -1
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +65 -47
- package/dist/presentation/routes/checkout-token.js.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.js +44 -53
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
- package/dist/presentation/routes/get-run.d.ts +2 -1
- package/dist/presentation/routes/get-run.d.ts.map +1 -1
- package/dist/presentation/routes/get-run.js +53 -50
- package/dist/presentation/routes/get-run.js.map +1 -1
- package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
- package/dist/presentation/routes/get-step-secrets.js +72 -68
- package/dist/presentation/routes/get-step-secrets.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +19 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +38 -30
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/leased-step.d.ts +2 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -1
- package/dist/presentation/routes/leased-step.js +1 -2
- package/dist/presentation/routes/leased-step.js.map +1 -1
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
- package/dist/presentation/routes/list-run-attempts.js +29 -26
- package/dist/presentation/routes/list-run-attempts.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts +2 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js +51 -60
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/next-step.d.ts +10 -1
- package/dist/presentation/routes/next-step.d.ts.map +1 -1
- package/dist/presentation/routes/next-step.js +64 -50
- package/dist/presentation/routes/next-step.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +10 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -0
- package/dist/presentation/routes/project-access.js +17 -0
- package/dist/presentation/routes/project-access.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -1
- package/dist/presentation/routes/report-step.d.ts.map +1 -1
- package/dist/presentation/routes/report-step.js +62 -61
- package/dist/presentation/routes/report-step.js.map +1 -1
- package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
- package/dist/presentation/routes/require-accessible-run.js +3 -6
- package/dist/presentation/routes/require-accessible-run.js.map +1 -1
- package/dist/presentation/routes/rerun-run.d.ts +2 -1
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
- package/dist/presentation/routes/rerun-run.js +46 -43
- package/dist/presentation/routes/rerun-run.js.map +1 -1
- package/dist/temporal/activities/index.d.ts +44 -9
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js +13 -9
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js +48 -33
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +28 -21
- package/src/core/agent-defaults.test.ts +28 -0
- package/src/core/agent-defaults.ts +36 -0
- package/src/core/agent-tool-capability-warning.test.ts +36 -11
- package/src/core/agent-tool-capability-warning.ts +27 -25
- package/src/core/agent-tools.ts +33 -36
- package/src/core/checkout.test.ts +38 -25
- package/src/core/checkout.ts +41 -14
- package/src/core/entities/workflow-run-attempt.ts +1 -1
- package/src/core/job-execution.ts +19 -9
- package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
- package/src/core/job-transition/derive-job-success.ts +1 -1
- package/src/core/listener-execution-materialization.test.ts +4 -2
- package/src/core/listener-execution-materialization.ts +6 -9
- package/src/core/run-workflow.test.ts +43 -38
- package/src/core/run-workflow.ts +26 -9
- package/src/core/step-config/agent.ts +24 -26
- package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
- package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
- package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
- package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
- package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
- package/src/core/step-config/materialize-workflow-model.ts +31 -29
- package/src/core/step-config/resolve-job-execution-name.ts +1 -1
- package/src/core/step-config/resolve-step-config.ts +11 -9
- package/src/core/step-config/run.ts +1 -1
- package/src/core/workflow-run-creation.test.ts +14 -10
- package/src/core/workflow-run-creation.ts +6 -9
- package/src/db/job-listeners.ts +20 -5
- package/src/db/runner-lease-table.ts +2 -2
- package/src/db/schema/workflow-run-attempts.ts +7 -3
- package/src/db/schema/workflow-runs.ts +1 -1
- package/src/db/workflow-runs/job-executions.ts +15 -1
- package/src/db/workflow-runs/jobs.ts +4 -1
- package/src/db/workflow-runs/run-create.test.ts +7 -1
- package/src/db/workflow-runs/run-create.ts +25 -15
- package/src/db/workflow-runs/run-rerun.test.ts +1 -1
- package/src/db/workflow-runs/run-rerun.ts +6 -3
- package/src/index.ts +75 -33
- package/src/presentation/dto/checkout-token.ts +7 -1
- package/src/presentation/index.ts +1 -1
- package/src/presentation/inter-module.test.ts +149 -0
- package/src/presentation/inter-module.ts +132 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
- package/src/presentation/routes/agent-runtime-config.ts +89 -64
- package/src/presentation/routes/cancel-run.test.ts +10 -20
- package/src/presentation/routes/cancel-run.ts +30 -27
- package/src/presentation/routes/checkout-token.test.ts +52 -33
- package/src/presentation/routes/checkout-token.ts +109 -49
- package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
- package/src/presentation/routes/get-run-aggregates.ts +54 -57
- package/src/presentation/routes/get-run.test.ts +10 -18
- package/src/presentation/routes/get-run.ts +51 -48
- package/src/presentation/routes/get-step-secrets.test.ts +29 -7
- package/src/presentation/routes/get-step-secrets.ts +72 -61
- package/src/presentation/routes/index.test.ts +16 -1
- package/src/presentation/routes/index.ts +54 -29
- package/src/presentation/routes/leased-step.ts +3 -2
- package/src/presentation/routes/list-run-attempts.test.ts +9 -19
- package/src/presentation/routes/list-run-attempts.ts +21 -18
- package/src/presentation/routes/list-runs.test.ts +13 -7
- package/src/presentation/routes/list-runs.ts +64 -67
- package/src/presentation/routes/next-step.test.ts +30 -11
- package/src/presentation/routes/next-step.ts +68 -48
- package/src/presentation/routes/project-access.ts +16 -0
- package/src/presentation/routes/report-step.test.ts +18 -2
- package/src/presentation/routes/report-step.ts +51 -49
- package/src/presentation/routes/require-accessible-run.ts +5 -2
- package/src/presentation/routes/rerun-run.test.ts +9 -19
- package/src/presentation/routes/rerun-run.ts +39 -36
- package/src/temporal/activities/index.ts +32 -12
- package/src/temporal/activities/orchestration-activities.test.ts +10 -8
- package/src/temporal/activities/orchestration-activities.ts +74 -50
- package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
- package/test/env.ts +1 -3
- package/test/factories/project.ts +10 -5
- package/test/factories/workflow-model.test.ts +5 -1
- package/test/factories/workflow-model.ts +1 -1
- package/test/factories/workflow-run.ts +1 -1
- package/test/fixtures/agent-inter-module.ts +27 -0
- package/test/fixtures/annotations-inter-module.ts +5 -0
- package/test/fixtures/auth-inter-module.ts +22 -0
- package/test/fixtures/lease-token.ts +2 -1
- package/test/fixtures/projects-inter-module.ts +8 -0
- package/test/fixtures/runners-inter-module.ts +52 -0
- package/test/fixtures/secrets-inter-module.ts +61 -0
- package/test/globalSetup.ts +11 -11
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/core/source-control.d.ts +0 -5
- package/dist/core/source-control.d.ts.map +0 -1
- package/dist/core/source-control.js +0 -19
- package/dist/core/source-control.js.map +0 -1
- package/src/core/source-control.test.ts +0 -17
- package/src/core/source-control.ts +0 -22
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IntegrationSourceControlService } from '@shipfox/api-integration-core';
|
|
2
|
-
export declare function setSourceControl(service: IntegrationSourceControlService): void;
|
|
3
|
-
export declare function clearSourceControl(): void;
|
|
4
|
-
export declare function sourceControl(): IntegrationSourceControlService;
|
|
5
|
-
//# sourceMappingURL=source-control.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-control.d.ts","sourceRoot":"","sources":["../../src/core/source-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,+BAA+B,EAAC,MAAM,+BAA+B,CAAC;AAQnF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,+BAA+B,GAAG,IAAI,CAE/E;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,wBAAgB,aAAa,IAAI,+BAA+B,CAK/D"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Boot-set holder for the integration source-control service, mirroring the db()
|
|
2
|
-
// singleton. The composition root injects it once at startup; routes read it.
|
|
3
|
-
// Workflows cannot construct the service itself (it needs the integration provider
|
|
4
|
-
// registry and connection lookup that live in @shipfox/api-integration-core).
|
|
5
|
-
let _sourceControl;
|
|
6
|
-
export function setSourceControl(service) {
|
|
7
|
-
_sourceControl = service;
|
|
8
|
-
}
|
|
9
|
-
export function clearSourceControl() {
|
|
10
|
-
_sourceControl = undefined;
|
|
11
|
-
}
|
|
12
|
-
export function sourceControl() {
|
|
13
|
-
if (!_sourceControl) {
|
|
14
|
-
throw new Error('workflows: source-control integration is not configured');
|
|
15
|
-
}
|
|
16
|
-
return _sourceControl;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=source-control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/source-control.ts"],"sourcesContent":["import type {IntegrationSourceControlService} from '@shipfox/api-integration-core';\n\n// Boot-set holder for the integration source-control service, mirroring the db()\n// singleton. The composition root injects it once at startup; routes read it.\n// Workflows cannot construct the service itself (it needs the integration provider\n// registry and connection lookup that live in @shipfox/api-integration-core).\nlet _sourceControl: IntegrationSourceControlService | undefined;\n\nexport function setSourceControl(service: IntegrationSourceControlService): void {\n _sourceControl = service;\n}\n\nexport function clearSourceControl(): void {\n _sourceControl = undefined;\n}\n\nexport function sourceControl(): IntegrationSourceControlService {\n if (!_sourceControl) {\n throw new Error('workflows: source-control integration is not configured');\n }\n return _sourceControl;\n}\n"],"names":["_sourceControl","setSourceControl","service","clearSourceControl","undefined","sourceControl","Error"],"mappings":"AAEA,iFAAiF;AACjF,8EAA8E;AAC9E,mFAAmF;AACnF,8EAA8E;AAC9E,IAAIA;AAEJ,OAAO,SAASC,iBAAiBC,OAAwC;IACvEF,iBAAiBE;AACnB;AAEA,OAAO,SAASC;IACdH,iBAAiBI;AACnB;AAEA,OAAO,SAASC;IACd,IAAI,CAACL,gBAAgB;QACnB,MAAM,IAAIM,MAAM;IAClB;IACA,OAAON;AACT"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {IntegrationSourceControlService} from '@shipfox/api-integration-core';
|
|
2
|
-
import {clearSourceControl, setSourceControl, sourceControl} from './source-control.js';
|
|
3
|
-
|
|
4
|
-
describe('sourceControl', () => {
|
|
5
|
-
it('returns the configured service', () => {
|
|
6
|
-
const service = {} as IntegrationSourceControlService;
|
|
7
|
-
setSourceControl(service);
|
|
8
|
-
|
|
9
|
-
expect(sourceControl()).toBe(service);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('throws when the source-control integration is not configured', () => {
|
|
13
|
-
clearSourceControl();
|
|
14
|
-
|
|
15
|
-
expect(() => sourceControl()).toThrow('source-control integration is not configured');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type {IntegrationSourceControlService} from '@shipfox/api-integration-core';
|
|
2
|
-
|
|
3
|
-
// Boot-set holder for the integration source-control service, mirroring the db()
|
|
4
|
-
// singleton. The composition root injects it once at startup; routes read it.
|
|
5
|
-
// Workflows cannot construct the service itself (it needs the integration provider
|
|
6
|
-
// registry and connection lookup that live in @shipfox/api-integration-core).
|
|
7
|
-
let _sourceControl: IntegrationSourceControlService | undefined;
|
|
8
|
-
|
|
9
|
-
export function setSourceControl(service: IntegrationSourceControlService): void {
|
|
10
|
-
_sourceControl = service;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function clearSourceControl(): void {
|
|
14
|
-
_sourceControl = undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function sourceControl(): IntegrationSourceControlService {
|
|
18
|
-
if (!_sourceControl) {
|
|
19
|
-
throw new Error('workflows: source-control integration is not configured');
|
|
20
|
-
}
|
|
21
|
-
return _sourceControl;
|
|
22
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import {resolve} from 'node:path';
|
|
2
|
-
import {TestWorkflowEnvironment} from '@temporalio/testing';
|
|
3
|
-
import {Worker} from '@temporalio/worker';
|
|
4
|
-
|
|
5
|
-
const TASK_QUEUE = 'test-orchestration-timeout';
|
|
6
|
-
const WORKFLOWS_PATH = resolve(import.meta.dirname, '../../../dist/temporal/workflows/index.js');
|
|
7
|
-
|
|
8
|
-
interface ActivityCall {
|
|
9
|
-
name: string;
|
|
10
|
-
params: unknown;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let testEnv: TestWorkflowEnvironment;
|
|
14
|
-
let worker: Worker;
|
|
15
|
-
let workerRunPromise: Promise<void> | undefined;
|
|
16
|
-
|
|
17
|
-
let calls: ActivityCall[] = [];
|
|
18
|
-
let versionSeq = 0;
|
|
19
|
-
let failJobExecutionAsTimedOutShouldThrow = false;
|
|
20
|
-
|
|
21
|
-
function nextVersion(): number {
|
|
22
|
-
return ++versionSeq;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function callsNamed(name: string): ActivityCall[] {
|
|
26
|
-
return calls.filter((c) => c.name === name);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
beforeAll(async () => {
|
|
30
|
-
// Time-skipping environment lets us advance virtual time past the execution
|
|
31
|
-
// timeout without waiting in real wall time.
|
|
32
|
-
testEnv = await TestWorkflowEnvironment.createTimeSkipping();
|
|
33
|
-
|
|
34
|
-
worker = await Worker.create({
|
|
35
|
-
connection: testEnv.nativeConnection,
|
|
36
|
-
taskQueue: TASK_QUEUE,
|
|
37
|
-
workflowsPath: WORKFLOWS_PATH,
|
|
38
|
-
activities: {
|
|
39
|
-
loadRunAttemptDag: () => ({
|
|
40
|
-
workflowRunId: 'run-1',
|
|
41
|
-
runAttemptId: 'run-attempt-1',
|
|
42
|
-
workspaceId: 'workspace-1',
|
|
43
|
-
projectId: 'project-1',
|
|
44
|
-
runVersion: 1,
|
|
45
|
-
jobs: [],
|
|
46
|
-
}),
|
|
47
|
-
setRunAttemptStatus: (params: unknown) => {
|
|
48
|
-
calls.push({name: 'setRunAttemptStatus', params});
|
|
49
|
-
return {newVersion: nextVersion()};
|
|
50
|
-
},
|
|
51
|
-
setJobStatus: (params: unknown) => {
|
|
52
|
-
calls.push({name: 'setJobStatus', params});
|
|
53
|
-
return {newVersion: nextVersion()};
|
|
54
|
-
},
|
|
55
|
-
setJobExecutionStatus: (params: unknown) => {
|
|
56
|
-
calls.push({name: 'setJobExecutionStatus', params});
|
|
57
|
-
return {newVersion: nextVersion(), status: (params as {status?: string}).status};
|
|
58
|
-
},
|
|
59
|
-
bulkSetStepStatuses: (params: unknown) => {
|
|
60
|
-
calls.push({name: 'bulkSetStepStatuses', params});
|
|
61
|
-
},
|
|
62
|
-
resolveLeaseExpiredJobExecutionActivity: (params: unknown) => {
|
|
63
|
-
calls.push({name: 'resolveLeaseExpiredJobExecutionActivity', params});
|
|
64
|
-
return {status: 'failed', executionVersion: nextVersion()};
|
|
65
|
-
},
|
|
66
|
-
resolveJobStatusFromJobExecutionsActivity: (params: unknown) => {
|
|
67
|
-
calls.push({name: 'resolveJobStatusFromJobExecutionsActivity', params});
|
|
68
|
-
return {status: 'failed', jobVersion: nextVersion()};
|
|
69
|
-
},
|
|
70
|
-
releaseLeaseActivity: (params: unknown) => {
|
|
71
|
-
calls.push({name: 'releaseLeaseActivity', params});
|
|
72
|
-
},
|
|
73
|
-
enqueueJobExecutionForRunner: (params: unknown) => {
|
|
74
|
-
// No-op — we want the workflow to block on the signal until the timeout fires.
|
|
75
|
-
calls.push({name: 'enqueueJobExecutionForRunner', params});
|
|
76
|
-
},
|
|
77
|
-
failJobExecutionAsTimedOutActivity: async (params: unknown) => {
|
|
78
|
-
calls.push({name: 'failJobExecutionAsTimedOutActivity', params});
|
|
79
|
-
if (failJobExecutionAsTimedOutShouldThrow) {
|
|
80
|
-
const {ApplicationFailure} = await import('@temporalio/common');
|
|
81
|
-
throw ApplicationFailure.nonRetryable('simulated DB outage');
|
|
82
|
-
}
|
|
83
|
-
return {newVersion: nextVersion()};
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
workerRunPromise = worker.run();
|
|
89
|
-
workerRunPromise.catch(() => {
|
|
90
|
-
// Suppress unhandled rejection on worker shutdown.
|
|
91
|
-
});
|
|
92
|
-
}, 60_000);
|
|
93
|
-
|
|
94
|
-
afterAll(async () => {
|
|
95
|
-
worker?.shutdown();
|
|
96
|
-
await workerRunPromise;
|
|
97
|
-
await testEnv?.teardown();
|
|
98
|
-
}, 15_000);
|
|
99
|
-
|
|
100
|
-
beforeEach(() => {
|
|
101
|
-
calls = [];
|
|
102
|
-
versionSeq = 0;
|
|
103
|
-
failJobExecutionAsTimedOutShouldThrow = false;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const defaultJobInput = {
|
|
107
|
-
workspaceId: 'workspace-1',
|
|
108
|
-
jobId: 'job-timeout',
|
|
109
|
-
runAttemptId: 'run-attempt-1',
|
|
110
|
-
projectId: 'project-1',
|
|
111
|
-
jobVersion: 1,
|
|
112
|
-
jobExecutionId: 'job-timeout',
|
|
113
|
-
executionVersion: 1,
|
|
114
|
-
requiredLabels: ['ubuntu22'],
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
function executeJob(input: typeof defaultJobInput): Promise<{status: string; jobVersion: number}> {
|
|
118
|
-
const normalized = {
|
|
119
|
-
...input,
|
|
120
|
-
jobExecutionId:
|
|
121
|
-
input.jobExecutionId === defaultJobInput.jobExecutionId &&
|
|
122
|
-
input.jobId !== defaultJobInput.jobId
|
|
123
|
-
? input.jobId
|
|
124
|
-
: input.jobExecutionId,
|
|
125
|
-
};
|
|
126
|
-
return testEnv.client.workflow.execute('jobExecutionOrchestration', {
|
|
127
|
-
taskQueue: TASK_QUEUE,
|
|
128
|
-
workflowId: `job:${input.jobId}-${Math.random()}`,
|
|
129
|
-
args: [normalized],
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
describe('jobExecutionOrchestration timeout path', () => {
|
|
134
|
-
test('times out after JOB_MAX_DURATION; calls failJobExecutionAsTimedOutActivity then bulkSetStepStatuses', async () => {
|
|
135
|
-
const result = await executeJob(defaultJobInput);
|
|
136
|
-
|
|
137
|
-
expect(result.status).toBe('failed');
|
|
138
|
-
|
|
139
|
-
expect(callsNamed('failJobExecutionAsTimedOutActivity')).toHaveLength(1);
|
|
140
|
-
|
|
141
|
-
const setJobStatuses = callsNamed('setJobExecutionStatus').map(
|
|
142
|
-
(c) => (c.params as {status: string}).status,
|
|
143
|
-
);
|
|
144
|
-
expect(setJobStatuses).toEqual(['running']);
|
|
145
|
-
|
|
146
|
-
// Timeout path sweeps steps with the bulk activity (no per-step detail).
|
|
147
|
-
const stepCall = callsNamed('bulkSetStepStatuses')[0];
|
|
148
|
-
expect((stepCall?.params as {status: string})?.status).toBe('failed');
|
|
149
|
-
// The lease is intentionally NOT released on the timeout path (the TIMED_OUT
|
|
150
|
-
// event drives cooperative cancel; the stuck detector reaps the row).
|
|
151
|
-
expect(callsNamed('releaseLeaseActivity')).toHaveLength(0);
|
|
152
|
-
expect(callsNamed('resolveLeaseExpiredJobExecutionActivity')).toHaveLength(0);
|
|
153
|
-
}, 60_000);
|
|
154
|
-
|
|
155
|
-
test('failJobExecutionAsTimedOutActivity throws → workflow surfaces the error', async () => {
|
|
156
|
-
failJobExecutionAsTimedOutShouldThrow = true;
|
|
157
|
-
|
|
158
|
-
await expect(executeJob({...defaultJobInput, jobId: 'job-fail-error'})).rejects.toThrow();
|
|
159
|
-
|
|
160
|
-
const setJobStatuses = callsNamed('setJobExecutionStatus').map(
|
|
161
|
-
(c) => (c.params as {status: string}).status,
|
|
162
|
-
);
|
|
163
|
-
expect(setJobStatuses).toEqual(['running']);
|
|
164
|
-
}, 60_000);
|
|
165
|
-
});
|