Skip to content

Commit

Permalink
Set WP and WC versions using the cypress:setup command
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Oct 11, 2023
1 parent a69af24 commit 3d98c6b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
matrix:
testGroup: ['@slow', '-@slow']
core:
- {name: 'WP latest', version: 'latest'}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.0'}
- {name: 'WP latest', version: '', wcVersion: ''}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.0', wcVersion: '8.0.3'}

steps:
- name: Checkout
Expand Down Expand Up @@ -68,17 +68,14 @@ jobs:
- name: Install dependencies
run: npm ci --include=dev

- name: Set the core version
run: ./bin/set-core-version.js ${{ matrix.core.version }}

- name: Set up WP environment with Elasticsearch
run: npm run env:start

- name: Build asset
run: npm run build

- name: Set up database
run: npm run cypress:setup
run: npm run cypress:setup -- --wp-version=${{ matrix.core.version }} --wc-version=${{ matrix.core.wcVersion }}

- name: Test
run: npm run cypress:run -- --env grepTags=${{ matrix.testGroup }}
Expand Down
18 changes: 18 additions & 0 deletions bin/setup-cypress-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
EP_HOST=""
ES_SHIELD=""
EP_INDEX_PREFIX=""
WP_VERSION=""
WC_VERSION=""
DISPLAY_HELP=0

for opt in "$@"; do
Expand All @@ -18,6 +20,12 @@ for opt in "$@"; do
-u=*|--ep-index-prefix=*)
EP_INDEX_PREFIX="${opt#*=}"
;;
-wp=*|--wp-version=*)
WP_VERSION="${opt#*=}"
;;
-wc=*|--wc-version=*)
WC_VERSION="${opt#*=}"
;;
-h|--help|*)
DISPLAY_HELP=1
;;
Expand All @@ -34,10 +42,20 @@ if [ $DISPLAY_HELP -eq 1 ]; then
echo "-h=*, --ep-host=* The remote Elasticsearch Host URL."
echo "-s=*, --es-shield=* The Elasticsearch credentials, used in the ES_SHIELD constant."
echo "-u=*, --ep-index-prefix=* The Elasticsearch credentials, used in the EP_INDEX_PREFIX constant."
echo "-W=*, --wp-version=* WordPress Core version."
echo "-w=*, --wc-version=* WooCommerce version."
echo "-h|--help Display this help screen"
exit
fi

if [ ! -z $WC_VERSION ]; then
./bin/wp-env-cli tests-wordpress "wp --allow-root plugin update woocommerce --version=${WC_VERSION}"
fi

if [ ! -z $WP_VERSION ]; then
./bin/wp-env-cli tests-wordpress "wp --allow-root core update --version=${WP_VERSION} --force"
fi

if [ -z $EP_HOST ]; then
# Determine what kind of env we're in
if [ "$(uname | tr '[:upper:]' '[:lower:]')" = "darwin" ]; then
Expand Down

0 comments on commit 3d98c6b

Please sign in to comment.