Skip to content

Commit 0a5bb5a

Browse files
refactor: run C3 e2e tests more easily locally and individually (#9533)
* fix: ensure that the `sourcemap-codec` library has been transformed correctly to be imported in workerd during Vitest runs Prior to this the inline snapshot tests were failing because they use the `magic-string` library, which in turn relies upon the `sourcemap-codec` library. This resulted in errors that look like: ``` Error running worker: SyntaxError: The requested module '@jridgewell/sourcemap-codec' does not provide an export named 'encode' ``` * refactor: run C3 e2e tests more easily locally and individually * fixup! refactor: run C3 e2e tests more easily locally and individually * move to-exist helper back to setup file * rename the filtering env vars * fixup! refactor: run C3 e2e tests more easily locally and individually * fix c3 e2e ci groups * remove unnecessary step * skip gatsby on yarn * Run windows tests in a normal directory * skip Workers tests on Windows * match the previous test descriptions
1 parent 45e97e8 commit 0a5bb5a

File tree

54 files changed

+2050
-1941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2050
-1941
lines changed

.changeset/six-lizards-retire.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@cloudflare/vitest-pool-workers": patch
3+
---
4+
5+
fix: ensure that the `sourcemap-codec` library has been transformed correctly to be imported in workerd during Vitest runs
6+
7+
Prior to this the inline snapshot tests were failing because they use the `magic-string` library, which in turn relies upon the `sourcemap-codec` library.
8+
9+
This resulted in errors that look like:
10+
11+
```
12+
Error running worker: SyntaxError: The requested module '@jridgewell/sourcemap-codec' does not provide an export named 'encode'
13+
```

.github/actions/run-c3-e2e/action.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/c3-e2e-quarantine.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/c3-e2e.yml

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,33 @@ env:
99

1010
jobs:
1111
e2e:
12-
# Note: please keep this job in sync with the e2e-only-dependabot-bumped-framework one
13-
#  in .github/workflows/c3-e2e-dependabot.yml
12+
# Runs the non-frameworks C3 E2E tests on all supported operating systems and package managers.
1413
timeout-minutes: 45
1514
concurrency:
16-
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.pm.name }}-${{ matrix.pm.version }}
15+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os.name }}-${{ matrix.pm.name }}-${{ matrix.pm.version }}${{ matrix.experimental && '-experimental' || '' }}
1716
cancel-in-progress: true
18-
name: ${{ format('C3 ({0})', matrix.description) }}
17+
name: ${{ format('C3 ({0}, {1}{2})', matrix.pm.name, matrix.os.description, matrix.experimental && ', experimental' || '') }}
1918
strategy:
2019
fail-fast: false
2120
matrix:
22-
include:
23-
- os: windows-latest
24-
description: pnpm, Windows
25-
pm: { name: pnpm, version: "9.12.0" }
26-
- os: ubuntu-latest
27-
description: npm, Linux
21+
experimental: [true, false]
22+
os:
23+
[
24+
{ name: windows-latest, description: Windows },
25+
{ name: ubuntu-latest, description: Linux },
26+
]
27+
pm:
28+
[
29+
{ name: npm, version: "0.0.0" },
30+
{ name: yarn, version: "1.0.0" },
31+
{ name: pnpm, version: "9.12.0" },
32+
]
33+
exclude:
34+
- os: { name: windows-latest, description: Windows }
2835
pm: { name: npm, version: "0.0.0" }
29-
- os: ubuntu-latest
30-
description: yarn, Linux
36+
- os: { name: windows-latest, description: Windows }
3137
pm: { name: yarn, version: "1.0.0" }
32-
- os: ubuntu-latest
33-
description: pnpm, Linux
34-
pm: { name: pnpm, version: "9.12.0" }
35-
runs-on: ${{ matrix.os }}
38+
runs-on: ${{ matrix.os.name }}
3639
steps:
3740
- name: Checkout Repo
3841
uses: actions/checkout@v4
@@ -45,6 +48,7 @@ jobs:
4548
filters: |
4649
everything_but_markdown:
4750
- '!**/*.md'
51+
4852
- name: Install Dependencies
4953
if: steps.changes.outputs.everything_but_markdown == 'true'
5054
uses: ./.github/actions/install-dependencies
@@ -60,26 +64,30 @@ jobs:
6064
env:
6165
GITHUB_TOKEN: ${{ github.token }}
6266

