Skip to content
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

Add wrangler pages project validate [directory] command #3762

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

GregBrimble
Copy link
Member

What this PR solves / how to test:

For internal use, we want to validate a static asset directory ahead of actually uploading it.

This PR just pulls out the validation logic we were already doing into its own command and then adds some more tests to cover the failure cases of a file size too large and having too many assets.

Associated docs issue(s)/PR(s):

n/a

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@GregBrimble GregBrimble requested review from a team as code owners August 15, 2023 08:49
@changeset-bot
Copy link

changeset-bot bot commented Aug 15, 2023

🦋 Changeset detected

Latest commit: 96032a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 15, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5889398203/npm-package-wrangler-3762

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5889398203/npm-package-wrangler-3762

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5889398203/npm-package-wrangler-3762 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5889398203/npm-package-cloudflare-pages-shared-3762

Note that these links will no longer work once the GitHub Actions artifact expires.

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Merging #3762 (6a1a614) into main (2ee9815) will increase coverage by 0.08%.
Report is 4 commits behind head on main.
The diff coverage is 96.66%.

❗ Current head 6a1a614 differs from pull request most recent head 96032a1. Consider uploading reports for the commit 96032a1 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3762      +/-   ##
==========================================
+ Coverage   75.17%   75.25%   +0.08%     
==========================================
  Files         194      195       +1     
  Lines       11410    11428      +18     
  Branches     3013     3014       +1     
==========================================
+ Hits         8577     8600      +23     
+ Misses       2833     2828       -5     
Files Changed Coverage Δ
packages/wrangler/src/pages/validate.tsx 95.74% <95.74%> (ø)
packages/wrangler/src/api/pages/deploy.tsx 88.13% <100.00%> (+0.20%) ⬆️
packages/wrangler/src/pages/index.ts 84.00% <100.00%> (+0.66%) ⬆️
packages/wrangler/src/pages/upload.tsx 78.23% <100.00%> (-2.22%) ⬇️

... and 3 files with indirect coverage changes

const directory = resolve(args.directory);

// TODO(future): Use this to more efficiently load files in and speed up uploading
// Limit memory to 1 GB unless more is specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this bit about limiting memory?

) => {
const files = await readdir(dir);

await Promise.all(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's 10,000k files in a directory, will this blow up?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's prooooobably worth pulling in p-queue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is just a refactor, and I'd rather keep it to just a copy-paste job right now rather than changing anything about how this actually works. Would totally be fine with creating a new issue to follow-up on improving this though!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeahhh I realized that after I made the comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - probably worth improving this code, but that's out of scope of this PR

@GregBrimble GregBrimble merged commit 18dc7b5 into main Aug 21, 2023
10 checks passed
@GregBrimble GregBrimble deleted the add-pages-validate-command branch August 21, 2023 12:19
@github-actions github-actions bot mentioned this pull request Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants