Skip to content

Commit

Permalink
Merge pull request #227 from 10up/update/207
Browse files Browse the repository at this point in the history
E2Eon build zip
  • Loading branch information
Sidsector9 committed Apr 14, 2023
2 parents af12f50 + 4cd9e2f commit 5c0130e
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 40 deletions.
1 change: 1 addition & 0 deletions .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 Down
38 changes: 25 additions & 13 deletions .github/workflows/test-e2e.yml → .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ on:
- develop

jobs:
build:
uses: 10up/simple-podcasting/.github/workflows/build-release-zip.yml@update/207 # TODO: Update this to develop branch.
cypress:
needs: build
runs-on: ubuntu-latest

strategy:
Expand All @@ -23,21 +26,30 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2

- name: install node
uses: actions/setup-node@v3
uses: actions/checkout@v3
- name: Download build zip
uses: actions/download-artifact@v3
with:
node-version-file: .nvmrc

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 ci

- name: Build asset
run: npm run build

- name: Set the core version
run: ./tests/bin/set-core-version.js ${{ matrix.core.version }}
run: npm install
- 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 wp-env start
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Thumbs.db
Desktop.ini

# E2E testing
.wp-env.json
.wp-env.override.json
artifacts
tests/cypress/downloads
tests/cypress/screenshots
Expand Down
3 changes: 3 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["."]
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
]
},
"devDependencies": {
"@10up/cypress-wp-utils": "git+https://github.com/10up/cypress-wp-utils.git#build",
"@10up/cypress-wp-utils": "github:10up/cypress-wp-utils#build",
"@wordpress/env": "^5.4.0",
"@wordpress/prettier-config": "^2.2.0",
"@wordpress/scripts": "^24.3.0",
Expand Down
21 changes: 0 additions & 21 deletions tests/bin/set-core-version.js

This file was deleted.

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

const fs = require('fs');

const path = `${process.cwd()}/.wp-env.override.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);
}

0 comments on commit 5c0130e

Please sign in to comment.