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

Granular e2e caching #6201

Merged
merged 6 commits into from
Jul 5, 2024
Merged

Granular e2e caching #6201

merged 6 commits into from
Jul 5, 2024

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Jul 4, 2024

What this PR solves / how to test

Turbo only supports caching on the individual task level, but for Wrangler's e2e tests we want to support caching on a more granular basis—at the file level.

As such, this PR constructs multiple turbo tasks—one per e2e test file, ensuring that each file's tests can be cached individually.

Because Turbo ignores the cache when package.json changes, we can't generate these package.json scripts on the fly in CI, and so we require them to be commited to the repository. Since this is easy to mess up, this PR adds a script to lint turbo.json, the root package.json, and Wrangler's package.json to ensure everything is set up as intended.

The intended flow here is that CI will run pnpm test:e2e:wrangler, which will trigger turbo to run an individual task for each Wrangler e2e test file. These tasks are defined in the root turbo.json, and correspond to scripts in the Wrangler package. We ensure there's no accidental task name collision across packages by adding --filter wrangler to the turbo command, to make it only run tasks in the Wrangler package.

An example of the benefit this gives us are these two runs:

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Included
    • Not necessary because: modification to how tests are run
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • Not necessary because: not user facing
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Not necessary because: not user facing

@penalosa penalosa requested a review from a team as a code owner July 4, 2024 16:18
Copy link

changeset-bot bot commented Jul 4, 2024

⚠️ No Changeset found

Latest commit: 03b625d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@penalosa penalosa added the e2e Run e2e tests on a PR label Jul 4, 2024
Copy link
Contributor

github-actions bot commented Jul 4, 2024

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/9809434507/npm-package-wrangler-6201

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-wrangler-6201 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-create-cloudflare-6201 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-cloudflare-kv-asset-handler-6201
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-miniflare-6201
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-cloudflare-pages-shared-6201
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9809434507/npm-package-cloudflare-vitest-pool-workers-6201

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240701.0
workerd 1.20240701.0 1.20240701.0
workerd --version 1.20240701.0 2024-07-01

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@penalosa penalosa force-pushed the penalosa/granular-e2e-caching branch from b14e4f3 to 51d01a7 Compare July 4, 2024 16:42
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Unfortunately this breaks on Windows due to its inability to have : colons in filepaths.

Is it not possible to make this more dynamic by using an ENV var to set which e2e tests to run and then running turbo multiple times for each env var?

@petebacondarwin petebacondarwin added the maintenance Maintenance task label Jul 5, 2024
Comment on lines +5 to +6
* As such, we run the `test:e2e` turbo task multiple times—once per e2e test file
* with different arguments, ensuring that each file's tests can be cached individually.
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@penalosa penalosa merged commit c6c083f into main Jul 5, 2024
20 checks passed
@penalosa penalosa deleted the penalosa/granular-e2e-caching branch July 5, 2024 14:06
// Ignore other files in the e2e directory (the README, for instance)
if (file.endsWith(".test.ts")) {
tasks.add(
`pnpm test:e2e --log-order=stream --summarize --filter wrangler --concurrency 1 -- run ./e2e/${file}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we could run the build task once at at the start of the run, and then use the --only flag here to avoid dumping all the build output out each time (even though it is full turbo)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR maintenance Maintenance task
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants