Skip to content

Commit 3921ba6

Browse files
committed
Update E2E workflow to use zip built by generate zip action.
1 parent 86e9489 commit 3921ba6

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

.github/workflows/e2e.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ on:
1010
- develop
1111

1212
jobs:
13+
build:
14+
uses: mailchimp/wordpress/.github/workflows/build-release-zip.yml@develop
15+
1316
cypress:
17+
needs: build
1418
name: ${{ matrix.core.name }}
1519
runs-on: ubuntu-latest
1620
env:
@@ -27,15 +31,25 @@ jobs:
2731
- name: Checkout
2832
uses: actions/checkout@v4
2933

34+
- name: Download build zip
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: ${{ github.event.repository.name }}
38+
path: ${{ github.event.repository.name }}
39+
40+
- name: Display structure of downloaded files
41+
run: ls -R
42+
working-directory: ${{ github.event.repository.name }}
43+
3044
- uses: actions/setup-node@v4
3145
with:
3246
node-version-file: '.nvmrc'
3347

3448
- name: Install dependencies
3549
run: npm ci
3650

37-
- name: Set the core version
38-
run: ./tests/bin/set-core-version.js ${{ matrix.core.version }}
51+
- name: Set the core version and plugins config
52+
run: ./tests/bin/set-core-version.js --core=${{ matrix.core.version }} --plugins=./${{ github.event.repository.name }}
3953

4054
- name: Set up WP environment
4155
run: npm run env:start
@@ -44,6 +58,7 @@ jobs:
4458
run: npm run cypress:run
4559

4660
- name: Update summary
61+
if: always()
4762
run: |
4863
npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json
4964
rm -rf ./tests/cypress/reports/mochawesome-*.json

tests/bin/set-core-version.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
#!/usr/bin/env node
22

33
const fs = require( 'fs' );
4-
const { exit } = require( 'process' );
54

6-
const path = `${ process.cwd() }/.wp-env.override.json`;
5+
const path = `${ process.cwd() }/.wp-env.json`;
76

8-
// eslint-disable-next-line import/no-dynamic-require
9-
const config = fs.existsSync( path ) ? require( path ) : {};
7+
let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.' ] };
108

11-
const args = process.argv.slice( 2 );
9+
const args = {};
10+
process.argv
11+
.slice(2, process.argv.length)
12+
.forEach( arg => {
13+
if (arg.slice(0,2) === '--') {
14+
const param = arg.split('=');
15+
const paramName = param[0].slice(2,param[0].length);
16+
const paramValue = param.length > 1 ? param[1] : true;
17+
args[paramName] = paramValue;
18+
}
19+
});
1220

13-
if ( args.length === 0 ) exit( 0 );
21+
if ( ! args.core && ! args.plugins ) {
22+
return;
23+
}
24+
25+
if ( 'latest' === args.core ) {
26+
delete args.core;
27+
}
1428

15-
if ( args[ 0 ] === 'latest' ) {
16-
if ( fs.existsSync( path ) ) {
17-
fs.unlinkSync( path );
18-
}
19-
exit( 0 );
29+
if( Object.keys(args).length === 0 ) {
30+
return;
2031
}
2132

22-
config.core = args[ 0 ];
33+
if ( args.plugins ) {
34+
args.plugins = args.plugins.split(',');
35+
}
2336

24-
// eslint-disable-next-line no-useless-escape
25-
if ( ! config.core.match( /^WordPress\/WordPress\#/ ) ) {
26-
config.core = `WordPress/WordPress#${ config.core }`;
37+
config = {
38+
...config,
39+
...args,
2740
}
2841

2942
try {
30-
fs.writeFileSync( path, JSON.stringify( config ) );
43+
fs.writeFileSync( path, JSON.stringify( config ) );
3144
} catch ( err ) {
32-
// eslint-disable-next-line no-console
33-
console.error( err );
45+
console.error( err );
3446
}

0 commit comments

Comments
 (0)