Commit graph

37 commits

Author SHA1 Message Date
Adishwar Rishi
0545ad285a
(feat): Use existing wrangler installation when appropriate (#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 <pbacondarwin@cloudflare.com>
2024-05-15 09:53:41 +01:00
Matthew Rodgers
31a6263ef3 Stop racing secret uploads
For up to date versions of wrangler, secrets are uploaded via the
'secret:bulk' command, which batches updates in a single API call.

For versions of wrangler without that capability, the action falls back
to the single 'secret put' command for each secret. It races all these
with a Promise.all()

Unfortunately, the single secret API cannot handle concurrency - at
best, these calls have to wait on one another, holding requests open
all the while. Often it times out and errors.

This fixes the legacy secret upload errors by making these calls
serially instead of concurrently.
2024-04-26 15:44:18 -07:00
Adishwar Rishi
b92719544e
Remove extra debug description for err.stack 2024-01-05 18:08:54 +11:00
Adishwar Rishi
ebaf896045
Improve debug error message for secret:bulk command failure 2024-01-03 13:19:58 +11:00
Adishwar Rishi
7e684fbad9
Surface inner exception when secret:bulk upload command fails 2024-01-03 13:07:49 +11:00
Grant Birkinbine
f88aee4953
Merge branch 'main' into write-results-to-a-file 2023-12-13 10:04:14 -07:00
Grant Birkinbine
a5f361f3f0
Update src/index.ts
Co-authored-by: Cina Saffary <itscina@gmail.com>
2023-12-13 10:02:54 -07:00
James Ross
9aba9c34da
fix: semver comparison (#216)
* fix: semver comparison

chore: bump dependencies

* chore: add changeset

* fix: update snapshot for error test
2023-12-13 09:53:47 +00:00
Grant Birkinbine
1599928d8e
Update src/index.ts 2023-12-12 22:24:09 -07:00
GrantBirki
ca0bf5eeba
properly check for pages deployments 2023-12-07 23:17:03 -07:00
GrantBirki
97c920b38e
parse and set the deployment-url 2023-12-07 22:48:10 -07:00
GrantBirki
11fa60953d
set another output for stderr as it will almost always contain 'some' data 2023-12-07 22:30:51 -07:00
GrantBirki
74a612d924
swap from file to output variable 2023-12-07 22:26:06 -07:00
GrantBirki
8d6fade5ad
save primary wrangler command output to a file (optionally) 2023-12-01 11:04:51 -07:00
Cina Saffary
473d9cbd29 Bump DEFAULT_WRANGLER_VERSION to 3.13.2 2023-10-18 17:04:41 -05:00
Cina Saffary
d647227bbc Refactor subprocess execution to use @actions/exec
Instead of using a mix of `child_process.exec`, `child_process.execSync` and a promisified version of `child_process.exec`, we now (mostly) just use `@actions/exec`. That runs `child_process.spawn` under the hood and handles a lot of character escaping for us. We can also now pass Buffers directly into the subprocess as stdin instead of relying on shell piping.

This ends up fixing a few problems we had where secrets and env var values containing shell metacharacters were being misinterpreted.

Unfortunately, `@actions/exec` doesn't support running with a shell. That means we still have to roll our own wrapper around `child_process.exec` to avoid a breaking change to `preCommands` and `postCommands`, since users might be expecting these to run within a shell.

Also worth noting that we're no longer hiding stdout and stderr from the secret uploading step. We were previously doing this out of an abundance of caution, but it made debugging issues very difficult if secret upload failed for some reason. I feel ok doing this since we're no longer echoing & piping the secret values, wrangler doesn't ever output secret values, and as a last line of defense GitHub masks any secret values that accidentally get logged.
2023-10-18 16:42:34 -05:00
Cina Saffary
bd06b290b1 Fix code formatting errors 2023-10-10 18:00:40 -05:00
Jacob Andersen
779191a652
add bun support 2023-10-10 12:36:03 -07:00
Cina Saffary
528687aaf4 Refactor to use npm as a fallback if no packageManager specified...
and no lockfile is present. Fixes #180
2023-10-09 17:20:09 -05:00
Han Yeong-woo
50b529e7b8
Fix pass arg issue 2023-09-19 03:50:54 +09:00
Han Yeong-woo
2375787b23
Move test fixtures to parent directory 2023-09-19 01:30:35 +09:00
Han Yeong-woo
868dbd9a40
Remove unused function 2023-09-19 01:30:34 +09:00
Han Yeong-woo
a009342d77
Add packageManager setting 2023-09-19 01:30:34 +09:00
Han Yeong-woo
f2e4cda4dd
Detect package manager and uses its commands
Fix #156
2023-09-19 01:30:33 +09:00
Han Yeong-woo
f4f2e854d7
Add isValidPackcageManager() util 2023-09-19 01:30:33 +09:00
Han Yeong-woo
cbe5f5b523
Add detect package manager util function 2023-09-19 01:30:33 +09:00
Cina Saffary
2962e94ac8 Move unit-tested modules into utils file
This fixes the issue where running the unit tests invoked the entire action since index.ts calls `main()` at the top-level scope.
2023-08-29 18:16:41 -05:00
Cina Saffary
5517edbb28 Avoid double "Error: Error:" logging 2023-08-29 18:00:03 -05:00
Cina Saffary
f74c325efc Limit error logging on secret upload 2023-08-29 17:57:19 -05:00
Cina Saffary
105f191b19 Update snapshot for checkWorkingDirectory test 2023-08-29 17:43:29 -05:00
Cina Saffary
e5251df521 Refactor error handling to stop execution on errors. Fixes #160. 2023-08-29 16:36:50 -05:00
Jacob M-G Evans
0aa12f0c2b
Merge pull request #154 from cloudflare/jacobmgevans/silence-mode
Quiet feature
2023-08-16 10:54:36 -05:00
Jacob M-G Evans
3f40637a1c
Quiet feature
Some of the stderr, stdout, info & groupings can be a little noisy for some users and use cases.
This feature allows for a option to be passed 'quiet: true' this would significantly reduce the noise.

There will still be output that lets the user know Wrangler Installed and Wrangler Action completed successfully.
Any failure status will still be output to the user as well, to prevent silent failures.

resolves #142
2023-08-16 09:37:29 -05:00
Esteban Borai
4132892387
fix: use wrangler@3.5.1 by default 2023-08-15 17:23:30 -04:00
Jacob M-G Evans
88466ea5ae
Update .changeset/itchy-buses-grow.md
Co-authored-by: Cina Saffary <itscina@gmail.com>
2023-08-10 14:51:00 -05:00
Jacob M-G Evans
74433eb31e
Additional Error Handling
Previously, we prevented any error logs from propagating too far to prevent leaking of any potentially sensitive information. However, this made it difficult for developers to debug their code.

In this release, we have updated our error handling to allow for more error messaging from pre/post and custom commands. We still discourage the use of these commands for secrets or other sensitive information, but we believe this change will make it easier for developers to debug their code.

Relates to #137
2023-08-10 10:11:35 -05:00
Jacob M-G Evans
edb2a58814
feat: rewrite Wrangler Action in TypeScript
* Removes dependencies such as Docker, decreasing spin-up time
* Adds community-requested features, including bulk secrets API utilization from Wrangler
* Fixes CI/CD
* Adds testing
* Improves command implementation
* Begins using Node for the Action engine/runner
* Openly discusses all changes with the community
  GitHub Discussions opened and Issues monitored

BREAKING CHANGES:
* Docker is no longer a dependency
* Wrangler v1 is no longer supported

Additional related Internal tickets:
Major Version Default: https://jira.cfdata.org/browse/DEVX-632
Rewrite Project: DEVX-804,802,800,632
2023-08-07 13:05:09 -05:00