Skip to content

Commit

Permalink
GA versions/deployments commands (#6497)
Browse files Browse the repository at this point in the history
* Default x-versions to true and allow negating with no-x-versions

* Update `wrangler deploy` to use the new versions/deployments API
  • Loading branch information
WalshyDev authored Aug 29, 2024
1 parent 0a76d7e commit 3bd833c
Show file tree
Hide file tree
Showing 23 changed files with 2,884 additions and 3,350 deletions.
9 changes: 9 additions & 0 deletions .changeset/mighty-seas-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": minor
---

chore: move `wrangler versions ...`, `wrangler deployments ...`, `wrangler rollback` and `wrangler triggers ...` out of experimental and open beta.
These are now available to use without the --x-versions flag, you can continue to pass this however without issue to keep compatibility with all the usage today.

A few of the commands had an output that wasn't guarded by `--x-versions` those have been updated to use the newer output, we have tried to keep compatibility where possible (for example: `wrangler rollback` will continue to output "Worker Version ID:" so users can continue to grab the ID).
If you wish to use the old versions of the commands you can pass the `--no-x-versions` flag. Note, these will be removed in the future so please work on migrating.
7 changes: 7 additions & 0 deletions .changeset/thirty-boats-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": minor
---

feat: update `wrangler deploy` to use the new versions and deployments API.
This should have zero user-facing impact but sets up the most used command to deploy Workers to use the new recommended APIs and move away from the old ones.
We will still call the old upload path where required (e.g. Durable Object migration or Service Worker format).
119 changes: 83 additions & 36 deletions packages/wrangler/e2e/deployments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ describe("deployments", { timeout: TIMEOUT }, () => {
it("list 1 deployment", async () => {
const output = await helper.run(`wrangler deployments list`);

expect(output.stdout).toContain("Upload from Wrangler 🤠");
expect(output.stdout).toContain("🟩 Active");
expect(normalize(output.stdout)).toMatchInlineSnapshot(`
"Created: TIMESTAMP
Author: person@example.com
Source: Upload
Message: Automatic deployment on upload.
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -"
`);
});

it("modify & deploy worker", async () => {
Expand Down Expand Up @@ -96,52 +104,91 @@ describe("deployments", { timeout: TIMEOUT }, () => {
it("list 2 deployments", async () => {
const dep = await helper.run(`wrangler deployments list`);
expect(normalize(dep.stdout)).toMatchInlineSnapshot(`
"🚧\`wrangler deployments\` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Deployment ID: 00000000-0000-0000-0000-000000000000
Version ID: 00000000-0000-0000-0000-000000000000
Created on: TIMESTAMP
Author: person@example.com
Source: Upload from Wrangler 🤠
Deployment ID: 00000000-0000-0000-0000-000000000000
Version ID: 00000000-0000-0000-0000-000000000000
Created on: TIMESTAMP
Author: person@example.com
Source: Upload from Wrangler 🤠
🟩 Active
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
"Created: TIMESTAMP
Author: person@example.com
Source: Upload
Message: Automatic deployment on upload.
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -
Created: TIMESTAMP
Author: person@example.com
Source: Unknown (deployment)
Message: -
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -"
`);
});

it("rollback", async () => {
const output = await helper.run(
`wrangler rollback --message "A test message"`
);
expect(output.stdout).toContain("Successfully rolled back");
expect(normalize(output.stdout)).toMatchInlineSnapshot(`
"├ Fetching latest deployment
├ Your current deployment has 1 version(s):
│ (100%) 00000000-0000-0000-0000-000000000000
│ Created: TIMESTAMP
│ Tag: -
│ Message: -
├ Finding latest stable Worker Version to rollback to
? Please provide an optional message for this rollback (120 characters max)
🤖 Using default value in non-interactive context: A test message
├ WARNING You are about to rollback to Worker Version 00000000-0000-0000-0000-000000000000.
│ This will immediately replace the current deployment and become the active deployment across all your deployed triggers.
│ However, your local development environment will not be affected by this rollback.
│ Rolling back to a previous deployment will not rollback any of the bound resources (Durable Object, D1, R2, KV, etc).
│ (100%) 00000000-0000-0000-0000-000000000000
│ Created: TIMESTAMP
│ Tag: -
│ Message: -
? Are you sure you want to deploy this Worker Version to 100% of traffic?
🤖 Using fallback value in non-interactive context: yes
Performing rollback...
╰ SUCCESS Worker Version 00000000-0000-0000-0000-000000000000 has been deployed to 100% of traffic.
Current Version ID: 00000000-0000-0000-0000-000000000000"
`);
});

it("list deployments", async () => {
const dep = await helper.run(`wrangler deployments list`);
expect(normalize(dep.stdout)).toMatchInlineSnapshot(`
"🚧\`wrangler deployments\` is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Deployment ID: 00000000-0000-0000-0000-000000000000
Version ID: 00000000-0000-0000-0000-000000000000
Created on: TIMESTAMP
Author: person@example.com
Source: Upload from Wrangler 🤠
Deployment ID: 00000000-0000-0000-0000-000000000000
Version ID: 00000000-0000-0000-0000-000000000000
Created on: TIMESTAMP
Author: person@example.com
Source: Upload from Wrangler 🤠
Deployment ID: 00000000-0000-0000-0000-000000000000
Version ID: 00000000-0000-0000-0000-000000000000
Created on: TIMESTAMP
Author: person@example.com
Source: Rollback from Wrangler 🤠
Rollback from: 00000000-0000-0000-0000-000000000000
Message: A test message
🟩 Active
Note: Deployment ID has been renamed to Version ID. Deployment ID is present to maintain compatibility with the previous behavior of this command. This output will change in a future version of Wrangler. To learn more visit: https://developers.cloudflare.com/workers/configuration/versions-and-deployments"
"Created: TIMESTAMP
Author: person@example.com
Source: Upload
Message: Automatic deployment on upload.
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -
Created: TIMESTAMP
Author: person@example.com
Source: Unknown (deployment)
Message: -
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -
Created: TIMESTAMP
Author: person@example.com
Source: Unknown (deployment)
Message: A test message
Version(s): (100%) 00000000-0000-0000-0000-000000000000
Created: TIMESTAMP
Tag: -
Message: -"
`);
});

Expand Down
Loading

0 comments on commit 3bd833c

Please sign in to comment.