Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E test on build zip #205

Merged
merged 8 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Build release zip

on:
workflow_dispatch:
workflow_call:
push:
branches:
- trunk
Expand All @@ -13,7 +14,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

faisal-alvi marked this conversation as resolved.
Show resolved Hide resolved
faisal-alvi marked this conversation as resolved.
Show resolved Hide resolved
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches:
- develop
jobs:
build:
uses: 10up/simple-local-avatars/.github/workflows/build-release-zip.yml@update/181 # TODO: Update this to develop branch before merge.
faisal-alvi marked this conversation as resolved.
Show resolved Hide resolved
cypress:
needs: build
name: ${{ matrix.core.name }}
runs-on: ubuntu-latest
strategy:
Expand All @@ -17,16 +20,32 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build zip
uses: actions/download-artifact@v3
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 }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
node_modules
~/.cache
~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm install
- name: Composer (optional)
run: composer install
continue-on-error: true
- name: Build (optional)
run: npm run build
continue-on-error: true
- 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-wp-config.js --core=${{ matrix.core.version }} --plugins=./${{ github.event.repository.name }}
- name: Set up WP environment
run: npm run env:start
- name: Test
Expand Down
31 changes: 0 additions & 31 deletions tests/bin/set-core-version.js

This file was deleted.

46 changes: 46 additions & 0 deletions tests/bin/set-wp-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

const fs = require( 'fs' );

const path = `${ process.cwd() }/.wp-env.json`;

let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.' ] };

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.core && ! args.plugins ) {
return;
}

if ( 'latest' === args.core ) {
delete args.core;
}

if( Object.keys(args).length === 0 ) {
return;
}

if ( args.plugins ) {
args.plugins = args.plugins.split(',');
}

config = {
...config,
...args,
}

try {
fs.writeFileSync( path, JSON.stringify( config ) );
} catch ( err ) {
console.error( err );
}