forked from cloudflare/wrangler-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): Use existing wrangler installation when appropriate (cloudfla…
…re#235) * (feat): Check for existing wrangler installation * Add test for pre-installed wrangler * Add changeset * Address CR comments - check for an exact wrangler version match * Tweak the fixture test for the pre-installed-wrangler test * Simplify if/else logic for checking wrangler versions as per review notes * fix(test): Fix execution for fake wrangler installation * fixup! fix(test): Fix execution for fake wrangler installation * Setup new CI test convention for wrangler-action * Remove unncessary ts-expect-error comments --------- Co-authored-by: Peter Bacon Darwin <[email protected]>
- Loading branch information
1 parent
ea5754c
commit 0545ad2
Showing
36 changed files
with
333 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler-action": minor | ||
--- | ||
|
||
wrangler-action will now re-use existing wrangler installations when available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "wrangler-action-test-build-quiet" | ||
main = "./index.ts" | ||
compatibility_date = "2023-07-07" | ||
workers_dev = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
type Env = { | ||
SECRET1?: string; | ||
SECRET2?: string; | ||
}; | ||
|
||
export default { | ||
fetch(request: Request, env: Env) { | ||
const url = new URL(request.url); | ||
|
||
if (url.pathname === "/secret-health-check") { | ||
const { SECRET1, SECRET2 } = env; | ||
|
||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") { | ||
throw new Error("SECRET1 or SECRET2 is not defined"); | ||
} | ||
|
||
return new Response("OK"); | ||
} | ||
|
||
return Response.json({ | ||
...request, | ||
headers: Object.fromEntries(request.headers), | ||
}); | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "wrangler-action-test", | ||
"license": "MIT", | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name = "wrangler-action-test" | ||
name = "wrangler-action-test-only-build" | ||
main = "./index.ts" | ||
compatibility_date = "2023-07-07" | ||
workers_dev = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
type Env = { | ||
SECRET1?: string; | ||
SECRET2?: string; | ||
}; | ||
|
||
export default { | ||
fetch(request: Request, env: Env) { | ||
const url = new URL(request.url); | ||
|
||
if (url.pathname === "/secret-health-check") { | ||
const { SECRET1, SECRET2 } = env; | ||
|
||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") { | ||
throw new Error("SECRET1 or SECRET2 is not defined"); | ||
} | ||
|
||
return new Response("OK"); | ||
} | ||
|
||
return Response.json({ | ||
...request, | ||
headers: Object.fromEntries(request.headers), | ||
}); | ||
}, | ||
}; |
18 changes: 18 additions & 0 deletions
18
test/pre-installed-wrangler/mock_packages/wrangler/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
|
||
const args = Array.from(process.argv); | ||
const command = args.pop(); | ||
switch (command) { | ||
case "--version": | ||
console.log(` | ||
⛅️ wrangler 1.1.1 (update available 1.2.3) | ||
------------------------------------------`); | ||
process.exit(0); | ||
case "action-test": | ||
console.log("Test successful."); | ||
process.exit(0); | ||
default: | ||
console.error("Invalid command"); | ||
process.exit(1); | ||
} |
7 changes: 7 additions & 0 deletions
7
test/pre-installed-wrangler/mock_packages/wrangler/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"private": true, | ||
"name": "wrangler", | ||
"version": "1.1.1", | ||
"main": "index.js", | ||
"bin": "index.js" | ||
} |
Oops, something went wrong.