Skip to content

Commit b251fe1

Browse files
committed
fix(workflow-code): review round 2: judge a held deployments write against the whole apply
1 parent 0506f1f commit b251fe1

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎packages/sim-cli/src/commands/protocol/workspace-source-apply.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,33 @@ describe('workspaces source apply', () => {
22642264
})
22652265
})
22662266

2267+
it('exits as written in part when the deployments write holds every deployment back', async () => {
2268+
request.mockImplementation(async (path: string, options: { body?: { kinds?: string[] } }) => {
2269+
if (path === '/api/v2/workflows/wf_1/deployment') return deploymentStatus(1)
2270+
const base = { ...BASE, resources: { 'workflow:ingest': { id: 'wf_1' } } }
2271+
return options.body?.kinds?.includes('deployment')
2272+
? answer({
2273+
plan: [{ kind: 'deployment', key: 'ingest', action: 'update', held: true }],
2274+
applied: [],
2275+
base,
2276+
})
2277+
: answer({
2278+
plan: [{ kind: 'workflow', key: 'ingest', action: 'update' }],
2279+
applied: [{ kind: 'workflow', key: 'ingest', action: 'update' }],
2280+
files: { 'workflows/ingest/workflow.ts': `${INGEST}// stored\n` },
2281+
base,
2282+
})
2283+
})
2284+
contextMockFns.mockRequestRaw.mockResolvedValue(
2285+
runAnswer({ status: 'completed', output: {} })
2286+
)
2287+
2288+
await apply('--yes', '--run', 'ingest={}')
2289+
2290+
expect(applies()).toHaveLength(2)
2291+
expect(process.exitCode).toBe(15)
2292+
})
2293+
22672294
it('holds back a managed deployments/ with no files left (its undeploys) until the runs complete', async () => {
22682295
unlinkSync(join(dir, 'deployments/ingest.ts'))
22692296
write('deployments/.gitkeep', '')

‎packages/sim-cli/src/commands/protocol/workspace-source-apply.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,11 @@ export function attachWorkspaceSourceApply(source: Command): void {
10761076
})
10771077
})
10781078
if (!deployed) return
1079-
settle({ ...deployed, plan: deployed.plan.filter(isDeployment) })
1080-
await finish(mergedApply(data, deployed))
1079+
const merged = mergedApply(data, deployed)
1080+
// Judged against the whole apply: held deployments after written workflows are a
1081+
// partial write, not nothing written.
1082+
settle({ ...merged, plan: deployed.plan.filter(isDeployment) })
1083+
await finish(merged)
10811084
},
10821085
{ readOnly: mode === 'dry' || mode === 'plan' }
10831086
)

0 commit comments

Comments
 (0)