From fd8fbca4fe114c79933d87fd36f862596afe64ae Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Tue, 13 Jun 2023 15:23:32 -0700 Subject: [PATCH] add webpack to e2e (#8602) --- .github/workflows/ci.yml | 15 ++++++++++----- tasks/run-e2e | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9af5cacee3f..72c0e73e072e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,12 +122,14 @@ jobs: tutorial-e2e: needs: check + strategy: matrix: - os: [ubuntu-latest] - fail-fast: true - name: 🌲 Tutorial E2E / ${{ matrix.os }} / node 18 latest - runs-on: ${{ matrix.os }} + bundler: [vite, webpack] + + name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 18 latest + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 @@ -153,7 +155,10 @@ jobs: echo "::set-output name=framework_path::$framework_path" - name: 🌲 Create a Redwood App - run: ./tasks/run-e2e ${{ steps.createpath.outputs.project_path }} --no-start + run: | + ./tasks/run-e2e ${{ steps.createpath.outputs.project_path }} \ + --no-start \ + --bundler ${{ matrix.bundler }} env: YARN_ENABLE_IMMUTABLE_INSTALLS: false diff --git a/tasks/run-e2e b/tasks/run-e2e index c1e6508eae75..847032474c74 100755 --- a/tasks/run-e2e +++ b/tasks/run-e2e @@ -49,7 +49,7 @@ const buildRedwoodFramework = () => { } } -const createRedwoodJSApp = ({ typescript }) => { +const createRedwoodJSApp = ({ typescript, bundler }) => { try { execa.sync( 'yarn node dist/create-redwood-app.js', @@ -86,6 +86,18 @@ const createRedwoodJSApp = ({ typescript }) => { } fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, 2)) + + if (bundler === 'webpack') { + const redwoodTOMLPath = path.join( + REDWOOD_PROJECT_DIRECTORY, + 'redwood.toml' + ) + const redwoodTOML = fs.readFileSync(redwoodTOMLPath, 'utf-8') + fs.writeFileSync( + redwoodTOMLPath, + redwoodTOML.replace('[web]\n', '[web]\n bundler = "webpack"\n') + ) + } } catch (e) { if (e.signal !== 'SIGINT') { console.error('Error: Could not create Redwood Project') @@ -232,6 +244,11 @@ const args = yargs(hideBin(process.argv)) .option('typescript', { default: false, type: 'boolean', alias: 'ts' }) .option('auto-start', { default: true, type: 'boolean', alias: 'start' }) .option('clean-files', { default: true, type: 'boolean' }) + .option('bundler', { + default: 'vite', + type: 'string', + choices: ['vite', 'webpack'], + }) .scriptName('run-e2e') .example('run-e2e') .example('run-e2e /tmp/redwood-app --ts') @@ -260,12 +277,13 @@ let { copyFramework, createProject, typescript, + bundler, autoStart, cleanFiles, } = args const tasks = [ buildFramework && buildRedwoodFramework, - createProject && (() => createRedwoodJSApp({ typescript })), + createProject && (() => createRedwoodJSApp({ typescript, bundler })), copyFramework && addFrameworkDepsToProject, copyFramework && runYarnInstall, copyFramework && copyFrameworkPackages,