From fc544bc5ddc77d5b6f39b275d268557f7f549f0c Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Tue, 29 Oct 2024 15:41:21 +0000 Subject: [PATCH 01/14] Added pause and resume commands to manage Workflows --- .changeset/violet-zoos-obey.md | 5 ++ .../src/workflows/commands/instances/list.ts | 2 +- .../src/workflows/commands/instances/pause.ts | 68 +++++++++++++++++++ .../workflows/commands/instances/resume.ts | 68 +++++++++++++++++++ packages/wrangler/src/workflows/index.ts | 2 + 5 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 .changeset/violet-zoos-obey.md create mode 100644 packages/wrangler/src/workflows/commands/instances/pause.ts create mode 100644 packages/wrangler/src/workflows/commands/instances/resume.ts diff --git a/.changeset/violet-zoos-obey.md b/.changeset/violet-zoos-obey.md new file mode 100644 index 000000000000..0b01aeab2a8f --- /dev/null +++ b/.changeset/violet-zoos-obey.md @@ -0,0 +1,5 @@ +--- +"wrangler": minor +--- + +Added pause and resume commands to manage Workflows diff --git a/packages/wrangler/src/workflows/commands/instances/list.ts b/packages/wrangler/src/workflows/commands/instances/list.ts index 8ad1166d41c7..0c27480d3114 100644 --- a/packages/wrangler/src/workflows/commands/instances/list.ts +++ b/packages/wrangler/src/workflows/commands/instances/list.ts @@ -9,7 +9,7 @@ defineCommand({ command: "wrangler workflows instances list", metadata: { - description: "Instance related commands (list, describe, terminate...)", + description: "Instance related commands (list, describe, terminate, pause, resume)", owner: "Product: Workflows", status: "open-beta", }, diff --git a/packages/wrangler/src/workflows/commands/instances/pause.ts b/packages/wrangler/src/workflows/commands/instances/pause.ts new file mode 100644 index 000000000000..0e3d194483e8 --- /dev/null +++ b/packages/wrangler/src/workflows/commands/instances/pause.ts @@ -0,0 +1,68 @@ +import { fetchResult } from "../../../cfetch"; +import { defineCommand } from "../../../core"; +import { logger } from "../../../logger"; +import { requireAuth } from "../../../user"; +import type { Instance } from "../../types"; + +defineCommand({ + command: "wrangler workflows instances pause", + + metadata: { + description: "Pause a workflow instance", + owner: "Product: Workflows", + status: "open-beta", + }, + + positionalArgs: ["name", "id"], + args: { + name: { + describe: "Name of the workflow", + type: "string", + demandOption: true, + }, + id: { + describe: + "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it", + type: "string", + demandOption: true, + }, + }, + + async handler(args, { config }) { + const accountId = await requireAuth(config); + + let id = args.id; + + if (id == "latest") { + const instances = ( + await fetchResult( + `/accounts/${accountId}/workflows/${args.name}/instances` + ) + ).sort((a, b) => b.created_on.localeCompare(a.created_on)); + + if (instances.length == 0) { + logger.error( + `There are no deployed instances in workflow "${args.name}"` + ); + return; + } + + id = instances[0].id; + } + + await fetchResult( + `/accounts/${accountId}/workflows/${args.name}/instances/${id}/status`, + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ status: "pause" }), + } + ); + + logger.info( + `⏸️ The instance "${id}" from ${args.name} was paused successfully` + ); + }, +}); diff --git a/packages/wrangler/src/workflows/commands/instances/resume.ts b/packages/wrangler/src/workflows/commands/instances/resume.ts new file mode 100644 index 000000000000..809fa632ca85 --- /dev/null +++ b/packages/wrangler/src/workflows/commands/instances/resume.ts @@ -0,0 +1,68 @@ +import { fetchResult } from "../../../cfetch"; +import { defineCommand } from "../../../core"; +import { logger } from "../../../logger"; +import { requireAuth } from "../../../user"; +import type { Instance } from "../../types"; + +defineCommand({ + command: "wrangler workflows instances resume", + + metadata: { + description: "Resume a workflow instance", + owner: "Product: Workflows", + status: "open-beta", + }, + + positionalArgs: ["name", "id"], + args: { + name: { + describe: "Name of the workflow", + type: "string", + demandOption: true, + }, + id: { + describe: + "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it", + type: "string", + demandOption: true, + }, + }, + + async handler(args, { config }) { + const accountId = await requireAuth(config); + + let id = args.id; + + if (id == "latest") { + const instances = ( + await fetchResult( + `/accounts/${accountId}/workflows/${args.name}/instances` + ) + ).sort((a, b) => b.created_on.localeCompare(a.created_on)); + + if (instances.length == 0) { + logger.error( + `There are no deployed instances in workflow "${args.name}"` + ); + return; + } + + id = instances[0].id; + } + + await fetchResult( + `/accounts/${accountId}/workflows/${args.name}/instances/${id}/status`, + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ status: "resume" }), + } + ); + + logger.info( + `πŸ”„ The instance "${id}" from ${args.name} was resumed successfully` + ); + }, +}); diff --git a/packages/wrangler/src/workflows/index.ts b/packages/wrangler/src/workflows/index.ts index 5a20e510d89c..f604a360cd94 100644 --- a/packages/wrangler/src/workflows/index.ts +++ b/packages/wrangler/src/workflows/index.ts @@ -6,6 +6,8 @@ import "./commands/trigger"; import "./commands/instances/list"; import "./commands/instances/describe"; import "./commands/instances/terminate"; +import "./commands/instances/pause"; +import "./commands/instances/resume"; defineNamespace({ command: "wrangler workflows", From 722cf14f454243e8630147cd22264054d9563246 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Tue, 29 Oct 2024 16:37:05 +0000 Subject: [PATCH 02/14] prettify check --- packages/wrangler/src/workflows/commands/instances/list.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/wrangler/src/workflows/commands/instances/list.ts b/packages/wrangler/src/workflows/commands/instances/list.ts index 0c27480d3114..0b8ee7dea143 100644 --- a/packages/wrangler/src/workflows/commands/instances/list.ts +++ b/packages/wrangler/src/workflows/commands/instances/list.ts @@ -9,7 +9,8 @@ defineCommand({ command: "wrangler workflows instances list", metadata: { - description: "Instance related commands (list, describe, terminate, pause, resume)", + description: + "Instance related commands (list, describe, terminate, pause, resume)", owner: "Product: Workflows", status: "open-beta", }, From 45495841bbeb9fd042735aa3dfe90b7e1b9aa925 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Tue, 29 Oct 2024 18:33:46 +0000 Subject: [PATCH 03/14] Update packages/wrangler/src/workflows/commands/instances/pause.ts Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> --- packages/wrangler/src/workflows/commands/instances/pause.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/workflows/commands/instances/pause.ts b/packages/wrangler/src/workflows/commands/instances/pause.ts index 0e3d194483e8..4c9bb05ebe21 100644 --- a/packages/wrangler/src/workflows/commands/instances/pause.ts +++ b/packages/wrangler/src/workflows/commands/instances/pause.ts @@ -22,7 +22,7 @@ defineCommand({ }, id: { describe: - "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it", + "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and pause it", type: "string", demandOption: true, }, From 0ccbb0c94b8e3297ac96ab58f34a041661e9a108 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Tue, 29 Oct 2024 18:33:51 +0000 Subject: [PATCH 04/14] Update packages/wrangler/src/workflows/commands/instances/resume.ts Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> --- packages/wrangler/src/workflows/commands/instances/resume.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/workflows/commands/instances/resume.ts b/packages/wrangler/src/workflows/commands/instances/resume.ts index 809fa632ca85..31b003617603 100644 --- a/packages/wrangler/src/workflows/commands/instances/resume.ts +++ b/packages/wrangler/src/workflows/commands/instances/resume.ts @@ -22,7 +22,7 @@ defineCommand({ }, id: { describe: - "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and describe it", + "ID of the instance - instead of an UUID you can type 'latest' to get the latest instance and resume it", type: "string", demandOption: true, }, From 56601ef4dd6c3527a773e50b5befef6d5517b4a6 Mon Sep 17 00:00:00 2001 From: emily-shen <69125074+emily-shen@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:40:19 +0000 Subject: [PATCH 05/14] add happy path test for `pause` --- .../wrangler/src/__tests__/workflows.test.ts | 84 +++++++++++++++++++ .../src/workflows/commands/instances/pause.ts | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 packages/wrangler/src/__tests__/workflows.test.ts diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts new file mode 100644 index 000000000000..1d0c67ff9940 --- /dev/null +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -0,0 +1,84 @@ +import { http, HttpResponse } from "msw"; +import { mockAccountId, mockApiToken } from "./helpers/mock-account-id"; +import { mockConsoleMethods } from "./helpers/mock-console"; +import { clearDialogs } from "./helpers/mock-dialogs"; +import { msw } from "./helpers/msw"; +import { runInTempDir } from "./helpers/run-in-tmp"; +import { runWrangler } from "./helpers/run-wrangler"; +import { writeWranglerToml } from "./helpers/write-wrangler-toml"; +import type { Instance } from "../workflows/types"; + +describe("wrangler workflows", () => { + const std = mockConsoleMethods(); + runInTempDir(); + mockAccountId(); + mockApiToken(); + afterEach(() => { + clearDialogs(); + }); + + describe("instances pause", () => { + const mockGetInstances = async (instances: Instance[]) => { + msw.use( + http.get( + `*/accounts/:accountId/workflows/some-workflow/instances`, + async () => { + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: instances, + }); + }, + { once: true } + ) + ); + }; + const mockPauseRequest = async (expectedInstance: string) => { + msw.use( + http.patch( + `*/accounts/:accountId/workflows/some-workflow/instances/:instanceId/status`, + async ({ params }) => { + expect(params.instanceId).toEqual(expectedInstance); + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: {}, + }); + }, + { once: true } + ) + ); + }; + + it("should get and pause the latest instance given a name", async () => { + writeWranglerToml(); + const mockInstances: Instance[] = [ + { + id: "earliest", + created_on: "2021-01-01T00:00:00Z", + modified_on: "2021-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + { + id: "latest", + created_on: "2022-01-01T00:00:00Z", + modified_on: "2022-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + ]; + await mockGetInstances(mockInstances); + await mockPauseRequest("latest"); + + await runWrangler(`workflows instances pause some-workflow latest`); + expect(std.out).toMatchInlineSnapshot( + `"⏸️ The instance \\"latest\\" from some-workflow was paused successfully"` + ); + }); + }); +}); diff --git a/packages/wrangler/src/workflows/commands/instances/pause.ts b/packages/wrangler/src/workflows/commands/instances/pause.ts index 4c9bb05ebe21..ab226ed80dbb 100644 --- a/packages/wrangler/src/workflows/commands/instances/pause.ts +++ b/packages/wrangler/src/workflows/commands/instances/pause.ts @@ -61,7 +61,7 @@ defineCommand({ } ); - logger.info( + logger.log( `⏸️ The instance "${id}" from ${args.name} was paused successfully` ); }, From cd6a34d916261896719d365477ebe3fdb5eba6a7 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Thu, 31 Oct 2024 17:03:09 +0000 Subject: [PATCH 06/14] added workflows cmds tests and fix delete not being implemented --- .../wrangler/src/__tests__/workflows.test.ts | 413 ++++++++++++++++-- .../wrangler/src/workflows/commands/delete.ts | 13 +- .../src/workflows/commands/instances/pause.ts | 2 +- 3 files changed, 384 insertions(+), 44 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 1d0c67ff9940..1ca24175eb3b 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -1,4 +1,5 @@ import { http, HttpResponse } from "msw"; +import { endEventLoop } from "./helpers/end-event-loop"; import { mockAccountId, mockApiToken } from "./helpers/mock-account-id"; import { mockConsoleMethods } from "./helpers/mock-console"; import { clearDialogs } from "./helpers/mock-dialogs"; @@ -6,7 +7,7 @@ import { msw } from "./helpers/msw"; import { runInTempDir } from "./helpers/run-in-tmp"; import { runWrangler } from "./helpers/run-wrangler"; import { writeWranglerToml } from "./helpers/write-wrangler-toml"; -import type { Instance } from "../workflows/types"; +import type { Instance, Workflow } from "../workflows/types"; describe("wrangler workflows", () => { const std = mockConsoleMethods(); @@ -17,34 +18,256 @@ describe("wrangler workflows", () => { clearDialogs(); }); - describe("instances pause", () => { - const mockGetInstances = async (instances: Instance[]) => { + const mockGetInstances = async (instances: Instance[]) => { + msw.use( + http.get( + `*/accounts/:accountId/workflows/some-workflow/instances`, + async () => { + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: instances, + }); + }, + { once: true } + ) + ); + }; + + const mockPatchRequest = async (expectedInstance: string) => { + msw.use( + http.patch( + `*/accounts/:accountId/workflows/some-workflow/instances/:instanceId/status`, + async ({ params }) => { + expect(params.instanceId).toEqual(expectedInstance); + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: {}, + }); + }, + { once: true } + ) + ); + }; + + describe("help", () => { + it("should show help when no argument is passed", async () => { + writeWranglerToml(); + + await runWrangler(`workflows`); + await endEventLoop(); + + expect(std.out).toMatchInlineSnapshot( + `"wrangler workflows + +πŸ” Manage Workflows [open-beta] + +COMMANDS + wrangler workflows list List Workflows associated to account [open-beta] + wrangler workflows describe Describe Workflow resource [open-beta] + wrangler workflows delete Delete workflow - when deleting a workflow, it will also delete it's own instances [open-beta] + wrangler workflows trigger [params] Trigger a workflow, creating a new instance. Can optionally take a JSON string to pass a parameter into the workflow instance [open-beta] + wrangler workflows instances Manage Workflow instances [open-beta] + +GLOBAL FLAGS + -j, --experimental-json-config Experimental: support wrangler.json [boolean] + -c, --config Path to .toml configuration file [string] + -e, --env Environment to use for operations and .env files [string] + -h, --help Show help [boolean] + -v, --version Show version number [boolean]"` + ); + }); + }); + + describe("instances help", () => { + it("should show instance help when no argument is passed", async () => { + writeWranglerToml(); + + await runWrangler(`workflows instances`); + await endEventLoop(); + + expect(std.out).toMatchInlineSnapshot( + `"wrangler workflows instances + +Manage Workflow instances [open-beta] + +COMMANDS + wrangler workflows instances list Instance related commands (list, describe, terminate, pause, resume) [open-beta] + wrangler workflows instances describe Describe a workflow instance - see its logs, retries and errors [open-beta] + wrangler workflows instances terminate Terminate a workflow instance [open-beta] + wrangler workflows instances pause Pause a workflow instance [open-beta] + wrangler workflows instances resume Resume a workflow instance [open-beta] + +GLOBAL FLAGS + -j, --experimental-json-config Experimental: support wrangler.json [boolean] + -c, --config Path to .toml configuration file [string] + -e, --env Environment to use for operations and .env files [string] + -h, --help Show help [boolean] + -v, --version Show version number [boolean]"` + ); + }); + }); + + describe("list", () => { + const mockWorkflows: Workflow[] = [ + { + class_name: "wf_class_1", + created_on: "2021-01-01T00:00:00Z", + id: "wf_id_1", + modified_on: "2021-01-01T00:00:00Z", + name: "wf_1", + script_name: "wf_script_1", + }, + { + class_name: "wf_class_2", + created_on: "2022-01-01T00:00:00Z", + id: "wf_id_2", + modified_on: "2022-01-01T00:00:00Z", + name: "wf_2", + script_name: "wf_script_2", + }, + ]; + + const mockGetWorkflows = async (workflows: Workflow[]) => { msw.use( http.get( - `*/accounts/:accountId/workflows/some-workflow/instances`, + `*/accounts/:accountId/workflows`, async () => { return HttpResponse.json({ success: true, errors: [], messages: [], - result: instances, + result: workflows, }); }, { once: true } ) ); }; - const mockPauseRequest = async (expectedInstance: string) => { + + it("should get the list of workflows", async () => { + writeWranglerToml(); + await mockGetWorkflows(mockWorkflows); + + await runWrangler(`workflows list`); + expect(std.info).toMatchInlineSnapshot(`"Showing last 2 workflows:"`); + expect(std.out).toMatchInlineSnapshot( + `"β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Name β”‚ Script name β”‚ Class name β”‚ Created β”‚ Modified β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ wf_1 β”‚ wf_script_1 β”‚ wf_class_1 β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ wf_2 β”‚ wf_script_2 β”‚ wf_class_2 β”‚ 1/1/2022, 12:00:00 AM β”‚ 1/1/2022, 12:00:00 AM β”‚ +β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜"` + ); + }); + }); + + describe("instances list", () => { + const mockInstances: Instance[] = [ + { + id: "foo", + created_on: "2021-01-01T00:00:00Z", + modified_on: "2021-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + { + id: "bar", + created_on: "2022-01-01T00:00:00Z", + modified_on: "2022-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + ]; + + it("should get the list of instances given a name", async () => { + writeWranglerToml(); + await mockGetInstances(mockInstances); + + await runWrangler(`workflows instances list some-workflow`); + console.log(std); + expect(std.info).toMatchInlineSnapshot( + `"Showing 2 instances from page 1:"` + ); + expect(std.out).toMatchInlineSnapshot( + `"β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Id β”‚ Version β”‚ Created β”‚ Modified β”‚ Status β”‚ +β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ bar β”‚ c β”‚ 1/1/2022, 12:00:00 AM β”‚ 1/1/2022, 12:00:00 AM β”‚ β–Ά Running β”‚ +β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ foo β”‚ c β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ β–Ά Running β”‚ +β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +{ + debug: [Getter], + out: [Getter], + info: [Getter], + err: [Getter], + warn: [Getter] +}"` + ); + }); + }); + + describe("instances describe", () => { + const mockDescribeInstances = async () => { + const mockResponse = { + end: "2019-08-24T14:15:22Z", + output: "string", + params: {}, + queued: "2019-08-24T14:15:22Z", + start: "2019-08-24T14:15:22Z", + status: "queued", + success: true, + trigger: { + source: "unknown", + }, + versionId: "14707576-2549-4848-82ed-f68f8a1b47c7", + steps: [ + { + attempts: [ + { + end: "2019-08-24T14:15:22Z", + error: { + message: "string", + name: "string", + }, + start: "2019-08-24T14:15:22Z", + success: true, + }, + ], + config: { + retries: { + backoff: "constant", + delay: "string", + limit: 0, + }, + timeout: "string", + }, + end: "2019-08-24T14:15:22Z", + name: "string", + output: {}, + start: "2019-08-24T14:15:22Z", + success: true, + type: "step", + }, + ], + }; + msw.use( - http.patch( - `*/accounts/:accountId/workflows/some-workflow/instances/:instanceId/status`, - async ({ params }) => { - expect(params.instanceId).toEqual(expectedInstance); + http.get( + `*/accounts/:accountId/workflows/some-workflow/instances/:instanceId`, + async () => { return HttpResponse.json({ success: true, errors: [], messages: [], - result: {}, + result: mockResponse, }); }, { once: true } @@ -52,32 +275,156 @@ describe("wrangler workflows", () => { ); }; - it("should get and pause the latest instance given a name", async () => { + it("should describe the bar instance given a name", async () => { + writeWranglerToml(); + await mockDescribeInstances(); + + await runWrangler(`workflows instances describe some-workflow bar`); + expect(std.out).toMatchInlineSnapshot( + `"β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Start β”‚ End β”‚ Duration β”‚ State β”‚ Error β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ 8/24/2019, 3:15:22 PM β”‚ 8/24/2019, 3:15:22 PM β”‚ 0 seconds β”‚ βœ… Success β”‚ string: string β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜"` + ); + }); + }); + + describe("instances pause", () => { + const mockInstances: Instance[] = [ + { + id: "foo", + created_on: "2021-01-01T00:00:00Z", + modified_on: "2021-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + { + id: "bar", + created_on: "2022-01-01T00:00:00Z", + modified_on: "2022-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + ]; + + it("should get and pause the bar instance given a name", async () => { writeWranglerToml(); - const mockInstances: Instance[] = [ - { - id: "earliest", - created_on: "2021-01-01T00:00:00Z", - modified_on: "2021-01-01T00:00:00Z", - workflow_id: "b", - version_id: "c", - status: "running", - }, - { - id: "latest", - created_on: "2022-01-01T00:00:00Z", - modified_on: "2022-01-01T00:00:00Z", - workflow_id: "b", - version_id: "c", - status: "running", - }, - ]; await mockGetInstances(mockInstances); - await mockPauseRequest("latest"); + await mockPatchRequest("bar"); + + await runWrangler(`workflows instances pause some-workflow bar`); + expect(std.info).toMatchInlineSnapshot( + `"⏸️ The instance \\"bar\\" from some-workflow was paused successfully"` + ); + }); + }); + + describe("instances resume", () => { + const mockInstances: Instance[] = [ + { + id: "foo", + created_on: "2021-01-01T00:00:00Z", + modified_on: "2021-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + { + id: "bar", + created_on: "2022-01-01T00:00:00Z", + modified_on: "2022-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "paused", + }, + ]; + + it("should get and resume the bar instance given a name", async () => { + writeWranglerToml(); + await mockGetInstances(mockInstances); + await mockPatchRequest("bar"); + + await runWrangler(`workflows instances resume some-workflow bar`); + expect(std.info).toMatchInlineSnapshot( + `"πŸ”„ The instance \\"bar\\" from some-workflow was resumed successfully"` + ); + }); + }); + + describe("instances terminate", () => { + const mockInstances: Instance[] = [ + { + id: "foo", + created_on: "2021-01-01T00:00:00Z", + modified_on: "2021-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + { + id: "bar", + created_on: "2022-01-01T00:00:00Z", + modified_on: "2022-01-01T00:00:00Z", + workflow_id: "b", + version_id: "c", + status: "running", + }, + ]; + + it("should get and terminate the bar instance given a name", async () => { + writeWranglerToml(); + await mockGetInstances(mockInstances); + await mockPatchRequest("bar"); + + await runWrangler(`workflows instances terminate some-workflow bar`); + expect(std.info).toMatchInlineSnapshot( + `"πŸ₯· The instance \\"bar\\" from some-workflow was terminated successfully"` + ); + }); + }); - await runWrangler(`workflows instances pause some-workflow latest`); + describe("trigger", () => { + const mockTriggerWorkflow = async () => { + msw.use( + http.post( + `*/accounts/:accountId/workflows/some-workflow/instances`, + async () => { + return HttpResponse.json({ + success: true, + errors: [], + messages: [], + result: {}, + }); + }, + { once: true } + ) + ); + }; + + it("should trigger a workflow given a name", async () => { + writeWranglerToml(); + await mockTriggerWorkflow(); + + await runWrangler(`workflows trigger some-workflow`); + expect(std.info).toMatchInlineSnapshot( + `"πŸš€ Workflow instance \\"undefined\\" has been queued successfully"` + ); + }); + }); + + describe("delete", () => { + it("should delete a workflow - check not implemented", async () => { + writeWranglerToml(); + + await runWrangler(`workflows delete some-workflow`); expect(std.out).toMatchInlineSnapshot( - `"⏸️ The instance \\"latest\\" from some-workflow was paused successfully"` + `"🚫 Workflow \\"some-workflow\\" NOT removed"` + ); + expect(std.info).toMatchInlineSnapshot( + `"🚫 delete command not yet implement"` ); }); }); diff --git a/packages/wrangler/src/workflows/commands/delete.ts b/packages/wrangler/src/workflows/commands/delete.ts index c5b1e00aa7c9..0aeaf2fce778 100644 --- a/packages/wrangler/src/workflows/commands/delete.ts +++ b/packages/wrangler/src/workflows/commands/delete.ts @@ -1,7 +1,5 @@ -import { fetchResult } from "../../cfetch"; import { defineCommand } from "../../core"; import { logger } from "../../logger"; -import { requireAuth } from "../../user"; defineCommand({ command: "wrangler workflows delete", @@ -21,13 +19,8 @@ defineCommand({ }, positionalArgs: ["name"], - async handler(args, { config }) { - const accountId = await requireAuth(config); - - await fetchResult(`/accounts/${accountId}/workflows/${args.name}`, { - method: "DELETE", - }); - - logger.info(`Workflow "${args.name}" was successfully removed`); + async handler(args) { + logger.info("🚫 delete command not yet implement"); + logger.log(`🚫 Workflow "${args.name}" NOT removed`); }, }); diff --git a/packages/wrangler/src/workflows/commands/instances/pause.ts b/packages/wrangler/src/workflows/commands/instances/pause.ts index ab226ed80dbb..4c9bb05ebe21 100644 --- a/packages/wrangler/src/workflows/commands/instances/pause.ts +++ b/packages/wrangler/src/workflows/commands/instances/pause.ts @@ -61,7 +61,7 @@ defineCommand({ } ); - logger.log( + logger.info( `⏸️ The instance "${id}" from ${args.name} was paused successfully` ); }, From 45851c664df70d7a7a9e7360c2eb1ef2aef4099e Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Thu, 31 Oct 2024 17:22:59 +0000 Subject: [PATCH 07/14] try to fix timezones --- .../wrangler/src/__tests__/workflows.test.ts | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 1ca24175eb3b..3385d39e2711 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -155,13 +155,15 @@ GLOBAL FLAGS await runWrangler(`workflows list`); expect(std.info).toMatchInlineSnapshot(`"Showing last 2 workflows:"`); expect(std.out).toMatchInlineSnapshot( - `"β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + ` +"β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Name β”‚ Script name β”‚ Class name β”‚ Created β”‚ Modified β”‚ β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ wf_1 β”‚ wf_script_1 β”‚ wf_class_1 β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ wf_2 β”‚ wf_script_2 β”‚ wf_class_2 β”‚ 1/1/2022, 12:00:00 AM β”‚ 1/1/2022, 12:00:00 AM β”‚ -β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜"` +β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜" + ` ); }); }); @@ -196,7 +198,8 @@ GLOBAL FLAGS `"Showing 2 instances from page 1:"` ); expect(std.out).toMatchInlineSnapshot( - `"β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + ` +"β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Id β”‚ Version β”‚ Created β”‚ Modified β”‚ Status β”‚ β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ bar β”‚ c β”‚ 1/1/2022, 12:00:00 AM β”‚ 1/1/2022, 12:00:00 AM β”‚ β–Ά Running β”‚ @@ -209,7 +212,8 @@ GLOBAL FLAGS info: [Getter], err: [Getter], warn: [Getter] -}"` +}" + ` ); }); }); @@ -217,11 +221,11 @@ GLOBAL FLAGS describe("instances describe", () => { const mockDescribeInstances = async () => { const mockResponse = { - end: "2019-08-24T14:15:22Z", + end: "2021-01-01T00:00:00Z", output: "string", params: {}, - queued: "2019-08-24T14:15:22Z", - start: "2019-08-24T14:15:22Z", + queued: "2021-01-01T00:00:00Z", + start: "2021-01-01T00:00:00Z", status: "queued", success: true, trigger: { @@ -232,12 +236,12 @@ GLOBAL FLAGS { attempts: [ { - end: "2019-08-24T14:15:22Z", + end: "2021-01-01T00:00:00Z", error: { message: "string", name: "string", }, - start: "2019-08-24T14:15:22Z", + start: "2021-01-01T00:00:00Z", success: true, }, ], @@ -249,10 +253,10 @@ GLOBAL FLAGS }, timeout: "string", }, - end: "2019-08-24T14:15:22Z", + end: "2021-01-01T00:00:00Z", name: "string", output: {}, - start: "2019-08-24T14:15:22Z", + start: "2021-01-01T00:00:00Z", success: true, type: "step", }, @@ -280,13 +284,13 @@ GLOBAL FLAGS await mockDescribeInstances(); await runWrangler(`workflows instances describe some-workflow bar`); - expect(std.out).toMatchInlineSnapshot( - `"β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” + expect(std.out).toMatchInlineSnapshot(` +"β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Start β”‚ End β”‚ Duration β”‚ State β”‚ Error β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ -β”‚ 8/24/2019, 3:15:22 PM β”‚ 8/24/2019, 3:15:22 PM β”‚ 0 seconds β”‚ βœ… Success β”‚ string: string β”‚ -β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜"` - ); +β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ 0 seconds β”‚ βœ… Success β”‚ string: string β”‚ +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜" + `); }); }); From c60723f5b4cdb791823df4a853a5f8c3f5a32b2d Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Thu, 31 Oct 2024 17:50:46 +0000 Subject: [PATCH 08/14] hidded workflows delete command from help as it is not yet implemented --- packages/wrangler/src/__tests__/workflows.test.ts | 1 - packages/wrangler/src/workflows/commands/delete.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 3385d39e2711..406ba162e886 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -68,7 +68,6 @@ describe("wrangler workflows", () => { COMMANDS wrangler workflows list List Workflows associated to account [open-beta] wrangler workflows describe Describe Workflow resource [open-beta] - wrangler workflows delete Delete workflow - when deleting a workflow, it will also delete it's own instances [open-beta] wrangler workflows trigger [params] Trigger a workflow, creating a new instance. Can optionally take a JSON string to pass a parameter into the workflow instance [open-beta] wrangler workflows instances Manage Workflow instances [open-beta] diff --git a/packages/wrangler/src/workflows/commands/delete.ts b/packages/wrangler/src/workflows/commands/delete.ts index 0aeaf2fce778..5d6ea8e9da38 100644 --- a/packages/wrangler/src/workflows/commands/delete.ts +++ b/packages/wrangler/src/workflows/commands/delete.ts @@ -8,6 +8,7 @@ defineCommand({ "Delete workflow - when deleting a workflow, it will also delete it's own instances", owner: "Product: Workflows", status: "open-beta", + hidden: true, }, args: { From 6bc790c37686b4b6bd25a99db1dbf93203469599 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 10:43:41 +0000 Subject: [PATCH 09/14] Update packages/wrangler/src/__tests__/workflows.test.ts Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> --- packages/wrangler/src/__tests__/workflows.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 406ba162e886..61887fee8b0d 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -192,7 +192,6 @@ GLOBAL FLAGS await mockGetInstances(mockInstances); await runWrangler(`workflows instances list some-workflow`); - console.log(std); expect(std.info).toMatchInlineSnapshot( `"Showing 2 instances from page 1:"` ); From 656802d1513b4b1bba4d29afe1157f09f6632d5f Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 10:46:24 +0000 Subject: [PATCH 10/14] Update packages/wrangler/src/__tests__/workflows.test.ts Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com> --- packages/wrangler/src/__tests__/workflows.test.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 61887fee8b0d..e75867ea527d 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -204,13 +204,7 @@ GLOBAL FLAGS β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ foo β”‚ c β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ β–Ά Running β”‚ β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ -{ - debug: [Getter], - out: [Getter], - info: [Getter], - err: [Getter], - warn: [Getter] -}" +" ` ); }); From a0cad9b1ba0912fe4240f530499af0e722afbf0f Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 10:48:04 +0000 Subject: [PATCH 11/14] fixed should get the list of instances given a name test --- packages/wrangler/src/__tests__/workflows.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index e75867ea527d..75869b7f69b3 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -203,8 +203,7 @@ GLOBAL FLAGS β”‚ bar β”‚ c β”‚ 1/1/2022, 12:00:00 AM β”‚ 1/1/2022, 12:00:00 AM β”‚ β–Ά Running β”‚ β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ foo β”‚ c β”‚ 1/1/2021, 12:00:00 AM β”‚ 1/1/2021, 12:00:00 AM β”‚ β–Ά Running β”‚ -β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ -" +β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜" ` ); }); From a8641a3a0ca8727305600c7ee96b5389c9f310af Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 10:49:41 +0000 Subject: [PATCH 12/14] better changeset --- .changeset/violet-zoos-obey.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/violet-zoos-obey.md b/.changeset/violet-zoos-obey.md index 0b01aeab2a8f..d0396ce2f40b 100644 --- a/.changeset/violet-zoos-obey.md +++ b/.changeset/violet-zoos-obey.md @@ -2,4 +2,4 @@ "wrangler": minor --- -Added pause and resume commands to manage Workflows +Added pause and resume commands to manage Workflows and hidded unimplemented delete command From c6c88f9b8f7fef5c5faf2c0892bc64578c78f575 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 13:55:52 +0000 Subject: [PATCH 13/14] added mocked instance id when a workflow is triggered --- packages/wrangler/src/__tests__/workflows.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index 75869b7f69b3..d23d3e6033af 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -391,7 +391,12 @@ GLOBAL FLAGS success: true, errors: [], messages: [], - result: {}, + result: { + "id": "3c70754a-8435-4498-92ad-22e2e2c90853", + "status": "queued", + "version_id": "9e94c502-ca41-4342-a7f7-af96b444512c", + "workflow_id": "03e70e31-d7a4-4401-a629-6a4b6096cdfe" + }, }); }, { once: true } @@ -404,8 +409,9 @@ GLOBAL FLAGS await mockTriggerWorkflow(); await runWrangler(`workflows trigger some-workflow`); + expect(std); expect(std.info).toMatchInlineSnapshot( - `"πŸš€ Workflow instance \\"undefined\\" has been queued successfully"` + `"πŸš€ Workflow instance \\"3c70754a-8435-4498-92ad-22e2e2c90853\\" has been queued successfully"` ); }); }); From 3c777c4f32b5153c14c4c5c512050ad8b25f610e Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 4 Nov 2024 14:06:45 +0000 Subject: [PATCH 14/14] prettify cleanup --- packages/wrangler/src/__tests__/workflows.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/wrangler/src/__tests__/workflows.test.ts b/packages/wrangler/src/__tests__/workflows.test.ts index d23d3e6033af..08bc32cb8d8b 100644 --- a/packages/wrangler/src/__tests__/workflows.test.ts +++ b/packages/wrangler/src/__tests__/workflows.test.ts @@ -392,11 +392,11 @@ GLOBAL FLAGS errors: [], messages: [], result: { - "id": "3c70754a-8435-4498-92ad-22e2e2c90853", - "status": "queued", - "version_id": "9e94c502-ca41-4342-a7f7-af96b444512c", - "workflow_id": "03e70e31-d7a4-4401-a629-6a4b6096cdfe" - }, + id: "3c70754a-8435-4498-92ad-22e2e2c90853", + status: "queued", + version_id: "9e94c502-ca41-4342-a7f7-af96b444512c", + workflow_id: "03e70e31-d7a4-4401-a629-6a4b6096cdfe", + }, }); }, { once: true }