63-
- name: E2E Tests (experimental)
64-
if: steps.changes.outputs.everything_but_markdown == 'true'
65-
uses: ./.github/actions/run-c3-e2e
66-
with:
67-
node-version: ${{ env.NODE_VERSION }}
68-
packageManager: ${{ matrix.pm.name }}
69-
packageManagerVersion: ${{ matrix.pm.version }}
70-
quarantine: false
71-
experimental: true
72-
accountId: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
73-
apiToken: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
67+
# Needed because gatsby requires git
68+
- name: Configure Git
69+
shell: bash
70+
run: |
71+
git config --global user.email [email protected]
72+
git config --global user.name 'Wrangler Tester'
7473
75-
- name: E2E Tests (non-experimental)
74+
- id: run-e2e
7675
if: steps.changes.outputs.everything_but_markdown == 'true'
77-
uses: ./.github/actions/run-c3-e2e
76+
shell: bash
77+
run: pnpm run test:e2e:c3
78+
env:
79+
NODE_VERSION: ${{ env.NODE_VERSION }}
80+
CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
81+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
82+
E2E_EXPERIMENTAL: ${{ matrix.experimental }}
83+
E2E_TEST_PM: ${{ matrix.pm.name }}
84+
E2E_TEST_PM_VERSION: ${{ matrix.pm.version }}
85+
CI_OS: ${{ runner.os }}
86+
87+
- name: Upload Logs
88+
uses: actions/upload-artifact@v4
89+
if: ${{ !cancelled() }}
7890
with:
79-
node-version: ${{ env.NODE_VERSION }}
80-
packageManager: ${{ matrix.pm.name }}
81-
packageManagerVersion: ${{ matrix.pm.version }}
82-
quarantine: false
83-
experimental: false
84-
accountId: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
85-
apiToken: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
91+
name: e2e-logs${{matrix.experimental == 'true' && '-experimental' || ''}}-${{runner.os}}-${{matrix.pm.name}}
92+
path: packages/create-cloudflare/.e2e-logs${{matrix.experimental == 'true' && '-experimental' || ''}}
93+
include-hidden-files: true

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"cloudflareaccess",
1212
"cloudflared",
1313
"Codespaces",
14+
"endgroup",
1415
"esbuild",
1516
"eslintcache",
1617
"execa",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"test": "dotenv -- turbo test",
2424
"test:ci": "dotenv -- turbo test:ci",
2525
"test:e2e": "dotenv -- turbo test:e2e",
26-
"test:e2e:wrangler": "node -r esbuild-register tools/e2e/runIndividualE2EFiles.ts",
26+
"test:e2e:c3": "dotenv -- node -r esbuild-register packages/create-cloudflare/scripts/e2e/run-tests.ts",
27+
"test:e2e:wrangler": "dotenv -- node -r esbuild-register tools/e2e/runIndividualE2EFiles.ts",
2728
"test:watch": "turbo test:watch",
2829
"type:tests": "dotenv -- turbo type:tests"
2930
},
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# rename/copy this file to .env to control the local c3 process
22
# (currently used only to control the behavior of the e2es locally)
33

4-
# CLOUDFLARE_API_TOKEN=? # the cloudflare api token needed for the deployment of projects
5-
# CLOUDFLARE_ACCOUNT_ID=? # the id of the account needed for the deployment of projects
6-
# FRAMEWORK_CLI_TO_TEST=? # the name of the cli of the _only_ framework to run e2e tests for
7-
# E2E_PROJECT_PATH=? # the path were to build the projects (for easier debugging, instead of having to find the tmpdir)
8-
# E2E_RETRIES=0 # the number of retries for framework e2e tests
9-
# E2E_NO_DEPLOY=true # flag to skip the deployment step in the e2es (for easier debugging, where the deployment is not relevant to current changes)
10-
# E2E_EXPERIMENTAL=true # flag to run only experimental framework e2e tests
4+
# CLOUDFLARE_API_TOKEN=? # the cloudflare api token needed for the deployment of projects
5+
# CLOUDFLARE_ACCOUNT_ID=? # the id of the account needed for the deployment of projects (defaults to the DevProd testing account)
6+
# E2E_WORKER_TEMPLATE_TO_TEST=hello-world:ts # Run only worker e2e tests that match this pattern
7+
# E2E_FRAMEWORK_TEMPLATE_TO_TEST=next # Run only framework e2e tests that match this pattern
8+
# E2E_TEST_PM=npm # the package manager to simulate the e2e tests
9+
# E2E_PROJECT_PATH=./temp/e2e # a path to where to generate the projects (for easier debugging, instead of having to find the tmpdir)
10+
# E2E_TEST_RETRIES=0 # the number of retries for framework e2e tests
11+
# E2E_RUN_DEPLOY_TESTS=false # flag to skip the deployment step in the e2es (for easier debugging, where the deployment is not relevant to current changes)
12+
# E2E_EXPERIMENTAL=true # flag to run only experimental framework e2e tests

packages/create-cloudflare/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
ignorePatterns: [
55
"dist",
66
"scripts",
7-
"e2e-tests/fixtures/*",
7+
"e2e/**/fixtures/**",
88
"**/templates*/**/*.*",
99
// template files are ignored by the eslint-config-worker configuration
1010
// we do however want the c3 files to be linted

0 commit comments

Comments
 (0)