Skip to content

Commit

Permalink
Update E2E workflow to use zip built by generate zip action.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Aug 9, 2024
1 parent 86e9489 commit 3921ba6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,15 +31,25 @@ 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'

- 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
Expand All @@ -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
Expand Down
48 changes: 30 additions & 18 deletions tests/bin/set-core-version.js
Original file line number Diff line number Diff line change
@@ -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 );
}

0 comments on commit 3921ba6

Please sign in to comment.