Skip to content

Commit

Permalink
feat: add experimental Next.js, with Workers assets, template (#6830)
Browse files Browse the repository at this point in the history
* feat: add experimental Next.js, with Workers assets, template

This template uses the new `@opennextjs/cloudflare` adaptor.

* test: add support for e2e testing of experimental frameworks and workers

* ci: Run C3 experimental e2e tests in CI

* ci: remove unnecessary build step from C3 e2e job

Not only is this unnecessary, the cached does not even get used by the e2e step that follows
(probably because the env vars change) so it adds extra time to these jobs.

* add logging to c3 e2e test failures

* ci: write json test results to the correct directory

* test: do not run experimental next.js template e2e tests on Windows
  • Loading branch information
petebacondarwin authored Sep 26, 2024
1 parent 7ede181 commit 0195621
Show file tree
Hide file tree
Showing 17 changed files with 733 additions and 496 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-eels-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

feat: add experimental Next.js, with Workers assets, template
21 changes: 9 additions & 12 deletions .github/actions/run-c3-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
quarantine:
description: "Whether to run the tests in quarantine mode"
required: false
experimental:
description: "Whether to run the tests in experimental mode"
required: false
framework:
description: "When specified, will only run tests for this framework"
required: false
Expand Down Expand Up @@ -39,21 +42,15 @@ runs:
git config --global user.email [email protected]
git config --global user.name 'Wrangler automated PR updater'
- name: Build
shell: bash
run: pnpm run build
env:
NODE_ENV: "production"
CI_OS: ${{ runner.os }}

- name: E2E Tests
- name: E2E Tests ${{inputs.experimental && '(experimental)' || ''}}
id: run-e2e
shell: bash
run: pnpm run test:e2e --filter create-cloudflare
env:
CLOUDFLARE_API_TOKEN: ${{ inputs.apiToken }}
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.accountId }}
E2E_QUARANTINE: ${{ inputs.quarantine }}
E2E_EXPERIMENTAL: ${{ inputs.experimental }}
FRAMEWORK_CLI_TO_TEST: ${{ inputs.framework }}
TEST_PM: ${{ inputs.packageManager }}
TEST_PM_VERSION: ${{ inputs.packageManagerVersion }}
Expand All @@ -64,15 +61,15 @@ runs:
uses: actions/upload-artifact@v3
if: always()
with:
name: e2e-logs-${{matrix.os}}
path: packages/create-cloudflare/.e2e-logs
name: e2e-logs${{inputs.experimental && '-experimental' || ''}}-${{matrix.os}}
path: packages/create-cloudflare/.e2e-logs${{inputs.experimental && '-experimental' || ''}}

- name: Upload Framework Diffs
if: ${{ steps.run-e2e.outcome == 'success' && inputs.saveDiffs == 'true' }}
uses: actions/upload-artifact@v3
with:
name: e2e-framework-diffs
path: packages/create-cloudflare/.e2e-diffs
name: e2e-framework-diffs${{inputs.experimental && '-experimental' || ''}}
path: packages/create-cloudflare/.e2e-diffs${{inputs.experimental && '-experimental' || ''}}
overwrite: true

- name: Fail if errors detected
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/c3-e2e-experimental.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Runs c3 e2e tests on pull requests with c3 changes

name: C3 E2E Tests (experimental)
on:
pull_request:
paths:
- packages/create-cloudflare/**
push:
branches:
- main
paths:
- packages/create-cloudflare/**

jobs:
e2e:
# Note: please keep this job in sync with the e2e-only-dependabot-bumped-framework one
#  in .github/workflows/c3-e2e-dependabot.yml
timeout-minutes: 45
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.pm.name }}-${{ matrix.pm.version }}
cancel-in-progress: true
name: ${{ format('Run experimental tests for {0}@{1} on {2}', matrix.pm.name, matrix.pm.version, matrix.os) }}
if: github.repository_owner == 'cloudflare' && github.event.pull_request.user.login != 'dependabot[bot]'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pm:
[
{ name: npm, version: "0.0.0" },
{ name: pnpm, version: "9.10.0" },
{ name: bun, version: "1.0.3" },
{ name: yarn, version: "1.0.0" },
]
# include a single windows test with pnpm
include:
- os: windows-latest
pm: { name: pnpm, version: "9.10.0" }
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: E2E Tests
uses: ./.github/actions/run-c3-e2e
with:
packageManager: ${{ matrix.pm.name }}
packageManagerVersion: ${{ matrix.pm.version }}
quarantine: false
experimental: true
accountId: ${{ secrets.C3_TEST_CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.C3_TEST_CLOUDFLARE_API_TOKEN }}
# We only need to do this once per-framework per-run, so avoid re-running for each package manager and os
saveDiffs: ${{ github.head_ref == 'changeset-release/main' && matrix.pm.name == 'pnpm' && matrix.os == 'ubuntu-latest'}}
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dist-functions
vscode.d.ts
vscode.*.d.ts

.e2e-logs
.e2e-logs*
templates/*/build
templates/*/dist

Expand Down
1 change: 1 addition & 0 deletions packages/create-cloudflare/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
# E2E_RETRIES=0 # the number of retries for framework e2e tests
# 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)
# SAVE_DIFFS=true # flag to trigger the diffs saving during the e2es process
# E2E_EXPERIMENTAL=true # flag to run only experimental framework e2e tests
4 changes: 2 additions & 2 deletions packages/create-cloudflare/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
node_modules
/dist
create-cloudflare-*.tgz
/.e2e-logs/*
/.e2e-diffs/*
/.e2e-logs*/*
/.e2e-diffs*/*

.DS_Store

Expand Down
7 changes: 4 additions & 3 deletions packages/create-cloudflare/e2e-tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@ import {
import type { WriteStream } from "fs";
import type { Suite } from "vitest";

const experimental = Boolean(process.env.E2E_EXPERIMENTAL);
const frameworkToTest = getFrameworkToTest({ experimental: false });

// Note: skipIf(frameworkToTest) makes it so that all the basic C3 functionality
// tests are skipped in case we are testing a specific framework
describe.skipIf(frameworkToTest || isQuarantineMode())(
describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
"E2E: Basic C3 functionality ",
() => {
const tmpDirPath = realpathSync(mkdtempSync(join(tmpdir(), "c3-tests")));
const projectPath = join(tmpDirPath, "basic-tests");
let logStream: WriteStream;

beforeAll((ctx) => {
recreateLogFolder(ctx as Suite);
recreateLogFolder({ experimental }, ctx as Suite);
});

beforeEach((ctx) => {
rmSync(projectPath, { recursive: true, force: true });
logStream = createTestLogStream(ctx);
logStream = createTestLogStream({ experimental }, ctx);
});

afterEach(() => {
Expand Down
Loading

0 comments on commit 0195621

Please sign in to comment.