@shipfox/api-workflows 11.0.0 → 12.1.0
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 +8 -8
- package/CHANGELOG.md +107 -0
- package/README.md +75 -0
- package/dist/core/agent-defaults.d.ts +2 -1
- package/dist/core/agent-defaults.d.ts.map +1 -1
- package/dist/core/agent-defaults.js.map +1 -1
- package/dist/core/checkout.d.ts +7 -21
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js +122 -41
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/job-execution.d.ts +8 -0
- package/dist/core/entities/job-execution.d.ts.map +1 -1
- package/dist/core/entities/job-execution.js +13 -1
- package/dist/core/entities/job-execution.js.map +1 -1
- package/dist/core/entities/job-listener-event.d.ts +2 -0
- package/dist/core/entities/job-listener-event.d.ts.map +1 -1
- package/dist/core/entities/job-listener-event.js.map +1 -1
- package/dist/core/entities/step.d.ts +13 -3
- package/dist/core/entities/step.d.ts.map +1 -1
- package/dist/core/entities/step.js +6 -0
- package/dist/core/entities/step.js.map +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts +1 -0
- 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/entities/workflow-run.d.ts +17 -0
- package/dist/core/entities/workflow-run.d.ts.map +1 -1
- package/dist/core/entities/workflow-run.js.map +1 -1
- package/dist/core/errors.d.ts +9 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +10 -5
- package/dist/core/errors.js.map +1 -1
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +14 -8
- package/dist/core/job-execution.js.map +1 -1
- package/dist/core/job-transition/decide-job-activation.d.ts +1 -0
- package/dist/core/job-transition/decide-job-activation.d.ts.map +1 -1
- package/dist/core/job-transition/decide-job-activation.js +1 -0
- package/dist/core/job-transition/decide-job-activation.js.map +1 -1
- package/dist/core/job-transition/derive-job-success.d.ts +1 -0
- package/dist/core/job-transition/derive-job-success.d.ts.map +1 -1
- package/dist/core/job-transition/derive-job-success.js +5 -8
- package/dist/core/job-transition/derive-job-success.js.map +1 -1
- package/dist/core/listener-execution-materialization.d.ts +6 -3
- package/dist/core/listener-execution-materialization.d.ts.map +1 -1
- package/dist/core/listener-execution-materialization.js +44 -6
- package/dist/core/listener-execution-materialization.js.map +1 -1
- package/dist/core/resolve-trigger-reference.d.ts +11 -0
- package/dist/core/resolve-trigger-reference.d.ts.map +1 -0
- package/dist/core/resolve-trigger-reference.js +39 -0
- package/dist/core/resolve-trigger-reference.js.map +1 -0
- package/dist/core/run-workflow.d.ts +1 -0
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js +1 -0
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/core/step-config/agent.d.ts +1 -2
- package/dist/core/step-config/agent.d.ts.map +1 -1
- package/dist/core/step-config/agent.js +22 -7
- package/dist/core/step-config/agent.js.map +1 -1
- package/dist/core/step-config/assemble-run-context.d.ts +19 -8
- package/dist/core/step-config/assemble-run-context.d.ts.map +1 -1
- package/dist/core/step-config/assemble-run-context.js +51 -19
- package/dist/core/step-config/assemble-run-context.js.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.js +72 -4
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
- package/dist/core/step-config/index.d.ts +1 -0
- package/dist/core/step-config/index.d.ts.map +1 -1
- package/dist/core/step-config/index.js +1 -0
- package/dist/core/step-config/index.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +49 -8
- 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 +9 -5
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts +3 -3
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.js +24 -13
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +174 -9
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/core/step-config/resolve-workflow-run-name.d.ts +19 -0
- package/dist/core/step-config/resolve-workflow-run-name.d.ts.map +1 -0
- package/dist/core/step-config/resolve-workflow-run-name.js +73 -0
- package/dist/core/step-config/resolve-workflow-run-name.js.map +1 -0
- package/dist/core/step-transition/decide-step-transition.js.map +1 -1
- package/dist/core/step-transition/evaluate-gate.d.ts +2 -1
- package/dist/core/step-transition/evaluate-gate.d.ts.map +1 -1
- package/dist/core/step-transition/evaluate-gate.js +5 -3
- package/dist/core/step-transition/evaluate-gate.js.map +1 -1
- package/dist/core/workflow-run-creation.d.ts +3 -0
- package/dist/core/workflow-run-creation.d.ts.map +1 -1
- package/dist/core/workflow-run-creation.js +22 -7
- package/dist/core/workflow-run-creation.js.map +1 -1
- package/dist/db/db.d.ts +278 -10
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +2 -0
- package/dist/db/db.js.map +1 -1
- package/dist/db/index.d.ts +3 -2
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +2 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/job-listener-events.d.ts +2 -0
- package/dist/db/job-listener-events.d.ts.map +1 -1
- package/dist/db/job-listener-events.js +1 -0
- package/dist/db/job-listener-events.js.map +1 -1
- package/dist/db/job-listeners.d.ts +2 -0
- package/dist/db/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js +81 -21
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/schema/job-executions.d.ts +3 -3
- package/dist/db/schema/job-executions.d.ts.map +1 -1
- package/dist/db/schema/job-executions.js +8 -4
- package/dist/db/schema/job-executions.js.map +1 -1
- package/dist/db/schema/job-listener-events.d.ts +20 -0
- package/dist/db/schema/job-listener-events.d.ts.map +1 -1
- package/dist/db/schema/job-listener-events.js +2 -0
- package/dist/db/schema/job-listener-events.js.map +1 -1
- package/dist/db/schema/step-attempts.js +2 -2
- package/dist/db/schema/step-attempts.js.map +1 -1
- package/dist/db/schema/steps.d.ts +4 -2
- package/dist/db/schema/steps.d.ts.map +1 -1
- package/dist/db/schema/steps.js +1 -1
- package/dist/db/schema/steps.js.map +1 -1
- package/dist/db/schema/workflow-run-attempts.d.ts +21 -2
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
- package/dist/db/schema/workflow-run-attempts.js +2 -0
- package/dist/db/schema/workflow-run-attempts.js.map +1 -1
- package/dist/db/schema/workflow-run-counters.d.ts +43 -0
- package/dist/db/schema/workflow-run-counters.d.ts.map +1 -0
- package/dist/db/schema/workflow-run-counters.js +10 -0
- package/dist/db/schema/workflow-run-counters.js.map +1 -0
- package/dist/db/schema/workflow-runs.d.ts +54 -1
- package/dist/db/schema/workflow-runs.d.ts.map +1 -1
- package/dist/db/schema/workflow-runs.js +10 -2
- package/dist/db/schema/workflow-runs.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +35 -14
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/jobs.d.ts +2 -0
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
- package/dist/db/workflow-runs/jobs.js +9 -5
- package/dist/db/workflow-runs/jobs.js.map +1 -1
- package/dist/db/workflow-runs/queries.d.ts +51 -0
- package/dist/db/workflow-runs/queries.d.ts.map +1 -1
- package/dist/db/workflow-runs/queries.js +82 -2
- package/dist/db/workflow-runs/queries.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +1 -0
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +159 -32
- 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 +13 -5
- package/dist/db/workflow-runs/run-rerun.js.map +1 -1
- package/dist/db/workflow-runs/shared.d.ts +1 -0
- package/dist/db/workflow-runs/shared.d.ts.map +1 -1
- package/dist/db/workflow-runs/shared.js +2 -1
- package/dist/db/workflow-runs/shared.js.map +1 -1
- package/dist/db/workflow-runs/steps.js +3 -3
- package/dist/db/workflow-runs/steps.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +4 -3
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +3 -2
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/metrics/instance.d.ts +1 -0
- package/dist/metrics/instance.d.ts.map +1 -1
- package/dist/metrics/instance.js +9 -0
- package/dist/metrics/instance.js.map +1 -1
- package/dist/presentation/dto/checkout-token.d.ts +1 -0
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
- package/dist/presentation/dto/checkout-token.js +1 -0
- package/dist/presentation/dto/checkout-token.js.map +1 -1
- package/dist/presentation/dto/index.d.ts +1 -1
- package/dist/presentation/dto/index.d.ts.map +1 -1
- package/dist/presentation/dto/index.js +1 -1
- package/dist/presentation/dto/index.js.map +1 -1
- package/dist/presentation/dto/step.d.ts.map +1 -1
- package/dist/presentation/dto/step.js +2 -2
- package/dist/presentation/dto/step.js.map +1 -1
- package/dist/presentation/dto/workflow-run.d.ts +3 -1
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -1
- package/dist/presentation/dto/workflow-run.js +34 -0
- package/dist/presentation/dto/workflow-run.js.map +1 -1
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +31 -3
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts +1 -1
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +32 -20
- package/dist/presentation/routes/checkout-token.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 +2 -1
- package/dist/presentation/routes/leased-step.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js +9 -3
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/presentation/routes/report-step.d.ts.map +1 -1
- package/dist/presentation/routes/report-step.js +9 -2
- package/dist/presentation/routes/report-step.js.map +1 -1
- package/dist/presentation/subscribers/on-job-steps-settled.js +1 -1
- package/dist/presentation/subscribers/on-job-steps-settled.js.map +1 -1
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts.map +1 -1
- package/dist/presentation/subscribers/on-runner-job-claimed.js +21 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js.map +1 -1
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js +2 -1
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +1 -0
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/temporal/constants.d.ts +1 -0
- package/dist/temporal/constants.d.ts.map +1 -1
- package/dist/temporal/constants.js +1 -0
- package/dist/temporal/constants.js.map +1 -1
- package/dist/temporal/index.d.ts +1 -1
- package/dist/temporal/index.d.ts.map +1 -1
- package/dist/temporal/index.js +1 -1
- package/dist/temporal/index.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +82 -43
- package/dist/temporal/workflows/index.d.ts +1 -1
- package/dist/temporal/workflows/index.d.ts.map +1 -1
- package/dist/temporal/workflows/index.js +1 -1
- package/dist/temporal/workflows/index.js.map +1 -1
- package/dist/temporal/workflows/job-execution-orchestration.d.ts +5 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -1
- package/dist/temporal/workflows/job-execution-orchestration.js +77 -43
- package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -1
- package/dist/temporal/workflows/test-env.d.ts +5 -1
- package/dist/temporal/workflows/test-env.d.ts.map +1 -1
- package/dist/temporal/workflows/test-env.js +32 -11
- package/dist/temporal/workflows/test-env.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0000_initial.sql +14 -2
- package/drizzle/0001_windy_sunfire.sql +1 -0
- package/drizzle/meta/0000_snapshot.json +93 -1
- package/drizzle/meta/0001_snapshot.json +1711 -0
- package/drizzle/meta/_journal.json +2 -2
- package/package.json +19 -19
- package/src/core/agent-defaults.ts +2 -1
- package/src/core/checkout.test.ts +378 -67
- package/src/core/checkout.ts +142 -59
- package/src/core/entities/job-execution.test.ts +21 -0
- package/src/core/entities/job-execution.ts +24 -0
- package/src/core/entities/job-listener-event.ts +3 -0
- package/src/core/entities/step.ts +15 -3
- package/src/core/entities/workflow-run-attempt.ts +1 -0
- package/src/core/entities/workflow-run.ts +16 -0
- package/src/core/errors.ts +21 -7
- package/src/core/job-execution.ts +27 -4
- package/src/core/job-transition/decide-job-activation.test.ts +4 -0
- package/src/core/job-transition/decide-job-activation.ts +2 -0
- package/src/core/job-transition/derive-job-success.test.ts +12 -0
- package/src/core/job-transition/derive-job-success.ts +6 -9
- package/src/core/listener-execution-materialization.test.ts +2 -0
- package/src/core/listener-execution-materialization.ts +57 -11
- package/src/core/resolve-trigger-reference.test.ts +160 -0
- package/src/core/resolve-trigger-reference.ts +53 -0
- package/src/core/run-workflow.ts +2 -0
- package/src/core/step-config/agent.ts +29 -12
- package/src/core/step-config/assemble-run-context.test.ts +149 -6
- package/src/core/step-config/assemble-run-context.ts +87 -25
- package/src/core/step-config/complete-step-dispatch-config.test.ts +125 -2
- package/src/core/step-config/complete-step-dispatch-config.ts +83 -1
- package/src/core/step-config/index.ts +7 -0
- package/src/core/step-config/materialize-job-execution-steps.test.ts +250 -1
- package/src/core/step-config/materialize-job-execution-steps.ts +57 -10
- package/src/core/step-config/materialize-workflow-model.test.ts +212 -4
- package/src/core/step-config/materialize-workflow-model.ts +33 -28
- package/src/core/step-config/resolve-job-execution-name.test.ts +37 -15
- package/src/core/step-config/resolve-job-execution-name.ts +30 -15
- package/src/core/step-config/resolve-step-config.ts +175 -10
- package/src/core/step-config/resolve-workflow-run-name.test.ts +115 -0
- package/src/core/step-config/resolve-workflow-run-name.ts +108 -0
- package/src/core/step-transition/decide-step-transition.ts +2 -2
- package/src/core/step-transition/evaluate-gate.test.ts +8 -0
- package/src/core/step-transition/evaluate-gate.ts +8 -1
- package/src/core/workflow-run-creation.test.ts +7 -4
- package/src/core/workflow-run-creation.ts +13 -7
- package/src/db/db.ts +2 -0
- package/src/db/index.ts +6 -0
- package/src/db/job-listener-events.test.ts +19 -0
- package/src/db/job-listener-events.ts +3 -0
- package/src/db/job-listeners.test.ts +187 -5
- package/src/db/job-listeners.ts +122 -30
- package/src/db/schema/job-executions.ts +12 -5
- package/src/db/schema/job-listener-events.ts +3 -0
- package/src/db/schema/step-attempts.ts +2 -2
- package/src/db/schema/steps.ts +2 -1
- package/src/db/schema/workflow-run-attempts.ts +2 -0
- package/src/db/schema/workflow-run-counters.ts +13 -0
- package/src/db/schema/workflow-runs.ts +11 -2
- package/src/db/workflow-runs/job-executions.ts +37 -15
- package/src/db/workflow-runs/jobs.ts +17 -4
- package/src/db/workflow-runs/queries.test.ts +206 -0
- package/src/db/workflow-runs/queries.ts +146 -2
- package/src/db/workflow-runs/run-create.test.ts +606 -8
- package/src/db/workflow-runs/run-create.ts +185 -40
- package/src/db/workflow-runs/run-rerun.test.ts +61 -2
- package/src/db/workflow-runs/run-rerun.ts +15 -5
- package/src/db/workflow-runs/shared.ts +2 -0
- package/src/db/workflow-runs/steps.ts +3 -3
- package/src/db/workflow-runs.ts +7 -0
- package/src/metrics/instance.ts +14 -0
- package/src/presentation/dto/checkout-token.test.ts +19 -9
- package/src/presentation/dto/checkout-token.ts +2 -1
- package/src/presentation/dto/index.ts +1 -1
- package/src/presentation/dto/job.test.ts +9 -0
- package/src/presentation/dto/step.test.ts +12 -0
- package/src/presentation/dto/step.ts +5 -2
- package/src/presentation/dto/workflow-run.ts +44 -2
- package/src/presentation/inter-module.test.ts +165 -0
- package/src/presentation/inter-module.ts +38 -4
- package/src/presentation/routes/checkout-token.test.ts +357 -142
- package/src/presentation/routes/checkout-token.ts +56 -26
- package/src/presentation/routes/get-run.test.ts +2 -0
- package/src/presentation/routes/get-step-secrets.test.ts +7 -2
- package/src/presentation/routes/leased-step.ts +9 -1
- package/src/presentation/routes/list-runs.test.ts +57 -0
- package/src/presentation/routes/list-runs.ts +8 -3
- package/src/presentation/routes/report-step.test.ts +25 -0
- package/src/presentation/routes/report-step.ts +10 -2
- package/src/presentation/subscribers/on-job-steps-settled.ts +1 -1
- package/src/presentation/subscribers/on-runner-job-claimed.test.ts +49 -0
- package/src/presentation/subscribers/on-runner-job-claimed.ts +22 -0
- package/src/temporal/activities/index.ts +1 -0
- package/src/temporal/activities/orchestration-activities.ts +1 -0
- package/src/temporal/constants.ts +1 -0
- package/src/temporal/index.ts +1 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/src/temporal/workflows/job-execution-orchestration.test.ts +142 -6
- package/src/temporal/workflows/job-execution-orchestration.ts +99 -50
- package/src/temporal/workflows/run-orchestration.test.ts +1 -1
- package/src/temporal/workflows/test-env.ts +50 -13
- package/test/factories/project.ts +2 -0
- package/test/factories/workflow-model.ts +80 -26
- package/test/factories/workflow-run.ts +4 -1
- package/test/fixtures/agent-inter-module.ts +2 -1
- package/test/fixtures/job-with-steps.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/drizzle/0001_agent_tool_materialization.sql +0 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_JOB_CHECKOUT,
|
|
4
|
+
type WorkflowFieldTemplate,
|
|
5
|
+
type WorkflowModel,
|
|
6
|
+
} from '@shipfox/api-definitions-dto';
|
|
7
|
+
import {parseWorkflowTemplate, planInterpolationField} from '@shipfox/expression';
|
|
3
8
|
import {createInterModuleKnownError} from '@shipfox/inter-module';
|
|
4
9
|
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
5
10
|
import {AgentConfigUnresolvableError, InterpolationUnresolvableError} from '#core/errors.js';
|
|
@@ -30,6 +35,15 @@ function template(source: string): string {
|
|
|
30
35
|
return `\${{ ${source} }}`;
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
function checkoutTemplate(
|
|
39
|
+
field: 'checkout.repository' | 'checkout.ref',
|
|
40
|
+
source: string,
|
|
41
|
+
): WorkflowFieldTemplate {
|
|
42
|
+
const result = planInterpolationField({field, segments: parseWorkflowTemplate(source)});
|
|
43
|
+
if (!result.ok) throw new Error(`Expected valid checkout template for ${field}`);
|
|
44
|
+
return result.plan.field.segments;
|
|
45
|
+
}
|
|
46
|
+
|
|
33
47
|
function shellRef(name: string): string {
|
|
34
48
|
return `\${${name}}`;
|
|
35
49
|
}
|
|
@@ -58,6 +72,28 @@ function creationContext(
|
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
describe('materializeWorkflowModel', () => {
|
|
75
|
+
it('keeps literal job names in runtime jobs', async () => {
|
|
76
|
+
const model = workflowModel({
|
|
77
|
+
jobs: {
|
|
78
|
+
deploy: {
|
|
79
|
+
name: 'Deploy',
|
|
80
|
+
steps: [{run: 'echo deploy'}],
|
|
81
|
+
},
|
|
82
|
+
review: {
|
|
83
|
+
name: 'Review',
|
|
84
|
+
steps: [{run: 'echo review'}],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const rows = await materializeWorkflowModel({model});
|
|
90
|
+
const deploy = rows.find((job) => job.key === 'deploy');
|
|
91
|
+
const review = rows.find((job) => job.key === 'review');
|
|
92
|
+
|
|
93
|
+
expect(deploy).toMatchObject({key: 'deploy', name: 'Deploy'});
|
|
94
|
+
expect(review).toMatchObject({key: 'review', name: 'Review'});
|
|
95
|
+
});
|
|
96
|
+
|
|
61
97
|
it('converts workflow model jobs and steps to runtime rows', async () => {
|
|
62
98
|
const model = workflowModel({
|
|
63
99
|
runner: 'ubuntu-latest',
|
|
@@ -96,7 +132,12 @@ describe('materializeWorkflowModel', () => {
|
|
|
96
132
|
sourceLocation: null,
|
|
97
133
|
status: 'pending',
|
|
98
134
|
type: 'setup',
|
|
99
|
-
config: {
|
|
135
|
+
config: {
|
|
136
|
+
checkout: {
|
|
137
|
+
permissions: {contents: 'read'},
|
|
138
|
+
persist_credentials: true,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
100
141
|
authoredConfig: null,
|
|
101
142
|
position: 0,
|
|
102
143
|
};
|
|
@@ -441,7 +482,12 @@ describe('materializeWorkflowModel', () => {
|
|
|
441
482
|
|
|
442
483
|
const rows = await materializeWorkflowModel({model});
|
|
443
484
|
|
|
444
|
-
expect(rows[0]?.steps[0]?.config).toEqual({
|
|
485
|
+
expect(rows[0]?.steps[0]?.config).toEqual({
|
|
486
|
+
checkout: {
|
|
487
|
+
permissions: {contents: 'read'},
|
|
488
|
+
persist_credentials: true,
|
|
489
|
+
},
|
|
490
|
+
});
|
|
445
491
|
expect(rows[0]?.steps[1]?.config).toEqual({
|
|
446
492
|
run: 'npm test',
|
|
447
493
|
env: {
|
|
@@ -573,6 +619,163 @@ describe('materializeWorkflowModel', () => {
|
|
|
573
619
|
});
|
|
574
620
|
});
|
|
575
621
|
|
|
622
|
+
it('resolves working directories for run and agent steps', async () => {
|
|
623
|
+
const model = workflowModel({
|
|
624
|
+
jobs: {
|
|
625
|
+
build: {
|
|
626
|
+
steps: [
|
|
627
|
+
{run: 'npm test', workingDirectory: 'packages/api'},
|
|
628
|
+
{prompt: 'Review the changes', workingDirectory: template('run.id')},
|
|
629
|
+
],
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
const rows = await materializeWorkflowModel({model, context: creationContext()});
|
|
635
|
+
|
|
636
|
+
expect(rows[0]?.steps[1]?.config).toEqual({
|
|
637
|
+
run: 'npm test',
|
|
638
|
+
working_directory: 'packages/api',
|
|
639
|
+
});
|
|
640
|
+
expect(rows[0]?.steps[2]?.config).toMatchObject({
|
|
641
|
+
harness: 'pi',
|
|
642
|
+
prompt: 'Review the changes',
|
|
643
|
+
working_directory: 'run-1',
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
it('defers unresolved working directory templates until step dispatch', async () => {
|
|
648
|
+
const model = workflowModel({
|
|
649
|
+
jobs: {
|
|
650
|
+
build: {
|
|
651
|
+
steps: [{run: 'npm test', workingDirectory: template('steps.previous.outputs.path')}],
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
const rows = await materializeWorkflowModel({model, context: creationContext()});
|
|
657
|
+
|
|
658
|
+
expect(rows[0]?.steps[1]?.config).toEqual({run: 'npm test'});
|
|
659
|
+
expect(rows[0]?.steps[1]?.configPlan?.working_directory).toEqual({
|
|
660
|
+
segments: [
|
|
661
|
+
{
|
|
662
|
+
kind: 'deferred',
|
|
663
|
+
expression: {
|
|
664
|
+
language: 'cel',
|
|
665
|
+
source: 'steps.previous.outputs.path',
|
|
666
|
+
check: 'syntax',
|
|
667
|
+
},
|
|
668
|
+
fillTarget: 'step-dispatch',
|
|
669
|
+
roots: ['steps'],
|
|
670
|
+
},
|
|
671
|
+
],
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
it('defers checkout target templates until step dispatch', async () => {
|
|
676
|
+
const repository = template('steps.previous.outputs.repository');
|
|
677
|
+
const ref = template('steps.previous.outputs.ref');
|
|
678
|
+
const model = workflowModel({
|
|
679
|
+
jobs: {
|
|
680
|
+
build: {
|
|
681
|
+
steps: [
|
|
682
|
+
{
|
|
683
|
+
checkout: {
|
|
684
|
+
repository,
|
|
685
|
+
ref,
|
|
686
|
+
fetchDepth: 1,
|
|
687
|
+
permissions: {contents: 'read'},
|
|
688
|
+
persistCredentials: true,
|
|
689
|
+
templates: {
|
|
690
|
+
repository: checkoutTemplate('checkout.repository', repository),
|
|
691
|
+
ref: checkoutTemplate('checkout.ref', ref),
|
|
692
|
+
},
|
|
693
|
+
},
|
|
694
|
+
},
|
|
695
|
+
],
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
const rows = await materializeWorkflowModel({model, context: creationContext()});
|
|
701
|
+
|
|
702
|
+
expect(rows[0]?.steps[1]?.config).toEqual({
|
|
703
|
+
checkout: {
|
|
704
|
+
fetch_depth: 1,
|
|
705
|
+
path: '.',
|
|
706
|
+
permissions: {contents: 'read'},
|
|
707
|
+
persist_credentials: true,
|
|
708
|
+
},
|
|
709
|
+
});
|
|
710
|
+
expect(rows[0]?.steps[1]?.authoredConfig).toEqual({
|
|
711
|
+
checkout: {
|
|
712
|
+
repository,
|
|
713
|
+
ref,
|
|
714
|
+
fetch_depth: 1,
|
|
715
|
+
permissions: {contents: 'read'},
|
|
716
|
+
persist_credentials: true,
|
|
717
|
+
},
|
|
718
|
+
});
|
|
719
|
+
expect(rows[0]?.steps[1]?.configPlan?.checkout).toEqual({
|
|
720
|
+
repository: {
|
|
721
|
+
segments: [
|
|
722
|
+
expect.objectContaining({
|
|
723
|
+
kind: 'deferred',
|
|
724
|
+
roots: ['steps'],
|
|
725
|
+
fillTarget: 'step-dispatch',
|
|
726
|
+
}),
|
|
727
|
+
],
|
|
728
|
+
},
|
|
729
|
+
ref: {
|
|
730
|
+
segments: [
|
|
731
|
+
expect.objectContaining({
|
|
732
|
+
kind: 'deferred',
|
|
733
|
+
roots: ['steps'],
|
|
734
|
+
fillTarget: 'step-dispatch',
|
|
735
|
+
}),
|
|
736
|
+
],
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
it('defers unresolved thinking templates until step dispatch', async () => {
|
|
742
|
+
const model = workflowModel({
|
|
743
|
+
jobs: {
|
|
744
|
+
build: {
|
|
745
|
+
steps: [
|
|
746
|
+
{
|
|
747
|
+
harness: 'pi',
|
|
748
|
+
prompt: 'Review the change.',
|
|
749
|
+
thinking: template('steps.previous.outputs.thinking'),
|
|
750
|
+
},
|
|
751
|
+
],
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
const rows = await materializeWorkflowModel({model, context: creationContext()});
|
|
757
|
+
|
|
758
|
+
expect(rows[0]?.steps[1]?.config).toEqual({});
|
|
759
|
+
expect(rows[0]?.steps[1]?.configPlan?.agent).toMatchObject({
|
|
760
|
+
harness: 'pi',
|
|
761
|
+
prompt: {segments: [{kind: 'literal', value: 'Review the change.'}]},
|
|
762
|
+
thinking: {
|
|
763
|
+
segments: [
|
|
764
|
+
{
|
|
765
|
+
kind: 'deferred',
|
|
766
|
+
expression: {
|
|
767
|
+
language: 'cel',
|
|
768
|
+
source: 'steps.previous.outputs.thinking',
|
|
769
|
+
check: 'syntax',
|
|
770
|
+
},
|
|
771
|
+
fillTarget: 'step-dispatch',
|
|
772
|
+
roots: ['steps'],
|
|
773
|
+
},
|
|
774
|
+
],
|
|
775
|
+
},
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
|
|
576
779
|
it('merges env before resolving and only resolves the winning values', async () => {
|
|
577
780
|
const model = workflowModel({
|
|
578
781
|
env: {SHARED: template('event.missing'), WORKFLOW_ONLY: template('run.id')},
|
|
@@ -1084,7 +1287,12 @@ describe('materializeWorkflowModel', () => {
|
|
|
1084
1287
|
sourceLocation: null,
|
|
1085
1288
|
status: 'pending',
|
|
1086
1289
|
type: 'setup',
|
|
1087
|
-
config: {
|
|
1290
|
+
config: {
|
|
1291
|
+
checkout: {
|
|
1292
|
+
permissions: {contents: 'read'},
|
|
1293
|
+
persist_credentials: true,
|
|
1294
|
+
},
|
|
1295
|
+
},
|
|
1088
1296
|
authoredConfig: null,
|
|
1089
1297
|
position: 0,
|
|
1090
1298
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import {DEFAULT_JOB_CHECKOUT, type WorkflowModel} from '@shipfox/api-definitions-dto';
|
|
2
2
|
import {canonicalizeLabels, findInvalidLabels, MAX_RUNNER_LABELS} from '@shipfox/runner-labels';
|
|
3
3
|
import type {AgentDefaultsResolver} from '#core/agent-defaults.js';
|
|
4
4
|
import type {
|
|
@@ -19,9 +19,9 @@ export interface MaterializedWorkflowJob {
|
|
|
19
19
|
readonly mode: WorkflowModelJob['mode'];
|
|
20
20
|
readonly success?: string;
|
|
21
21
|
readonly executionTimeoutMs?: number;
|
|
22
|
-
readonly checkout: WorkflowModelJob['checkout']
|
|
22
|
+
readonly checkout: Exclude<WorkflowModelJob['checkout'], false>;
|
|
23
23
|
readonly listening?: WorkflowModelJob['listening'];
|
|
24
|
-
readonly name?:
|
|
24
|
+
readonly name?: string;
|
|
25
25
|
readonly outputs?: WorkflowModelJob['outputs'];
|
|
26
26
|
readonly dependencies: readonly string[];
|
|
27
27
|
readonly runner: readonly string[];
|
|
@@ -52,31 +52,36 @@ export async function materializeWorkflowModel(
|
|
|
52
52
|
const jobsById = new Map(model.jobs.map((job) => [job.id, job]));
|
|
53
53
|
|
|
54
54
|
return await Promise.all(
|
|
55
|
-
model.jobs.map(async (job, position) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
job
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
model.jobs.map(async (job, position) => {
|
|
56
|
+
const name = job.name;
|
|
57
|
+
return {
|
|
58
|
+
key: job.key,
|
|
59
|
+
mode: job.mode,
|
|
60
|
+
...(job.success === undefined ? {} : {success: job.success}),
|
|
61
|
+
...(job.executionTimeoutMs === undefined
|
|
62
|
+
? {}
|
|
63
|
+
: {executionTimeoutMs: job.executionTimeoutMs}),
|
|
64
|
+
checkout: job.checkout === false ? DEFAULT_JOB_CHECKOUT : job.checkout,
|
|
65
|
+
...(job.listening === undefined ? {} : {listening: job.listening}),
|
|
66
|
+
...(name === undefined ? {} : {name}),
|
|
67
|
+
...(job.outputs === undefined ? {} : {outputs: job.outputs}),
|
|
68
|
+
dependencies: dependencySourceNames(job, jobsById),
|
|
69
|
+
runner: job.runner,
|
|
70
|
+
position,
|
|
71
|
+
steps:
|
|
72
|
+
job.mode === 'listening'
|
|
73
|
+
? []
|
|
74
|
+
: await materializeJobExecutionSteps({
|
|
75
|
+
model,
|
|
76
|
+
job,
|
|
77
|
+
context,
|
|
78
|
+
resolveAgentDefaults,
|
|
79
|
+
definitionId,
|
|
80
|
+
agentToolContext,
|
|
81
|
+
agentToolSnapshot,
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}),
|
|
80
85
|
);
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -6,11 +6,11 @@ function template(source: string): string {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
describe('resolveJobExecutionName', () => {
|
|
9
|
-
it('resolves an interpolated
|
|
9
|
+
it('resolves an interpolated execution name at execution creation', () => {
|
|
10
10
|
const [job] = workflowModel({
|
|
11
11
|
jobs: {
|
|
12
12
|
deploy: {
|
|
13
|
-
|
|
13
|
+
executionName: `Deploy ${template('inputs.environment')}`,
|
|
14
14
|
steps: [{run: 'echo deploy'}],
|
|
15
15
|
},
|
|
16
16
|
},
|
|
@@ -20,18 +20,17 @@ describe('resolveJobExecutionName', () => {
|
|
|
20
20
|
const result = resolveJobExecutionName({
|
|
21
21
|
definitionId: 'definition-1',
|
|
22
22
|
job,
|
|
23
|
-
fallbackName: 'deploy #1',
|
|
24
23
|
context: {inputs: {environment: 'prod'}},
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
expect(result).toMatchObject({
|
|
28
|
-
|
|
27
|
+
nameOverride: 'Deploy prod',
|
|
29
28
|
trace: [
|
|
30
29
|
{
|
|
31
|
-
field: 'job.
|
|
30
|
+
field: 'job.execution_name',
|
|
32
31
|
expression: 'inputs.environment',
|
|
33
32
|
roots: ['inputs'],
|
|
34
|
-
fillTarget: '
|
|
33
|
+
fillTarget: 'execution-creation',
|
|
35
34
|
evaluatedAt: 'execution-creation',
|
|
36
35
|
value: 'prod',
|
|
37
36
|
},
|
|
@@ -43,7 +42,7 @@ describe('resolveJobExecutionName', () => {
|
|
|
43
42
|
const [job] = workflowModel({
|
|
44
43
|
jobs: {
|
|
45
44
|
deploy: {
|
|
46
|
-
|
|
45
|
+
executionName: template('inputs.environment'),
|
|
47
46
|
steps: [{run: 'echo deploy'}],
|
|
48
47
|
},
|
|
49
48
|
},
|
|
@@ -53,18 +52,17 @@ describe('resolveJobExecutionName', () => {
|
|
|
53
52
|
const result = resolveJobExecutionName({
|
|
54
53
|
definitionId: 'definition-1',
|
|
55
54
|
job,
|
|
56
|
-
fallbackName: 'deploy #1',
|
|
57
55
|
context: {inputs: {environment: ''}},
|
|
58
56
|
});
|
|
59
57
|
|
|
60
58
|
expect(result).toMatchObject({
|
|
61
|
-
|
|
59
|
+
nameOverride: null,
|
|
62
60
|
trace: [
|
|
63
61
|
{
|
|
64
|
-
field: 'job.
|
|
62
|
+
field: 'job.execution_name',
|
|
65
63
|
expression: 'inputs.environment',
|
|
66
64
|
roots: ['inputs'],
|
|
67
|
-
fillTarget: '
|
|
65
|
+
fillTarget: 'execution-creation',
|
|
68
66
|
evaluatedAt: 'execution-creation',
|
|
69
67
|
value: '',
|
|
70
68
|
},
|
|
@@ -72,10 +70,26 @@ describe('resolveJobExecutionName', () => {
|
|
|
72
70
|
});
|
|
73
71
|
});
|
|
74
72
|
|
|
75
|
-
it('falls back
|
|
73
|
+
it('falls back to the static job name when no execution name template exists', () => {
|
|
74
|
+
const [job] = workflowModel({
|
|
75
|
+
jobs: {deploy: {steps: [{run: 'echo deploy'}]}},
|
|
76
|
+
}).jobs;
|
|
77
|
+
if (!job) throw new Error('Missing deploy job');
|
|
78
|
+
|
|
79
|
+
const result = resolveJobExecutionName({
|
|
80
|
+
definitionId: 'definition-1',
|
|
81
|
+
job,
|
|
82
|
+
context: {},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(result).toEqual({nameOverride: null, trace: []});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('falls back when execution-name evaluation fails', () => {
|
|
76
89
|
const [job] = workflowModel({
|
|
77
90
|
jobs: {
|
|
78
91
|
deploy: {
|
|
92
|
+
executionName: template('inputs.environment.missing'),
|
|
79
93
|
steps: [{run: 'echo deploy'}],
|
|
80
94
|
},
|
|
81
95
|
},
|
|
@@ -85,10 +99,18 @@ describe('resolveJobExecutionName', () => {
|
|
|
85
99
|
const result = resolveJobExecutionName({
|
|
86
100
|
definitionId: 'definition-1',
|
|
87
101
|
job,
|
|
88
|
-
|
|
89
|
-
context: {},
|
|
102
|
+
context: {inputs: null},
|
|
90
103
|
});
|
|
91
104
|
|
|
92
|
-
expect(result).
|
|
105
|
+
expect(result).toMatchObject({
|
|
106
|
+
nameOverride: null,
|
|
107
|
+
trace: [
|
|
108
|
+
expect.objectContaining({
|
|
109
|
+
field: 'job.execution_name',
|
|
110
|
+
expression: 'inputs.environment.missing',
|
|
111
|
+
degraded: true,
|
|
112
|
+
}),
|
|
113
|
+
],
|
|
114
|
+
});
|
|
93
115
|
});
|
|
94
116
|
});
|
|
@@ -1,50 +1,65 @@
|
|
|
1
1
|
import type {WorkflowModel} from '@shipfox/api-definitions-dto';
|
|
2
2
|
import {
|
|
3
3
|
capTraceEntries,
|
|
4
|
+
evaluationTraceEntry,
|
|
4
5
|
getWorkflowInterpolationFieldFailurePolicy,
|
|
5
6
|
resolveFieldAtSite,
|
|
6
7
|
type WorkflowExpressionEvaluationContext,
|
|
7
8
|
WorkflowTemplateResolutionError,
|
|
8
9
|
} from '@shipfox/expression';
|
|
9
10
|
import type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';
|
|
10
|
-
import {InterpolationUnresolvableError} from '#core/errors.js';
|
|
11
11
|
|
|
12
12
|
interface WorkflowModelJobName {
|
|
13
|
-
readonly
|
|
13
|
+
readonly executionName?: WorkflowModel['jobs'][number]['executionName'] | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface ResolveJobExecutionNameParams {
|
|
17
17
|
readonly definitionId: string;
|
|
18
18
|
readonly job: WorkflowModelJobName;
|
|
19
|
-
readonly fallbackName: string;
|
|
20
19
|
readonly context: WorkflowExpressionEvaluationContext;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export function resolveJobExecutionName(params: ResolveJobExecutionNameParams): {
|
|
24
|
-
|
|
23
|
+
/** The resolved override to persist. The static fallback is deliberately not persisted. */
|
|
24
|
+
readonly nameOverride: string | null;
|
|
25
25
|
readonly trace: readonly PersistedEvaluationTraceEntry[];
|
|
26
26
|
} {
|
|
27
|
-
if (params.job.
|
|
27
|
+
if (params.job.executionName === undefined) return {nameOverride: null, trace: []};
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
30
|
const resolved = resolveFieldAtSite({
|
|
31
|
-
field: {segments: params.job.
|
|
31
|
+
field: {segments: params.job.executionName},
|
|
32
32
|
site: 'execution-creation',
|
|
33
33
|
context: params.context,
|
|
34
|
-
failurePolicy: getWorkflowInterpolationFieldFailurePolicy('job.
|
|
34
|
+
failurePolicy: getWorkflowInterpolationFieldFailurePolicy('job.execution_name'),
|
|
35
35
|
});
|
|
36
36
|
return {
|
|
37
|
-
value:
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
nameOverride: resolved.kind === 'frozen' && resolved.value !== '' ? resolved.value : null,
|
|
38
|
+
trace: capTraceEntries(
|
|
39
|
+
resolved.trace.map((entry) => ({...entry, field: 'job.execution_name'})),
|
|
40
|
+
),
|
|
40
41
|
};
|
|
41
42
|
} catch (error) {
|
|
42
43
|
if (error instanceof WorkflowTemplateResolutionError) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const failedSegment = params.job.executionName.find(
|
|
45
|
+
(segment) => segment.kind === 'deferred' && segment.expression.source === error.source,
|
|
46
|
+
);
|
|
47
|
+
const trace =
|
|
48
|
+
failedSegment?.kind === 'deferred'
|
|
49
|
+
? [
|
|
50
|
+
{
|
|
51
|
+
...evaluationTraceEntry({
|
|
52
|
+
expression: failedSegment.expression.source,
|
|
53
|
+
roots: failedSegment.roots,
|
|
54
|
+
fillTarget: failedSegment.fillTarget,
|
|
55
|
+
evaluatedAt: 'execution-creation',
|
|
56
|
+
degraded: true,
|
|
57
|
+
}),
|
|
58
|
+
field: 'job.execution_name',
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
: [];
|
|
62
|
+
return {nameOverride: null, trace: capTraceEntries(trace)};
|
|
48
63
|
}
|
|
49
64
|
throw error;
|
|
50
65
|
}
|