@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,3 +1,4 @@
|
|
|
1
|
+
import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';
|
|
1
2
|
import {createLeaseTokenAuthMethod, verifyJobLeaseToken} from '@shipfox/api-auth';
|
|
2
3
|
import {closeApp, createApp, type FastifyInstance} from '@shipfox/node-fastify';
|
|
3
4
|
import {eq, sql} from 'drizzle-orm';
|
|
@@ -12,9 +13,14 @@ import {
|
|
|
12
13
|
getWorkflowRunByAttemptId,
|
|
13
14
|
} from '#db/workflow-runs.js';
|
|
14
15
|
import {insertRunningJobLease, mintActiveLeaseToken} from '#test/fixtures/active-lease-token.js';
|
|
16
|
+
import {agentTestClient} from '#test/fixtures/agent-inter-module.js';
|
|
17
|
+
import {workflowsTestAuthClient} from '#test/fixtures/auth-inter-module.js';
|
|
15
18
|
import {arrangeJobWithSteps} from '#test/fixtures/job-with-steps.js';
|
|
16
19
|
import {mintLeaseToken} from '#test/fixtures/lease-token.js';
|
|
17
|
-
import {
|
|
20
|
+
import {projectsTestClient} from '#test/fixtures/projects-inter-module.js';
|
|
21
|
+
import {runnersTestClient} from '#test/fixtures/runners-inter-module.js';
|
|
22
|
+
import {createTestSecretsClient} from '#test/fixtures/secrets-inter-module.js';
|
|
23
|
+
import {createLeaseTokenRouteGroup} from './index.js';
|
|
18
24
|
|
|
19
25
|
const URL = '/runs/jobs/current/steps/next';
|
|
20
26
|
|
|
@@ -42,14 +48,10 @@ async function setRunnerToolCapabilities(
|
|
|
42
48
|
`);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
WHERE job_execution_id = ${jobExecutionId}
|
|
50
|
-
`);
|
|
51
|
-
return Number(result.rows[0]?.count ?? '0');
|
|
52
|
-
}
|
|
51
|
+
const annotationWrites = vi.fn<AnnotationsInterModuleClient['replaceOrRemoveAnnotation']>();
|
|
52
|
+
const annotationsTestClient: AnnotationsInterModuleClient = {
|
|
53
|
+
replaceOrRemoveAnnotation: annotationWrites.mockResolvedValue({}),
|
|
54
|
+
};
|
|
53
55
|
|
|
54
56
|
describe('POST /runs/jobs/current/steps/next', () => {
|
|
55
57
|
let app: FastifyInstance;
|
|
@@ -57,7 +59,17 @@ describe('POST /runs/jobs/current/steps/next', () => {
|
|
|
57
59
|
beforeAll(async () => {
|
|
58
60
|
app = await createApp({
|
|
59
61
|
auth: [createLeaseTokenAuthMethod()],
|
|
60
|
-
routes: [
|
|
62
|
+
routes: [
|
|
63
|
+
createLeaseTokenRouteGroup({
|
|
64
|
+
agent: agentTestClient,
|
|
65
|
+
annotations: annotationsTestClient,
|
|
66
|
+
auth: workflowsTestAuthClient,
|
|
67
|
+
integrations: {} as never,
|
|
68
|
+
projects: projectsTestClient,
|
|
69
|
+
runners: runnersTestClient,
|
|
70
|
+
secrets: createTestSecretsClient(),
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
61
73
|
swagger: false,
|
|
62
74
|
});
|
|
63
75
|
await app.ready();
|
|
@@ -199,6 +211,7 @@ describe('POST /runs/jobs/current/steps/next', () => {
|
|
|
199
211
|
});
|
|
200
212
|
|
|
201
213
|
test('writes the tool capability warning only on fresh dispatch', async () => {
|
|
214
|
+
annotationWrites.mockClear();
|
|
202
215
|
const {jobId, steps} = await arrangeJobWithSteps(1);
|
|
203
216
|
await db()
|
|
204
217
|
.update(stepsTable)
|
|
@@ -232,7 +245,13 @@ describe('POST /runs/jobs/current/steps/next', () => {
|
|
|
232
245
|
|
|
233
246
|
expect(first.statusCode).toBe(200);
|
|
234
247
|
expect(second.statusCode).toBe(200);
|
|
235
|
-
expect(
|
|
248
|
+
expect(annotationWrites).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(annotationWrites).toHaveBeenCalledWith(
|
|
250
|
+
expect.objectContaining({
|
|
251
|
+
jobExecutionId: lease.jobExecutionId,
|
|
252
|
+
annotation: expect.objectContaining({op: 'replace'}),
|
|
253
|
+
}),
|
|
254
|
+
);
|
|
236
255
|
});
|
|
237
256
|
|
|
238
257
|
test('returns 404 for a valid token without an active lease', async () => {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';
|
|
2
|
+
import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';
|
|
2
3
|
import {requireLeasedJobContext} from '@shipfox/api-auth-context';
|
|
4
|
+
import type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';
|
|
5
|
+
import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';
|
|
3
6
|
import {nextStepResponseSchema} from '@shipfox/api-workflows-dto';
|
|
4
7
|
import {ClientError, defineRoute} from '@shipfox/node-fastify';
|
|
5
8
|
import {warnAgentToolCapabilityMismatchOnDispatch} from '#core/agent-tool-capability-warning.js';
|
|
@@ -7,56 +10,73 @@ import {JobLeaseNotActiveError, JobNotFoundError} from '#core/errors.js';
|
|
|
7
10
|
import {nextStepForLeasedJobExecution} from '#core/job-execution.js';
|
|
8
11
|
import {toStepDto} from '#presentation/dto/step.js';
|
|
9
12
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export function createNextStepRoute(params: {
|
|
14
|
+
agent: AgentInterModuleClient;
|
|
15
|
+
annotations: AnnotationsInterModuleClient;
|
|
16
|
+
auth: AuthInterModuleClient;
|
|
17
|
+
runners: RunnersInterModuleClient;
|
|
18
|
+
}) {
|
|
19
|
+
return defineRoute({
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/steps/next',
|
|
22
|
+
description:
|
|
23
|
+
'Returns the next step for the runner to run on its job. The job is identified by the access token, so no job ID is needed. Calling this again before reporting the current step returns that same step, so retries are safe. When no runnable steps remain, the response reports that there are no more steps to run, along with the job status; the runner then stops. Finalization is driven server-side from recorded step results and dispatch-time skips, not by the runner calling a job-completion endpoint.',
|
|
24
|
+
schema: {
|
|
25
|
+
response: {
|
|
26
|
+
200: nextStepResponseSchema,
|
|
27
|
+
},
|
|
18
28
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
29
|
+
errorHandler: (error) => {
|
|
30
|
+
if (error instanceof JobNotFoundError) {
|
|
31
|
+
throw new ClientError(error.message, 'job-not-found', {status: 404});
|
|
32
|
+
}
|
|
33
|
+
if (error instanceof JobLeaseNotActiveError) {
|
|
34
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});
|
|
35
|
+
}
|
|
36
|
+
throw error;
|
|
37
|
+
},
|
|
38
|
+
handler: async (request) => {
|
|
39
|
+
const leasedJob = requireLeasedJobContext(request);
|
|
40
|
+
const next = await nextStepForLeasedJobExecution({
|
|
41
|
+
jobId: leasedJob.jobId,
|
|
42
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
43
|
+
runnerSessionId: leasedJob.runnerSessionId,
|
|
44
|
+
agent: params.agent,
|
|
45
|
+
});
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
if (next.kind === 'step') {
|
|
48
|
+
const {token: leaseToken} = await params.auth.mintJobLeaseToken({
|
|
49
|
+
workflowRunId: leasedJob.workflowRunId,
|
|
50
|
+
...(leasedJob.workflowRunAttempt === undefined
|
|
51
|
+
? {}
|
|
52
|
+
: {workflowRunAttempt: leasedJob.workflowRunAttempt}),
|
|
53
|
+
workflowRunAttemptId: leasedJob.workflowRunAttemptId,
|
|
54
|
+
jobId: leasedJob.jobId,
|
|
55
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
56
|
+
projectId: leasedJob.projectId,
|
|
57
|
+
workspaceId: leasedJob.workspaceId,
|
|
58
|
+
runnerSessionId: leasedJob.runnerSessionId,
|
|
41
59
|
currentStepId: next.step.id,
|
|
42
60
|
currentStepAttempt: next.step.currentAttempt,
|
|
43
|
-
}),
|
|
44
|
-
);
|
|
45
|
-
if (next.dispatched) {
|
|
46
|
-
await warnAgentToolCapabilityMismatchOnDispatch({
|
|
47
|
-
leaseIdentity: leasedJob,
|
|
48
|
-
step: next.step,
|
|
49
61
|
});
|
|
62
|
+
if (next.dispatched) {
|
|
63
|
+
await warnAgentToolCapabilityMismatchOnDispatch({
|
|
64
|
+
annotations: params.annotations,
|
|
65
|
+
runners: params.runners,
|
|
66
|
+
leaseIdentity: leasedJob,
|
|
67
|
+
step: next.step,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// The runner echoes this back on report so a stale report from a superseded
|
|
71
|
+
// attempt is ignored.
|
|
72
|
+
return {
|
|
73
|
+
kind: 'step' as const,
|
|
74
|
+
step: toStepDto(next.step),
|
|
75
|
+
attempt: next.step.currentAttempt,
|
|
76
|
+
lease_token: leaseToken,
|
|
77
|
+
};
|
|
50
78
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
step: toStepDto(next.step),
|
|
56
|
-
attempt: next.step.currentAttempt,
|
|
57
|
-
lease_token: leaseToken,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {kind: 'done' as const, status: next.status};
|
|
61
|
-
},
|
|
62
|
-
});
|
|
79
|
+
return {kind: 'done' as const, status: next.status};
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {requireWorkspaceAccess} from '@shipfox/api-auth-context';
|
|
2
|
+
import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
|
|
3
|
+
import {ClientError} from '@shipfox/node-fastify';
|
|
4
|
+
import type {FastifyRequest} from 'fastify';
|
|
5
|
+
|
|
6
|
+
export async function requireProjectAccess(
|
|
7
|
+
request: FastifyRequest,
|
|
8
|
+
projectId: string,
|
|
9
|
+
projects: ProjectsModuleClient,
|
|
10
|
+
) {
|
|
11
|
+
const result = await projects.getProjectById({projectId});
|
|
12
|
+
if (result.project === null)
|
|
13
|
+
throw new ClientError('Project not found', 'project-not-found', {status: 404});
|
|
14
|
+
requireWorkspaceAccess({request, workspaceId: result.project.workspaceId});
|
|
15
|
+
return result.project;
|
|
16
|
+
}
|
|
@@ -9,9 +9,15 @@ import {
|
|
|
9
9
|
getWorkflowRunByAttemptId,
|
|
10
10
|
} from '#db/workflow-runs.js';
|
|
11
11
|
import {insertRunningJobLease, mintActiveLeaseToken} from '#test/fixtures/active-lease-token.js';
|
|
12
|
+
import {agentTestClient} from '#test/fixtures/agent-inter-module.js';
|
|
13
|
+
import {annotationsTestClient} from '#test/fixtures/annotations-inter-module.js';
|
|
14
|
+
import {workflowsTestAuthClient} from '#test/fixtures/auth-inter-module.js';
|
|
12
15
|
import {arrangeJobWithSteps} from '#test/fixtures/job-with-steps.js';
|
|
13
16
|
import {mintLeaseToken} from '#test/fixtures/lease-token.js';
|
|
14
|
-
import {
|
|
17
|
+
import {projectsTestClient} from '#test/fixtures/projects-inter-module.js';
|
|
18
|
+
import {runnersTestClient} from '#test/fixtures/runners-inter-module.js';
|
|
19
|
+
import {createTestSecretsClient} from '#test/fixtures/secrets-inter-module.js';
|
|
20
|
+
import {createLeaseTokenRouteGroup} from './index.js';
|
|
15
21
|
|
|
16
22
|
function reportUrl(stepId: string): string {
|
|
17
23
|
return `/runs/jobs/current/steps/${stepId}/report`;
|
|
@@ -27,7 +33,17 @@ describe('POST /runs/jobs/current/steps/:stepId/report', () => {
|
|
|
27
33
|
beforeAll(async () => {
|
|
28
34
|
app = await createApp({
|
|
29
35
|
auth: [createLeaseTokenAuthMethod()],
|
|
30
|
-
routes: [
|
|
36
|
+
routes: [
|
|
37
|
+
createLeaseTokenRouteGroup({
|
|
38
|
+
agent: agentTestClient,
|
|
39
|
+
annotations: annotationsTestClient,
|
|
40
|
+
auth: workflowsTestAuthClient,
|
|
41
|
+
integrations: {} as never,
|
|
42
|
+
projects: projectsTestClient,
|
|
43
|
+
runners: runnersTestClient,
|
|
44
|
+
secrets: createTestSecretsClient(),
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
31
47
|
swagger: false,
|
|
32
48
|
});
|
|
33
49
|
await app.ready();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {requireLeasedJobContext} from '@shipfox/api-auth-context';
|
|
2
|
-
import {
|
|
2
|
+
import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';
|
|
3
3
|
import {reportStepBodySchema, reportStepResponseSchema} from '@shipfox/api-workflows-dto';
|
|
4
4
|
import {ClientError, defineRoute} from '@shipfox/node-fastify';
|
|
5
5
|
import {z} from 'zod';
|
|
@@ -7,55 +7,57 @@ import {StepAttemptAheadError, StepNotFoundError, StepNotRunningError} from '#co
|
|
|
7
7
|
import {recordStepResult} from '#core/job-execution.js';
|
|
8
8
|
import {fromStepErrorDto} from '#presentation/dto/step.js';
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
export function createReportStepRoute(runners: RunnersInterModuleClient) {
|
|
11
|
+
return defineRoute({
|
|
12
|
+
method: 'POST',
|
|
13
|
+
path: '/steps/:stepId/report',
|
|
14
|
+
description:
|
|
15
|
+
'Reports whether a step succeeded or failed. The job is identified by the access token. Reporting the same step more than once is safe: once a step has finished, later reports for it are ignored. The runner does not call a separate job-completion endpoint — finalization is driven server-side from the recorded step results, and the `cancel` flag tells the runner to stop once the job has finished without full success.',
|
|
16
|
+
schema: {
|
|
17
|
+
params: z.object({stepId: z.string().uuid()}),
|
|
18
|
+
body: reportStepBodySchema,
|
|
19
|
+
response: {
|
|
20
|
+
200: reportStepResponseSchema,
|
|
21
|
+
},
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const leasedJob = requireLeasedJobContext(request);
|
|
23
|
+
errorHandler: (error) => {
|
|
24
|
+
if (error instanceof StepNotFoundError) {
|
|
25
|
+
throw new ClientError(error.message, 'step-not-found', {status: 404});
|
|
26
|
+
}
|
|
27
|
+
if (error instanceof StepNotRunningError) {
|
|
28
|
+
throw new ClientError(error.message, 'step-not-running', {status: 409});
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof StepAttemptAheadError) {
|
|
31
|
+
throw new ClientError(error.message, 'step-attempt-ahead', {status: 409});
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
},
|
|
35
|
+
handler: async (request) => {
|
|
36
|
+
const {stepId} = request.params;
|
|
37
|
+
const leasedJob = requireLeasedJobContext(request);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const {active: leaseIsActive} = await runners.getLeaseState({
|
|
40
|
+
jobId: leasedJob.jobId,
|
|
41
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
42
|
+
runnerSessionId: leasedJob.runnerSessionId,
|
|
43
|
+
});
|
|
44
|
+
if (!leaseIsActive) {
|
|
45
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});
|
|
46
|
+
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
const outcome = await recordStepResult({
|
|
49
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
50
|
+
stepId,
|
|
51
|
+
status: request.body.status,
|
|
52
|
+
error: fromStepErrorDto(request.body.error),
|
|
53
|
+
output: request.body.output ?? null,
|
|
54
|
+
response: request.body.response ?? null,
|
|
55
|
+
exitCode: request.body.exit_code ?? request.body.error?.exit_code ?? null,
|
|
56
|
+
logOutcome: request.body.log_outcome,
|
|
57
|
+
...(request.body.attempt !== undefined ? {attempt: request.body.attempt} : {}),
|
|
58
|
+
});
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
60
|
+
return {ok: true, cancel: outcome.jobFinished && outcome.status === 'failed'};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
|
|
2
2
|
import {ClientError} from '@shipfox/node-fastify';
|
|
3
3
|
import type {FastifyRequest} from 'fastify';
|
|
4
4
|
import type {WorkflowRun} from '#core/entities/workflow-run.js';
|
|
5
5
|
import {getWorkflowRunById} from '#db/index.js';
|
|
6
|
+
import {requireProjectAccess} from './project-access.js';
|
|
6
7
|
|
|
7
8
|
export async function requireAccessibleRun({
|
|
8
9
|
request,
|
|
9
10
|
id,
|
|
11
|
+
projects,
|
|
10
12
|
}: {
|
|
11
13
|
request: FastifyRequest;
|
|
12
14
|
id: string;
|
|
15
|
+
projects: ProjectsModuleClient;
|
|
13
16
|
}): Promise<WorkflowRun> {
|
|
14
17
|
const run = await getWorkflowRunById(id);
|
|
15
18
|
if (!run) {
|
|
16
19
|
throw new ClientError('Run not found', 'not-found', {status: 404});
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
await requireProjectAccess(
|
|
22
|
+
await requireProjectAccess(request, run.projectId, projects).catch((err: unknown) => {
|
|
20
23
|
if (err instanceof ClientError && (err.status === 403 || err.status === 404)) {
|
|
21
24
|
throw new ClientError('Run not found', 'not-found', {status: 404});
|
|
22
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {buildUserContext, setUserContext} from '@shipfox/api-auth-context';
|
|
2
|
-
import {
|
|
2
|
+
import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
|
|
3
3
|
import {ClientError} from '@shipfox/node-fastify';
|
|
4
4
|
import type {FastifyInstance} from 'fastify';
|
|
5
5
|
import Fastify from 'fastify';
|
|
@@ -15,16 +15,11 @@ import {rerunRunRoute} from './rerun-run.js';
|
|
|
15
15
|
|
|
16
16
|
const projectAccessState = vi.hoisted(() => ({workspaceId: ''}));
|
|
17
17
|
|
|
18
|
-
vi.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}),
|
|
24
|
-
),
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
const mockRequireProjectAccess = vi.mocked(requireProjectAccess);
|
|
18
|
+
const getProjectById = vi.fn();
|
|
19
|
+
const projects = {
|
|
20
|
+
getProjectById,
|
|
21
|
+
requireProjectForWorkspace: vi.fn(),
|
|
22
|
+
} as unknown as ProjectsModuleClient;
|
|
28
23
|
|
|
29
24
|
describe('POST /api/workflows/runs/:id/rerun', () => {
|
|
30
25
|
let app: FastifyInstance;
|
|
@@ -46,7 +41,7 @@ describe('POST /api/workflows/runs/:id/rerun', () => {
|
|
|
46
41
|
);
|
|
47
42
|
done();
|
|
48
43
|
});
|
|
49
|
-
app.post('/api/workflows/runs/:id/rerun', rerunRunRoute);
|
|
44
|
+
app.post('/api/workflows/runs/:id/rerun', rerunRunRoute(projects));
|
|
50
45
|
await app.ready();
|
|
51
46
|
});
|
|
52
47
|
|
|
@@ -54,7 +49,7 @@ describe('POST /api/workflows/runs/:id/rerun', () => {
|
|
|
54
49
|
workspaceId = crypto.randomUUID();
|
|
55
50
|
projectId = crypto.randomUUID();
|
|
56
51
|
projectAccessState.workspaceId = workspaceId;
|
|
57
|
-
|
|
52
|
+
getProjectById.mockImplementation(({projectId: requestedProjectId}) =>
|
|
58
53
|
Promise.resolve({
|
|
59
54
|
project: {
|
|
60
55
|
id: requestedProjectId,
|
|
@@ -62,10 +57,7 @@ describe('POST /api/workflows/runs/:id/rerun', () => {
|
|
|
62
57
|
sourceConnectionId: crypto.randomUUID(),
|
|
63
58
|
sourceExternalRepositoryId: `repo:${crypto.randomUUID()}`,
|
|
64
59
|
name: 'Project',
|
|
65
|
-
createdAt: new Date(),
|
|
66
|
-
updatedAt: new Date(),
|
|
67
60
|
},
|
|
68
|
-
workspaceId,
|
|
69
61
|
}),
|
|
70
62
|
);
|
|
71
63
|
});
|
|
@@ -174,9 +166,7 @@ describe('POST /api/workflows/runs/:id/rerun', () => {
|
|
|
174
166
|
payload: {mode: 'all'},
|
|
175
167
|
});
|
|
176
168
|
const source = await createTerminalRun('failed');
|
|
177
|
-
|
|
178
|
-
new ClientError('Forbidden', 'forbidden', {status: 403}),
|
|
179
|
-
);
|
|
169
|
+
getProjectById.mockRejectedValueOnce(new ClientError('Forbidden', 'forbidden', {status: 403}));
|
|
180
170
|
|
|
181
171
|
const inaccessible = await app.inject({
|
|
182
172
|
method: 'POST',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {requireUserContext} from '@shipfox/api-auth-context';
|
|
2
|
+
import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
|
|
2
3
|
import {rerunWorkflowRunBodySchema, workflowRunResponseSchema} from '@shipfox/api-workflows-dto';
|
|
3
4
|
import {ClientError, defineRoute} from '@shipfox/node-fastify';
|
|
4
5
|
import {z} from 'zod';
|
|
@@ -7,42 +8,44 @@ import {createRerunWorkflowRun} from '#db/index.js';
|
|
|
7
8
|
import {toRunDto} from '#presentation/dto/index.js';
|
|
8
9
|
import {requireAccessibleRun} from './require-accessible-run.js';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
export function rerunRunRoute(projects: ProjectsModuleClient) {
|
|
12
|
+
return defineRoute({
|
|
13
|
+
method: 'POST',
|
|
14
|
+
path: '/:id/rerun',
|
|
15
|
+
description: 'Re-run a terminal workflow run',
|
|
16
|
+
schema: {
|
|
17
|
+
params: z.object({
|
|
18
|
+
id: z.string().uuid(),
|
|
19
|
+
}),
|
|
20
|
+
body: rerunWorkflowRunBodySchema,
|
|
21
|
+
response: {
|
|
22
|
+
200: workflowRunResponseSchema,
|
|
23
|
+
},
|
|
21
24
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const sourceRun = await requireAccessibleRun({request, id});
|
|
25
|
+
errorHandler: (error) => {
|
|
26
|
+
if (error instanceof SourceRunNotFoundError) {
|
|
27
|
+
throw new ClientError('Run not found', 'not-found', {status: 404});
|
|
28
|
+
}
|
|
29
|
+
if (error instanceof RunNotTerminalError) {
|
|
30
|
+
throw new ClientError('Run is not terminal', 'run-not-terminal', {status: 409});
|
|
31
|
+
}
|
|
32
|
+
if (error instanceof NoFailedJobsError) {
|
|
33
|
+
throw new ClientError('Run has no failed jobs', 'no-failed-jobs', {status: 409});
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
},
|
|
37
|
+
handler: async (request) => {
|
|
38
|
+
const {id} = request.params;
|
|
39
|
+
const sourceRun = await requireAccessibleRun({request, id, projects});
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const actor = requireUserContext(request);
|
|
42
|
+
const run = await createRerunWorkflowRun({
|
|
43
|
+
workflowRunId: sourceRun.id,
|
|
44
|
+
mode: request.body.mode,
|
|
45
|
+
actorUserId: actor.userId,
|
|
46
|
+
});
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
48
|
+
return toRunDto(run, run.currentAttempt);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
+
import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';
|
|
2
|
+
import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';
|
|
4
|
+
import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';
|
|
5
|
+
import type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';
|
|
1
6
|
import {
|
|
2
7
|
activateJobListenerActivity,
|
|
3
8
|
bulkSetStepStatuses,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
createCancelRunnerJobsActivity,
|
|
10
|
+
createDrainListenerEventsActivity,
|
|
11
|
+
createEnqueueJobExecutionForRunner,
|
|
12
|
+
createReleaseLeaseActivity,
|
|
7
13
|
evaluateJobActivationsActivity,
|
|
8
14
|
failJobExecutionAsTimedOutActivity,
|
|
9
15
|
failRunAsTimedOutActivity,
|
|
10
16
|
loadRunAttemptDag,
|
|
11
17
|
peekListenerBufferActivity,
|
|
12
18
|
recordListenerFiringOutcomeActivity,
|
|
13
|
-
releaseLeaseActivity,
|
|
14
19
|
resolveJobListenerActivity,
|
|
15
20
|
resolveJobStatusFromJobExecutionsActivity,
|
|
16
21
|
resolveLeaseExpiredJobExecutionActivity,
|
|
@@ -20,26 +25,41 @@ import {
|
|
|
20
25
|
settleListenerJobExecutionActivity,
|
|
21
26
|
} from './orchestration-activities.js';
|
|
22
27
|
|
|
23
|
-
export function createOrchestrationActivities(
|
|
28
|
+
export function createOrchestrationActivities(params: {
|
|
29
|
+
agent: AgentInterModuleClient;
|
|
30
|
+
integrations: IntegrationsModuleClient;
|
|
31
|
+
projects: ProjectsModuleClient;
|
|
32
|
+
runners: RunnersInterModuleClient;
|
|
33
|
+
secrets: Pick<SecretsInterModuleClient, 'getVariablesByNamespace'>;
|
|
34
|
+
}) {
|
|
24
35
|
return {
|
|
25
36
|
loadRunAttemptDag,
|
|
26
37
|
setRunAttemptStatus,
|
|
27
38
|
setJobStatus,
|
|
28
|
-
setJobExecutionStatus
|
|
39
|
+
setJobExecutionStatus: async (activityParams: Parameters<typeof setJobExecutionStatus>[0]) =>
|
|
40
|
+
await setJobExecutionStatus(activityParams, params.secrets),
|
|
29
41
|
bulkSetStepStatuses,
|
|
30
|
-
cancelRunnerJobsActivity,
|
|
31
|
-
enqueueJobExecutionForRunner,
|
|
42
|
+
cancelRunnerJobsActivity: createCancelRunnerJobsActivity(params.runners),
|
|
43
|
+
enqueueJobExecutionForRunner: createEnqueueJobExecutionForRunner(params.runners),
|
|
32
44
|
evaluateJobActivationsActivity,
|
|
33
|
-
failJobExecutionAsTimedOutActivity
|
|
45
|
+
failJobExecutionAsTimedOutActivity: async (
|
|
46
|
+
activityParams: Parameters<typeof failJobExecutionAsTimedOutActivity>[0],
|
|
47
|
+
) => await failJobExecutionAsTimedOutActivity(activityParams, params.secrets),
|
|
34
48
|
failRunAsTimedOutActivity,
|
|
35
49
|
activateJobListenerActivity,
|
|
36
|
-
drainListenerEventsActivity
|
|
50
|
+
drainListenerEventsActivity: createDrainListenerEventsActivity({
|
|
51
|
+
agent: params.agent,
|
|
52
|
+
integrations: params.integrations,
|
|
53
|
+
projects: params.projects,
|
|
54
|
+
}),
|
|
37
55
|
peekListenerBufferActivity,
|
|
38
56
|
resolveJobListenerActivity,
|
|
39
57
|
settleListenerJobExecutionActivity,
|
|
40
58
|
recordListenerFiringOutcomeActivity,
|
|
41
|
-
resolveLeaseExpiredJobExecutionActivity
|
|
59
|
+
resolveLeaseExpiredJobExecutionActivity: async (
|
|
60
|
+
activityParams: Parameters<typeof resolveLeaseExpiredJobExecutionActivity>[0],
|
|
61
|
+
) => await resolveLeaseExpiredJobExecutionActivity(activityParams, params.secrets),
|
|
42
62
|
resolveJobStatusFromJobExecutionsActivity,
|
|
43
|
-
releaseLeaseActivity,
|
|
63
|
+
releaseLeaseActivity: createReleaseLeaseActivity(params.runners),
|
|
44
64
|
};
|
|
45
65
|
}
|