From 3921ba60c98119508ad75c0b1a0ed0e3216addf9 Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Fri, 9 Aug 2024 15:31:59 +0530 Subject: [PATCH] Update E2E workflow to use zip built by generate zip action. --- .github/workflows/e2e.yml | 19 ++++++++++++-- tests/bin/set-core-version.js | 48 ++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index db40edc..9985810 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -10,7 +10,11 @@ on: - develop jobs: + build: + uses: mailchimp/wordpress/.github/workflows/build-release-zip.yml@develop + cypress: + needs: build name: ${{ matrix.core.name }} runs-on: ubuntu-latest env: @@ -27,6 +31,16 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Download build zip + uses: actions/download-artifact@v4 + with: + name: ${{ github.event.repository.name }} + path: ${{ github.event.repository.name }} + + - name: Display structure of downloaded files + run: ls -R + working-directory: ${{ github.event.repository.name }} + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' @@ -34,8 +48,8 @@ jobs: - name: Install dependencies run: npm ci - - name: Set the core version - run: ./tests/bin/set-core-version.js ${{ matrix.core.version }} + - name: Set the core version and plugins config + run: ./tests/bin/set-core-version.js --core=${{ matrix.core.version }} --plugins=./${{ github.event.repository.name }} - name: Set up WP environment run: npm run env:start @@ -44,6 +58,7 @@ jobs: run: npm run cypress:run - name: Update summary + if: always() run: | npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json rm -rf ./tests/cypress/reports/mochawesome-*.json diff --git a/tests/bin/set-core-version.js b/tests/bin/set-core-version.js index f320701..abe61c4 100755 --- a/tests/bin/set-core-version.js +++ b/tests/bin/set-core-version.js @@ -1,34 +1,46 @@ #!/usr/bin/env node const fs = require( 'fs' ); -const { exit } = require( 'process' ); -const path = `${ process.cwd() }/.wp-env.override.json`; +const path = `${ process.cwd() }/.wp-env.json`; -// eslint-disable-next-line import/no-dynamic-require -const config = fs.existsSync( path ) ? require( path ) : {}; +let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.' ] }; -const args = process.argv.slice( 2 ); +const args = {}; +process.argv + .slice(2, process.argv.length) + .forEach( arg => { + if (arg.slice(0,2) === '--') { + const param = arg.split('='); + const paramName = param[0].slice(2,param[0].length); + const paramValue = param.length > 1 ? param[1] : true; + args[paramName] = paramValue; + } + }); -if ( args.length === 0 ) exit( 0 ); +if ( ! args.core && ! args.plugins ) { + return; +} + +if ( 'latest' === args.core ) { + delete args.core; +} -if ( args[ 0 ] === 'latest' ) { - if ( fs.existsSync( path ) ) { - fs.unlinkSync( path ); - } - exit( 0 ); +if( Object.keys(args).length === 0 ) { + return; } -config.core = args[ 0 ]; +if ( args.plugins ) { + args.plugins = args.plugins.split(','); +} -// eslint-disable-next-line no-useless-escape -if ( ! config.core.match( /^WordPress\/WordPress\#/ ) ) { - config.core = `WordPress/WordPress#${ config.core }`; +config = { + ...config, + ...args, } try { - fs.writeFileSync( path, JSON.stringify( config ) ); + fs.writeFileSync( path, JSON.stringify( config ) ); } catch ( err ) { - // eslint-disable-next-line no-console - console.error( err ); + console.error( err ); }