-
Notifications
You must be signed in to change notification settings - Fork 164
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
(feat): Use existing wrangler installation when appropriate #235
Changes from all commits
f78ca6a
b78dcf8
d1f1b4f
2523489
06f5e60
992c58e
afaec62
109508e
fcb0eb9
d9ae0a6
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler-action": minor | ||
--- | ||
|
||
wrangler-action will now re-use existing wrangler installations when available |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ jobs: | |
- name: Only build app | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/base" | ||
workingDirectory: "./test/only-build" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: deploy --dry-run | ||
|
@@ -38,12 +38,11 @@ jobs: | |
uses: ./ | ||
with: | ||
quiet: true | ||
workingDirectory: "./test/base" | ||
workingDirectory: "./test/build-quiet" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: deploy --dry-run | ||
|
||
# START Setup and teardown of Worker Environment Tests | ||
- name: Environment support | ||
uses: ./ | ||
with: | ||
|
@@ -52,28 +51,20 @@ jobs: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
environment: dev | ||
preCommands: npx wrangler deploy --env dev # https://github.com/cloudflare/wrangler-action/issues/162 | ||
postCommands: npx wrangler delete --name wrangler-action-dev-environment-test --force | ||
secrets: | | ||
SECRET1 | ||
SECRET2 | ||
env: | ||
SECRET1: ${{ secrets.SECRET1 }} | ||
SECRET2: ${{ secrets.SECRET2 }} | ||
|
||
- name: Clean up Deployed Environment Worker | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/base" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: delete --name wrangler-action-dev-environment-test --force | ||
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. Is this actually a test we want to do? i.e. run the delete command? 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. That's a great question. We actually do have a |
||
|
||
# END Setup and teardown of Worker Environment Tests | ||
# START Setup and teardown of Workers w/ Secrets Tests | ||
- name: Deploy app secrets w/ hardcoded Wrangler v2 | ||
uses: ./ | ||
with: | ||
wranglerVersion: "2.20.0" | ||
workingDirectory: "./test/base" | ||
workingDirectory: "./test/secrets-v2" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
secrets: | | ||
|
@@ -84,13 +75,13 @@ jobs: | |
SECRET2: ${{ secrets.SECRET2 }} | ||
|
||
- name: Health Check Deployed Worker | ||
run: node .github/workflows/workerHealthCheck.cjs | ||
run: node .github/workflows/workerHealthCheck.cjs wrangler-action-test-secrets-v2 | ||
shell: bash | ||
|
||
- name: Deploy app secrets w/ default version | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/base" | ||
workingDirectory: "./test/secrets-default" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
secrets: | | ||
|
@@ -101,22 +92,23 @@ jobs: | |
SECRET2: ${{ secrets.SECRET2 }} | ||
|
||
- name: Health Check Deployed Worker | ||
run: node .github/workflows/workerHealthCheck.cjs | ||
run: node .github/workflows/workerHealthCheck.cjs wrangler-action-test-secrets-default | ||
shell: bash | ||
|
||
- name: Clean Up Deployed Workers | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/base" | ||
workingDirectory: "./test/secrets-default" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: delete --name wrangler-action-test --force | ||
command: delete --name wrangler-action-test-secrets-v2 --force | ||
postCommands: npx wrangler delete --name wrangler-action-test-secrets-default --force | ||
# END Setup and teardown of Workers w/ Secrets Tests | ||
|
||
- name: Support packageManager variable | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/empty" | ||
workingDirectory: "./test/specify-package-manager" | ||
packageManager: "npm" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
|
@@ -125,7 +117,7 @@ jobs: | |
- name: Support unspecified packageManager with no lockfile | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/empty" | ||
workingDirectory: "./test/unspecified-package-manager" | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: deploy --dry-run | ||
|
@@ -159,3 +151,14 @@ jobs: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: deploy --dry-run | ||
|
||
- name: Change directory to pre-installed-wrangler and install dependencies | ||
run: | | ||
cd ./test/pre-installed-wrangler | ||
npm install | ||
|
||
- name: Support pre-installed wrangler | ||
uses: ./ | ||
with: | ||
workingDirectory: "./test/pre-installed-wrangler" | ||
command: action-test |
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 |
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.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "wrangler-action-test", | ||
"license": "MIT", | ||
"private": true | ||
} |
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 |
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), | ||
}); | ||
}, | ||
}; |
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); | ||
} |
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" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I think this is OK. But what happens if this step fails?
We should probably implement a cleanup job that runs on a schedule similar to workers-sdk e2e test cleanup...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that sounds like something we should add. Do you want me to do it in this PR? If not I'm happy to make another PR after this one to add it in.