Skip to content

Commit

Permalink
Merge branch 'develop' into update/ecommerce-1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mamatharao05 authored Dec 12, 2024
2 parents 7682957 + 9d5dea0 commit 513d46e
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 79 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/cypress-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ jobs:
echo '{"wpVersion": "${{ matrix.wpVersion }}","phpVersion": "${{ matrix.phpVersion }}"}' > cypress.env.json
- name: Install WordPress
run: npx wp-env start --debug
uses: nick-fields/retry@v3
with:
timeout_minutes: 4
max_attempts: 3
command: npx wp-env start --debug

- name: Run Cypress Tests
if: ${{ github.repository != 'newfold-labs/wp-plugin-hostgator' || github.actor == 'dependabot[bot]' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ jobs:
run: echo '{"config":{"WP_DEBUG_DISPLAY":false},"plugins":["${{ steps.workflow.outputs.DIST }}/${{ steps.workflow.outputs.PACKAGE }}"]}' > .wp-env.override.json

- name: Install WordPress
run: npx wp-env start --debug
uses: nick-fields/retry@v3
with:
timeout_minutes: 4
max_attempts: 3
command: npx wp-env start --debug

- name: Run Cypress Tests
if: ${{ github.repository != 'newfold-labs/wp-plugin-hostgator' || github.actor == 'dependabot[bot]' }}
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@
"doctrine/inflector": "1.4.4 as 1.3.1",
"newfold-labs/wp-module-activation": "^1.0.5",
"newfold-labs/wp-module-atomic": "^1.3",
"newfold-labs/wp-module-coming-soon": "^1.3.1",
"newfold-labs/wp-module-coming-soon": "^1.3.2",
"newfold-labs/wp-module-context": "^1.0.1",
"newfold-labs/wp-module-data": "^2.6.7",
"newfold-labs/wp-module-data": "^2.6.8",
"newfold-labs/wp-module-deactivation": "^1.2.3",
"newfold-labs/wp-module-ecommerce": "^1.4.5",
"newfold-labs/wp-module-features": "^1.4.2",
"newfold-labs/wp-module-global-ctb": "^1.0.13",
"newfold-labs/wp-module-help-center": "^2.2.1",
"newfold-labs/wp-module-help-center": "^2.2.2",
"newfold-labs/wp-module-loader": "^1.0.10",
"newfold-labs/wp-module-marketplace": "^2.4.0",
"newfold-labs/wp-module-migration": "^1.0.12",
"newfold-labs/wp-module-notifications": "^1.6.6",
"newfold-labs/wp-module-onboarding": "^2.5.5",
"newfold-labs/wp-module-patterns": "^2.8.0",
"newfold-labs/wp-module-patterns": "^2.8.1",
"newfold-labs/wp-module-performance": "2.0.1 as 1.9.9",
"newfold-labs/wp-module-runtime": "^1.0.12",
"newfold-labs/wp-module-secure-passwords": "^1.1.1",
Expand Down
62 changes: 52 additions & 10 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module.exports = defineConfig({
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {

const semver = require('semver');

// Ensure that the base URL is always properly set.
if (config.env && config.env.baseUrl) {
config.baseUrl = config.env.baseUrl;
Expand All @@ -56,17 +54,27 @@ module.exports = defineConfig({
}
}

// Exclude tests for WordPress lower than 6.5 (6.4 or 6.3) or PHP lower than 7.4 (7.1, 7.2 and 7.3)
if (
semver.satisfies( config.env.wpSemverVersion, '<6.5.0' ) ||
semver.satisfies( config.env.phpSemverVersion, '<7.4.0' )
) {
// Tests require Wondor Theme, exclude if not supported due to WP or PHP versions
if ( ! supportsWonderTheme( config.env ) ) {
config.excludeSpecPattern = config.excludeSpecPattern.concat( [
'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/**', // Onboarding requires Wonder Theme
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/ecommerce-next-steps.cy.js', // Requires Onboarding
] );
}

// Tests requires Woo, so exclude if not supported due to WP or PHP versions
if ( ! supportsWoo( config.env ) ) {
config.excludeSpecPattern = config.excludeSpecPattern.concat( [
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Site-Capabilities/**',
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/homePageWithWoo.cy.js',
'vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/ecommerce-next-steps.cy.js', // Skip this since Onboarding does not support this version
'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/**', // Onboarding requires WP 6.5 or greater, as it uses the Wonder Theme which has the same requirement
'vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js', // woo is required and is not supported in older WP or PHP
'vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon-woo.cy.js',
] );
}

// Test requires Jetpack, so exclude if not supported due to WP or PHP versions
if ( ! supportsJetpack( config.env ) ) {
config.excludeSpecPattern = config.excludeSpecPattern.concat( [
'vendor/newfold-labs/wp-module-solutions/tests/cypress/integration/wp-plugins-installation-check.cy.js',
] );
}

Expand All @@ -88,3 +96,37 @@ module.exports = defineConfig({
retries: 1,
experimentalMemoryManagement: true,
})

// Check against plugin support at https://wordpress.org/plugins/woocommerce/
const supportsWoo = ( env ) => {
const semver = require( 'semver' );
if (
semver.satisfies( env.wpSemverVersion, '>=6.5.0' ) &&
semver.satisfies( env.phpSemverVersion, '>=7.4.0' )
) {
return true;
}
return false;
};
// Check against plugin support at https://wordpress.org/plugins/jetpack/
const supportsJetpack = ( env ) => {
const semver = require( 'semver' );
if (
semver.satisfies( env.wpSemverVersion, '>=6.6.0' ) &&
semver.satisfies( env.phpSemverVersion, '>=7.2.0' )
) {
return true;
}
return false;
};
// Check against theme support at https://github.com/newfold-labs/yith-wonder/blob/master/style.css
const supportsWonderTheme = ( env ) => {
const semver = require( 'semver' );
if (
semver.satisfies( env.wpSemverVersion, '>=6.5.0' ) &&
semver.satisfies( env.phpSemverVersion, '>=7.0.0' )
) {
return true;
}
return false;
};
102 changes: 80 additions & 22 deletions package-lock.json

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

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"@newfold-labs/wp-module-ecommerce": "^1.4.5",
"@newfold-labs/wp-module-runtime": "^1.0.12",
"@newfold/ui-component-library": "^1.1.0",
"@reduxjs/toolkit": "^2.3.0",
"@wordpress/compose": "^7.12.0",
"@reduxjs/toolkit": "^2.5.0",
"@wordpress/compose": "^7.14.0",
"@wordpress/dom-ready": "^4.13.0",
"@wordpress/element": "^6.13.0",
"@wordpress/i18n": "^5.12.0",
"@wordpress/icons": "^10.12.0",
"@wordpress/i18n": "^5.14.0",
"@wordpress/icons": "^10.14.0",
"ajv": "^8.17.1",
"classnames": "^2.5.1",
"jquery": "^3.7.1",
Expand All @@ -39,7 +39,7 @@
"@automattic/babel-plugin-preserve-i18n": "^1.0.0",
"@tailwindcss/forms": "^0.5.7",
"@testing-library/cypress": "^10.0.2",
"@wordpress/env": "^10.12.0",
"@wordpress/env": "^10.14.0",
"@wordpress/scripts": "^30.6.0",
"cypress": "^13.16.0",
"cypress-axe": "1.5.0",
Expand Down Expand Up @@ -71,6 +71,7 @@
"php-deps": "composer install --no-dev --optimize-autoloader",
"postprepare": "npm run set-wp-version",
"prebuild:cleanup": "rm -rf ./build ./wp-plugin-hostgator ./wp-plugin-hostgator.zip ./vendor",
"set-version-bump": "node ./set-version-bump.js && npm i && rm -rf ./build && npm run build && composer run i18n",
"set-wp-version": "node ./set-latest-wp-version.js",
"srb": "npm run simulate-runner-build",
"simulate-runner-build": "npm run prebuild:cleanup && npm i && npm run php-deps && npm run build && npm run create:dist && npm run create:zip",
Expand Down
32 changes: 32 additions & 0 deletions set-version-bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require( 'fs' );
const semver = require( 'semver' );
const packagefile = './package.json';
const pluginfile = './wp-plugin-hostgator.php';

if ( fs.existsSync( packagefile ) && fs.existsSync( pluginfile ) ) {
const packageData = require( packagefile );
const currentVersion = packageData.version;
let type = process.argv[ 2 ];
if ( ! [ 'major', 'minor', 'patch' ].includes( type ) ) {
type = 'patch';
}

const newVersion = semver.inc( packageData.version, type );
packageData.version = newVersion;
fs.writeFileSync( packagefile, JSON.stringify( packageData, null, 4 ) );

fs.readFile( pluginfile, 'utf8', function ( err, data ) {
if ( err ) {
return console.log( err );
}
const result = data.replaceAll( currentVersion, newVersion );

fs.writeFile( pluginfile, result, 'utf8', function ( err ) {
if ( err ) {
return console.log( err );
}
} );
} );

console.log( 'Version updated', currentVersion, '=>', newVersion );
}
Loading

0 comments on commit 513d46e

Please sign in to comment.