-
Notifications
You must be signed in to change notification settings - Fork 642
workflows: rollback types #6766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { | |||||||||||||||||||
| RpcTarget, | ||||||||||||||||||||
| WorkerEntrypoint, | ||||||||||||||||||||
| } from 'cloudflare:workers'; | ||||||||||||||||||||
| import type {WorkflowStep} from 'cloudflare:workers'; | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this import could be merged with the block above using inline
Suggested change
|
||||||||||||||||||||
| import { expectTypeOf } from 'expect-type'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Check `cache` export from `cloudflare:workers` has the expected type. | ||||||||||||||||||||
|
|
@@ -794,3 +795,29 @@ export default <ExportedHandler<Env>>{ | |||||||||||||||||||
| return new Response(); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| declare const workflowStep: WorkflowStep; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| expectTypeOf( | ||||||||||||||||||||
| workflowStep.do('step with rollback', async (): Promise<string> => 'ok', { | ||||||||||||||||||||
| rollback: async (ctx) => { | ||||||||||||||||||||
| expectTypeOf(ctx.error).toEqualTypeOf<Error>(); | ||||||||||||||||||||
| expectTypeOf(ctx.output).toEqualTypeOf<string | undefined>(); | ||||||||||||||||||||
| expectTypeOf(ctx.stepName).toEqualTypeOf<string>(); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| ).toMatchTypeOf<Promise<string>>(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| workflowStep.do( | ||||||||||||||||||||
| 'configured rollback', | ||||||||||||||||||||
| {retries: {limit: 0, delay: 0}}, | ||||||||||||||||||||
| async (): Promise<string> => 'ok', | ||||||||||||||||||||
| { | ||||||||||||||||||||
| rollback: async (ctx) => { | ||||||||||||||||||||
| expectTypeOf(ctx.output).toEqualTypeOf<string | undefined>(); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| rollbackConfig: {retries: {limit: 0, delay: 0}}, | ||||||||||||||||||||
| } | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| workflowStep.do('empty rollback options', async () => 'ok', {}); | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding tests without any rollback options to verify backward compatibility of the existing overloads:
Suggested change
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.