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

Always run non-network E2E tests #7872

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ runs:

- name: Install NPM Dependencies
shell: bash
run: pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile --ignore-scripts --prefer-offline
4 changes: 2 additions & 2 deletions .github/workflows/c3-e2e-experimental.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Runs c3 e2e tests on pull requests with c3 changes

name: C3 E2E Tests (experimental)
on:
pull_request:
# on:
# pull_request:

jobs:
e2e:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/c3-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Runs c3 e2e tests on pull requests with c3 changes

name: C3 E2E Tests
on:
pull_request:
# on:
# pull_request:

jobs:
e2e:
Expand Down
145 changes: 145 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: CI

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ci
cancel-in-progress: true

jobs:
build:
name: "Builds"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: Run builds
run: pnpm run build
env:
CI_OS: ${{ runner.os }}

check:
timeout-minutes: 30
name: "Checks"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: ["build"]
steps:
- name: Checkout Repo
if: ${{ steps.cache-repo.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: Check for errors
run: pnpm run check
env:
NODE_OPTIONS: "--max_old_space_size=8192"
CI_OS: ${{ matrix.os }}

- name: Check the changesets
run: node -r esbuild-register tools/deployments/validate-changesets.ts

check-non-linux:
if: github.head_ref == 'changeset-release/main'
timeout-minutes: 30
name: "Checks"
needs: ["build"]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
if: ${{ steps.cache-repo.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: Check for errors
run: pnpm run check
env:
NODE_OPTIONS: "--max_old_space_size=8192"
CI_OS: ${{ matrix.os }}

- name: Check the changesets
run: node -r esbuild-register tools/deployments/validate-changesets.ts

test:
timeout-minutes: 30
needs: ["build"]

name: "Tests"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13]
filter:
[
'--filter="./packages/*" --filter="./fixtures/*" --filter="./packages/vite-plugin-cloudflare/playground"',
]
# Things in the tools folder are for running in CI, and so only need to run on linux
include:
- os: ubuntu-latest
filter: '--filter="./tools"'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
if: ${{ steps.cache-repo.outputs.cache-hit != 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
turbo-api: ${{ secrets.TURBO_API }}
turbo-team: ${{ secrets.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}

- name: Run tests
run: pnpm run test:ci --concurrency 1 ${{ matrix.filter }}
env:
TMP_CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TMP_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
NODE_OPTIONS: "--max_old_space_size=8192"
WRANGLER_LOG_PATH: ${{ runner.temp }}/wrangler-debug-logs/
TEST_REPORT_PATH: ${{ runner.temp }}/test-report/index.html
CI_OS: ${{ runner.os }}
6 changes: 1 addition & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: E2E tests

on:
push:
branches:
- changeset-release/main
pull_request:
types: [synchronize, opened, reopened, labeled, unlabeled]
repository_dispatch:

jobs:
Expand All @@ -14,7 +10,6 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.node }}
cancel-in-progress: true
timeout-minutes: 40
if: (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.*.labels.*.name, 'e2e' ) && github.event.pull_request.head.repo.owner.login == 'cloudflare'))
name: "E2E Test"
strategy:
fail-fast: false
Expand Down Expand Up @@ -54,6 +49,7 @@ jobs:
WRANGLER_LOG_PATH: ${{ runner.temp }}/wrangler-debug-logs/
TEST_REPORT_PATH: ${{ runner.temp }}/test-report/index.html
CI_OS: ${{ matrix.os }}
WRANGLER_E2E_ALLOW_REMOTE: ${{ github.head_ref == 'changeset-release/main' || contains(github.event.*.labels.*.name, 'e2e' ) }}

- name: Upload debug logs
if: always()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-and-check.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Tests + Checks

on:
pull_request:
# on:
# pull_request:

jobs:
add-to-project:
Expand Down
86 changes: 45 additions & 41 deletions packages/wrangler/e2e/c3-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,59 @@ import { readFileSync } from "node:fs";
import path from "node:path";
import { fetch } from "undici";
import { beforeAll, describe, expect, it } from "vitest";
import { ALLOW_REMOTE } from "./helpers/allow-remote";
import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test";
import { generateResourceName } from "./helpers/generate-resource-name";

// TODO: Investigate why this is really flaky on windows
describe.runIf(process.platform !== "win32")("c3 integration", () => {
const helper = new WranglerE2ETestHelper();
const workerName = generateResourceName("c3");
let c3Packed: string;
describe.runIf(process.platform !== "win32" && ALLOW_REMOTE)(
"c3 integration",
() => {
const helper = new WranglerE2ETestHelper();
const workerName = generateResourceName("c3");
let c3Packed: string;

beforeAll(async () => {
const pathToC3 = path.resolve(__dirname, "../../create-cloudflare");
execSync("pnpm pack --pack-destination ./pack", { cwd: pathToC3 });
const versions = execSync("ls -1 pack", {
encoding: "utf-8",
cwd: pathToC3,
beforeAll(async () => {
const pathToC3 = path.resolve(__dirname, "../../create-cloudflare");
execSync("pnpm pack --pack-destination ./pack", { cwd: pathToC3 });
const versions = execSync("ls -1 pack", {
encoding: "utf-8",
cwd: pathToC3,
});
const version = versions.trim().split("\n").at(-1); // get last version
assert(version);
c3Packed = path.join(pathToC3, "pack", version);
});
const version = versions.trim().split("\n").at(-1); // get last version
assert(version);
c3Packed = path.join(pathToC3, "pack", version);
});

it("init project via c3", async () => {
const env = {
...process.env,
WRANGLER_C3_COMMAND: `--package ${c3Packed} dlx create-cloudflare`,
GIT_AUTHOR_NAME: "test-user",
GIT_AUTHOR_EMAIL: "test-user@cloudflare.com",
GIT_COMMITTER_NAME: "test-user",
GIT_COMMITTER_EMAIL: "test-user@cloudflare.com",
};
it("init project via c3", async () => {
const env = {
...process.env,
WRANGLER_C3_COMMAND: `--package ${c3Packed} dlx create-cloudflare`,
GIT_AUTHOR_NAME: "test-user",
GIT_AUTHOR_EMAIL: "test-user@cloudflare.com",
GIT_COMMITTER_NAME: "test-user",
GIT_COMMITTER_EMAIL: "test-user@cloudflare.com",
};

await helper.run(`wrangler init ${workerName} --yes`, {
env,
});
await helper.run(`wrangler init ${workerName} --yes`, {
env,
});

expect(
readFileSync(
path.join(helper.tmpPath, workerName, "wrangler.json"),
"utf8"
)
).not.toContain("<TBD>");
});
expect(
readFileSync(
path.join(helper.tmpPath, workerName, "wrangler.json"),
"utf8"
)
).not.toContain("<TBD>");
});

it("can run `wrangler dev` on generated worker", async () => {
const worker = helper.runLongLived(`wrangler dev`, {
cwd: path.join(helper.tmpPath, workerName),
it("can run `wrangler dev` on generated worker", async () => {
const worker = helper.runLongLived(`wrangler dev`, {
cwd: path.join(helper.tmpPath, workerName),
});
const { url } = await worker.waitForReady();
const res = await fetch(url);
expect(await res.text()).toBe("Hello World!");
});
const { url } = await worker.waitForReady();
const res = await fetch(url);
expect(await res.text()).toBe("Hello World!");
});
});
}
);
3 changes: 2 additions & 1 deletion packages/wrangler/e2e/cert.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomUUID } from "node:crypto";
import * as forge from "node-forge";
import { describe, expect, it } from "vitest";
import { ALLOW_REMOTE } from "./helpers/allow-remote";
import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test";
import { normalizeOutput } from "./helpers/normalize";

Expand Down Expand Up @@ -111,7 +112,7 @@ function generateRootCaCert() {
return { certificate: pemCert, privateKey: pemPrivateKey };
}

describe("cert", () => {
describe.runIf(ALLOW_REMOTE)("cert", () => {
const normalize = (str: string) =>
normalizeOutput(str, {
[process.env.CLOUDFLARE_ACCOUNT_ID as string]: "CLOUDFLARE_ACCOUNT_ID",
Expand Down
5 changes: 3 additions & 2 deletions packages/wrangler/e2e/deployments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import dedent from "ts-dedent";
import { fetch } from "undici";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import { CLOUDFLARE_ACCOUNT_ID } from "./helpers/account-id";
import { ALLOW_REMOTE } from "./helpers/allow-remote";
import { WranglerE2ETestHelper } from "./helpers/e2e-wrangler-test";
import { generateResourceName } from "./helpers/generate-resource-name";
import { normalizeOutput } from "./helpers/normalize";
Expand All @@ -17,7 +18,7 @@ const workerName = generateResourceName();
const dispatchNamespaceName = generateResourceName("dispatch");
const dispatchWorkerName = generateResourceName();

describe("deployments", { timeout: TIMEOUT }, () => {
describe.runIf(ALLOW_REMOTE)("deployments", { timeout: TIMEOUT }, () => {
let deployedUrl: string;
const helper = new WranglerE2ETestHelper();

Expand Down Expand Up @@ -252,7 +253,7 @@ const checkAssets = async (testCases: AssetTestCase[], deployedUrl: string) => {
}
};

describe.each([
describe.runIf(ALLOW_REMOTE).each([
{
name: "regular Worker",
flags: "",
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/e2e/dev-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { execSync } from "child_process";
import dedent from "ts-dedent";
import { beforeEach, describe, expect, it } from "vitest";
import { CLOUDFLARE_ACCOUNT_ID } from "./helpers/account-id";
import { ALLOW_REMOTE } from "./helpers/allow-remote";
import { makeRoot, seed } from "./helpers/setup";
import { WRANGLER_IMPORT } from "./helpers/wrangler";

describe("switching runtimes", () => {
describe.runIf(ALLOW_REMOTE)("switching runtimes", () => {
let root: string;
beforeEach(async () => {
root = await makeRoot();
Expand Down
Loading
Loading