2020-06-17 20:28:11 +00:00
|
|
|
language: generic
|
2018-11-27 17:12:48 +00:00
|
|
|
|
2020-06-17 20:28:11 +00:00
|
|
|
services:
|
|
|
|
- docker
|
2018-11-27 17:12:48 +00:00
|
|
|
|
2019-07-01 12:52:44 +00:00
|
|
|
cache:
|
2020-01-02 09:51:17 +00:00
|
|
|
directories:
|
2020-06-17 20:28:11 +00:00
|
|
|
- $HOME/.jest-cache
|
|
|
|
- $HOME/.nvm/.cache
|
2020-01-02 09:51:17 +00:00
|
|
|
- $HOME/.npm
|
|
|
|
- $HOME/.composer/cache
|
2018-11-27 17:12:48 +00:00
|
|
|
|
2019-12-11 15:04:25 +00:00
|
|
|
branches:
|
2020-01-02 09:51:17 +00:00
|
|
|
only:
|
2020-09-26 17:28:16 +00:00
|
|
|
- trunk
|
2019-12-11 15:04:25 +00:00
|
|
|
|
2020-06-17 20:28:11 +00:00
|
|
|
# Make sure NodeGit gets the correct C libs.
|
|
|
|
addons:
|
|
|
|
apt:
|
|
|
|
sources:
|
|
|
|
- ubuntu-toolchain-r-test
|
|
|
|
packages:
|
|
|
|
- libstdc++-4.9-dev
|
|
|
|
|
2019-07-01 12:52:44 +00:00
|
|
|
before_install:
|
2020-01-02 09:51:17 +00:00
|
|
|
- timedatectl
|
|
|
|
- nvm install --latest-npm
|
2020-06-17 20:28:11 +00:00
|
|
|
- |
|
|
|
|
if [[ ! -z "$E2E_TESTS" ]]; then
|
|
|
|
# Upgrade docker-compose.
|
|
|
|
sudo rm /usr/local/bin/docker-compose
|
|
|
|
curl -sL https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose
|
|
|
|
chmod +x docker-compose
|
|
|
|
sudo mv docker-compose /usr/local/bin
|
|
|
|
fi
|
2019-07-01 12:52:44 +00:00
|
|
|
|
|
|
|
before_script:
|
2020-01-02 09:51:17 +00:00
|
|
|
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
|
|
|
- |
|
|
|
|
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
|
|
|
phpenv config-rm xdebug.ini
|
|
|
|
else
|
|
|
|
echo "xdebug.ini does not exist"
|
|
|
|
fi
|
|
|
|
- |
|
2020-06-17 20:28:11 +00:00
|
|
|
if [[ ! -z "$PHP_UNIT" ]]; then
|
|
|
|
composer install
|
|
|
|
fi
|
|
|
|
- |
|
|
|
|
if [[ ! -z "$E2E_TESTS" ]]; then
|
2020-01-02 09:51:17 +00:00
|
|
|
composer install --no-dev
|
2020-06-17 20:28:11 +00:00
|
|
|
npm ci
|
|
|
|
if [[ ! -z "$GUTENBERG_LATEST" ]]; then
|
2020-08-19 14:50:12 +00:00
|
|
|
JSON='{"config": { "SCRIPT_DEBUG": false, "JETPACK_AUTOLOAD_DEV": true } }'
|
2020-06-17 20:28:11 +00:00
|
|
|
else
|
2020-08-19 14:50:12 +00:00
|
|
|
JSON='{"core": "WordPress/WordPress#'"$WP_VERSION"'", "config": { "SCRIPT_DEBUG": false, "JETPACK_AUTOLOAD_DEV": true } }'
|
2020-06-17 20:28:11 +00:00
|
|
|
fi
|
|
|
|
echo $JSON > .wp-env.override.json
|
|
|
|
npm run build:e2e-test
|
|
|
|
chmod -R 767 ./
|
|
|
|
npm run wp-env start
|
2020-01-02 09:51:17 +00:00
|
|
|
fi
|
|
|
|
- |
|
2020-06-17 20:28:11 +00:00
|
|
|
if [[ "$WP_TRAVISCI" == "phpcs" ]]; then
|
2020-01-02 09:51:17 +00:00
|
|
|
composer install
|
|
|
|
fi
|
2020-02-11 16:13:20 +00:00
|
|
|
|
2019-08-09 18:08:31 +00:00
|
|
|
jobs:
|
|
|
|
fast_finish: true
|
|
|
|
include:
|
|
|
|
- stage: build tests
|
|
|
|
name: PHP 7.1/unit-tests/Latest WP
|
|
|
|
php: 7.1
|
|
|
|
env:
|
2020-01-02 09:51:17 +00:00
|
|
|
- WP_VERSION=latest
|
2020-06-05 19:13:51 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-06-17 20:28:11 +00:00
|
|
|
- PHP_UNIT=1
|
2019-08-09 18:08:31 +00:00
|
|
|
script:
|
Support "create account" option in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2851)
* prototype 'create account' checkbox in checkout block
* expose store config for generating password/username to blocks:
+ use FILTER_VALIDATE_BOOLEAN instead of hard-coded `yes`
* stub out signup form in checkout block
* context / provider to store checkout signup form data
* revert signup form - checkout block will always generate username etc
* persist signup checkbox in checkout state & pass to checkout API
* add `create_account` param to order API, fix name in client POST
* handle creating user account as part of order (first cut)
* ensure the order is associated with the new customer
* only show 'create account' checkbox when appropriate (guest checkout)
* remove unnecessary username/password variables
* refactor account-creation logic into functions:
- clarify inputs and outputs
- use RouteException for error handling
- use woo options directly, avoid dependency on WC_Checkout
* update "email exists" error message to use existing error message text
* handle all known errors from wc_create_new_customer + use core message
* only show "create account" checkbox to shopper when necessary:
- if guest checkout is disabled, user must create account - not optional
* only show "create account" if account creation is optional:
- fixes incorrect logic in previous commit
- add some comments to clarify
* fix create account logic in API when checkout requires account:
- use correct woo setting option name
- reverse logic to match option = allow guest false means registration required
* strip html tags from create account error messages
* temporarily force enable autogenerate user/pass in new account API
* fix rebase errors
* add new allowCreateAccount attribute in checkout block
* show/hide `Create account` checkbox dependent on block attribute:
- previously was dependent on store setting
* new create user API, with set initial password email (first cut):
- use core register_new_user for creating the user
- this triggers core "set new password" email
- generate username using logic lifted from WC core
- rough cut, lots to tidy/polish here
* remove alternative/unused create account function
* set `Customer` role for signups during checkout
* eslint fix - switch case break
* remove comments that mirror code & might go stale
* tidy func comment
* remove unused function
* use store setting `allow signup` for default value of new block option
* refactor order signup logic to service class first cut:
- new CreateAccount service
- hook up via custom action (for now at least)
- paste over existing create account logic (temporary - will be replaced)
* adapt wc_create_new_customer logic in CreateAccount service (WIP)
* set default_password_nag on new account + throw instead of WP_Error
* rename `createAccount` => `shouldCreateAccount` to clarify meaning
* fix checkout block - renamed `shouldCreateAccount` (missed in prev commit)
* prototype sending alternative email template for checkout signup
* add magic link to set password to blocks new account html email
* tidy up new account email templates - set password link, subject/heading
* use same id so merchant setting tweaks apply to our new improved email
* remove logging
* code tidies in CreateAccount service:
- remove unnecessary constructor
- type-hint in should_create_customer_account
- streamline logic in should_create_customer_account - remove
unnecessary `empty` check
- add comments to illuminate different use-cases handled by should_create_customer_account
* don't provide password to new account email templates (no longer used)
* declare dependencies in root namespace
* code tidies on new account email class:
- correct namespace and camelcase name
- declare class in file, don't instantiate; instantiate in client code
(CreateAccount service) when used
- no require/file import, use `use`
* move CustomerNewEmail to folder matching namespace
* use Package->get_path for email template paths:
- CreateAccount service now depends on Package
- CreateAccount passes Package to email class so it can use `get_path`
- note: CustomerNewAccount is not registered with DI container as it
needs to be instantiated after Woo init (for `WC_Email`)
- shift email templates to {plugin}/templates, consistent with WP
convention
* call CreateAccount::from_order_request directly, no custom hook:
- custom hook is not appropriate as we may not want to allow
extensibility in this way - TBD
* add appropriate margin above create account checkbox
* remove unnecessary direct-access protection
* generalise name of error-handling method
* simplify CustomerNewAccount - instantiate directly, when needed
* remove unused new_account_email member - now instantiated on demand
* numerous fixes and updates due to rebase changes
* fix typo in name of CustomerNewAccount php file (missing `n`)
* experiment - link to lost-password form in my-account (prototype branded screen)
* Revert "experiment - link to lost-password form in my-account (prototype branded screen)"
This reverts commit e1dc6dd5e9f0218ede81da92188d813c2d0856d9.
* feature gate CreateAccount service init to dev build only +
+ remove stale comment
* feature gate front end "Create account" checkbox to feature plugin only
* feature gate editor "allow signup" option to dev build only
* feature gate checkout api create account - dev build only
* tweak feature gating PHP logic so it's robust:
- all PHP feature gating is in the service class
- all publicly-available methods return early if feature gate off
- Checkout rest API transparently calls service - no explicit feature
gate at API level
* ensure frontend/editor features are feature gated (isExperimentalBuild is a function)
* feature gate value of checkoutAllowsSignup - can only be true in feature plugin
* fix a / an typo in comment
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* remove commented code
* hello world unit test (doesn't test anything yet)
* add a command for running unit tests when container already up:
- this should probably move to another PR/branch
* basic tests of core logic in CreateAccount service
* import isExperimentalBuild direct:
- import from alias package was causing an issue, likely a dependency cycle
* refactor from_order_request to return new user ID so it's easier to test
* test creating a customer from an order + rest request:
- i.e. a full end-to-end integration test
* delete redundant test and tidy comments
* generalise test to provider format
* refactor create-dup-user err test to use same approach as success test
* add test for when user should not be created
* don't hard-code options in "create" test, remove redundant provider in no-account-requested test
* de-generalise "user already signed up" test
* add test for malformed email
* flesh out & comment successful signup tests
* flesh out "invalid email" tests
* clarify no account requested test comment
* remove phpunit:quick - I don't think it's needed
* add comment explaining this is an integration test
* experiment – disable feature flag, is this why the tests are failing?
* revert test commit - restore feature gate (experimental flag)
* skip all tests if CreateAccount is disabled due to feature flag
* d'oh - expose CreateAccount:is_feature_enabled so can be used in tests
* add jsdoc for checkout-state shouldCreateAccount field
* remove unnecessary comment + fix whitespace/indentation
* simulate logged-out user for createaccount signup tests
* use a single, compound if statement for early return (review nitpick)
* don't hide `checkoutAllowsSignup` store setting behind feature flag:
- the feature flag should be used to enable/disable behaviour
- it's dangerous to adjust store settings/options based on feature flag
* rejig tests so they require woocommerce_blocks_phase==3:
- make feature gate method private to avoid exposing
- remove feature flag check & test skip for other builds
- set blocks phase in travis config
* remove redundant user-logout in test setup - cleaner to just require this
* use WP function bracket style (same line)
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-10-01 02:07:16 +00:00
|
|
|
- echo 'woocommerce_blocks_phase = 3' > blocks.ini
|
2020-06-17 20:28:11 +00:00
|
|
|
- npm run phpunit
|
2019-08-09 18:08:31 +00:00
|
|
|
- name: PHP 5.6/unit-tests/Latest WP
|
|
|
|
php: 5.6
|
|
|
|
env:
|
2020-01-02 09:51:17 +00:00
|
|
|
- WP_VERSION=latest
|
2020-06-05 19:13:51 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-06-17 20:28:11 +00:00
|
|
|
- PHP_UNIT=1
|
2019-08-09 18:08:31 +00:00
|
|
|
script:
|
Support "create account" option in checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2851)
* prototype 'create account' checkbox in checkout block
* expose store config for generating password/username to blocks:
+ use FILTER_VALIDATE_BOOLEAN instead of hard-coded `yes`
* stub out signup form in checkout block
* context / provider to store checkout signup form data
* revert signup form - checkout block will always generate username etc
* persist signup checkbox in checkout state & pass to checkout API
* add `create_account` param to order API, fix name in client POST
* handle creating user account as part of order (first cut)
* ensure the order is associated with the new customer
* only show 'create account' checkbox when appropriate (guest checkout)
* remove unnecessary username/password variables
* refactor account-creation logic into functions:
- clarify inputs and outputs
- use RouteException for error handling
- use woo options directly, avoid dependency on WC_Checkout
* update "email exists" error message to use existing error message text
* handle all known errors from wc_create_new_customer + use core message
* only show "create account" checkbox to shopper when necessary:
- if guest checkout is disabled, user must create account - not optional
* only show "create account" if account creation is optional:
- fixes incorrect logic in previous commit
- add some comments to clarify
* fix create account logic in API when checkout requires account:
- use correct woo setting option name
- reverse logic to match option = allow guest false means registration required
* strip html tags from create account error messages
* temporarily force enable autogenerate user/pass in new account API
* fix rebase errors
* add new allowCreateAccount attribute in checkout block
* show/hide `Create account` checkbox dependent on block attribute:
- previously was dependent on store setting
* new create user API, with set initial password email (first cut):
- use core register_new_user for creating the user
- this triggers core "set new password" email
- generate username using logic lifted from WC core
- rough cut, lots to tidy/polish here
* remove alternative/unused create account function
* set `Customer` role for signups during checkout
* eslint fix - switch case break
* remove comments that mirror code & might go stale
* tidy func comment
* remove unused function
* use store setting `allow signup` for default value of new block option
* refactor order signup logic to service class first cut:
- new CreateAccount service
- hook up via custom action (for now at least)
- paste over existing create account logic (temporary - will be replaced)
* adapt wc_create_new_customer logic in CreateAccount service (WIP)
* set default_password_nag on new account + throw instead of WP_Error
* rename `createAccount` => `shouldCreateAccount` to clarify meaning
* fix checkout block - renamed `shouldCreateAccount` (missed in prev commit)
* prototype sending alternative email template for checkout signup
* add magic link to set password to blocks new account html email
* tidy up new account email templates - set password link, subject/heading
* use same id so merchant setting tweaks apply to our new improved email
* remove logging
* code tidies in CreateAccount service:
- remove unnecessary constructor
- type-hint in should_create_customer_account
- streamline logic in should_create_customer_account - remove
unnecessary `empty` check
- add comments to illuminate different use-cases handled by should_create_customer_account
* don't provide password to new account email templates (no longer used)
* declare dependencies in root namespace
* code tidies on new account email class:
- correct namespace and camelcase name
- declare class in file, don't instantiate; instantiate in client code
(CreateAccount service) when used
- no require/file import, use `use`
* move CustomerNewEmail to folder matching namespace
* use Package->get_path for email template paths:
- CreateAccount service now depends on Package
- CreateAccount passes Package to email class so it can use `get_path`
- note: CustomerNewAccount is not registered with DI container as it
needs to be instantiated after Woo init (for `WC_Email`)
- shift email templates to {plugin}/templates, consistent with WP
convention
* call CreateAccount::from_order_request directly, no custom hook:
- custom hook is not appropriate as we may not want to allow
extensibility in this way - TBD
* add appropriate margin above create account checkbox
* remove unnecessary direct-access protection
* generalise name of error-handling method
* simplify CustomerNewAccount - instantiate directly, when needed
* remove unused new_account_email member - now instantiated on demand
* numerous fixes and updates due to rebase changes
* fix typo in name of CustomerNewAccount php file (missing `n`)
* experiment - link to lost-password form in my-account (prototype branded screen)
* Revert "experiment - link to lost-password form in my-account (prototype branded screen)"
This reverts commit e1dc6dd5e9f0218ede81da92188d813c2d0856d9.
* feature gate CreateAccount service init to dev build only +
+ remove stale comment
* feature gate front end "Create account" checkbox to feature plugin only
* feature gate editor "allow signup" option to dev build only
* feature gate checkout api create account - dev build only
* tweak feature gating PHP logic so it's robust:
- all PHP feature gating is in the service class
- all publicly-available methods return early if feature gate off
- Checkout rest API transparently calls service - no explicit feature
gate at API level
* ensure frontend/editor features are feature gated (isExperimentalBuild is a function)
* feature gate value of checkoutAllowsSignup - can only be true in feature plugin
* fix a / an typo in comment
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* remove commented code
* hello world unit test (doesn't test anything yet)
* add a command for running unit tests when container already up:
- this should probably move to another PR/branch
* basic tests of core logic in CreateAccount service
* import isExperimentalBuild direct:
- import from alias package was causing an issue, likely a dependency cycle
* refactor from_order_request to return new user ID so it's easier to test
* test creating a customer from an order + rest request:
- i.e. a full end-to-end integration test
* delete redundant test and tidy comments
* generalise test to provider format
* refactor create-dup-user err test to use same approach as success test
* add test for when user should not be created
* don't hard-code options in "create" test, remove redundant provider in no-account-requested test
* de-generalise "user already signed up" test
* add test for malformed email
* flesh out & comment successful signup tests
* flesh out "invalid email" tests
* clarify no account requested test comment
* remove phpunit:quick - I don't think it's needed
* add comment explaining this is an integration test
* experiment – disable feature flag, is this why the tests are failing?
* revert test commit - restore feature gate (experimental flag)
* skip all tests if CreateAccount is disabled due to feature flag
* d'oh - expose CreateAccount:is_feature_enabled so can be used in tests
* add jsdoc for checkout-state shouldCreateAccount field
* remove unnecessary comment + fix whitespace/indentation
* simulate logged-out user for createaccount signup tests
* use a single, compound if statement for early return (review nitpick)
* don't hide `checkoutAllowsSignup` store setting behind feature flag:
- the feature flag should be used to enable/disable behaviour
- it's dangerous to adjust store settings/options based on feature flag
* rejig tests so they require woocommerce_blocks_phase==3:
- make feature gate method private to avoid exposing
- remove feature flag check & test skip for other builds
- set blocks phase in travis config
* remove redundant user-logout in test setup - cleaner to just require this
* use WP function bracket style (same line)
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2020-10-01 02:07:16 +00:00
|
|
|
- echo 'woocommerce_blocks_phase = 3' > blocks.ini
|
2020-06-17 20:28:11 +00:00
|
|
|
- npm run phpunit
|
2019-08-09 18:08:31 +00:00
|
|
|
- name: Javascript Tests
|
|
|
|
script:
|
2020-01-02 09:51:17 +00:00
|
|
|
- npm install
|
|
|
|
- npm run test
|
2020-01-31 20:04:37 +00:00
|
|
|
env:
|
2020-06-05 19:13:51 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-12-09 16:09:45 +00:00
|
|
|
- name: E2E Tests (WP 5.4)
|
2020-02-11 16:13:20 +00:00
|
|
|
script:
|
2020-02-14 20:16:58 +00:00
|
|
|
- npm run test:e2e
|
2020-02-11 16:13:20 +00:00
|
|
|
env:
|
2020-12-09 16:09:45 +00:00
|
|
|
- WP_VERSION=5.4-branch
|
2020-06-17 20:28:11 +00:00
|
|
|
- E2E_TESTS=1
|
2020-06-16 12:18:34 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-12-09 16:09:45 +00:00
|
|
|
- name: E2E Tests (WP 5.5)
|
2020-06-16 12:18:34 +00:00
|
|
|
script:
|
|
|
|
- npm run test:e2e
|
|
|
|
env:
|
2020-12-09 16:09:45 +00:00
|
|
|
- WP_VERSION=5.5-branch
|
2020-06-17 20:28:11 +00:00
|
|
|
- E2E_TESTS=1
|
2020-06-16 12:18:34 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-12-09 16:09:45 +00:00
|
|
|
- name: E2E Tests (WP 5.6)
|
2020-06-16 12:18:34 +00:00
|
|
|
script:
|
|
|
|
- npm run test:e2e
|
|
|
|
env:
|
2020-12-09 16:09:45 +00:00
|
|
|
- WP_VERSION=5.6-branch
|
2020-06-17 20:28:11 +00:00
|
|
|
- E2E_TESTS=1
|
2020-06-16 12:18:34 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-12-09 16:09:45 +00:00
|
|
|
- name: E2E Tests (WP 5.6 with Gutenberg plugin)
|
2020-06-16 12:18:34 +00:00
|
|
|
script:
|
2020-06-17 20:28:11 +00:00
|
|
|
- npm run wp-env run tests-cli "wp plugin install gutenberg --activate"
|
2020-06-16 12:18:34 +00:00
|
|
|
- npm install @wordpress/e2e-test-utils@latest
|
2020-06-17 20:28:11 +00:00
|
|
|
- chmod -R 767 ./
|
2020-06-16 12:18:34 +00:00
|
|
|
- npm run test:e2e
|
|
|
|
env:
|
2020-12-09 16:09:45 +00:00
|
|
|
- WP_VERSION=5.6-branch
|
2020-06-17 20:28:11 +00:00
|
|
|
- E2E_TESTS=1
|
2020-06-16 12:18:34 +00:00
|
|
|
- GUTENBERG_LATEST=true
|
2020-06-05 19:13:51 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-03-22 15:40:42 +00:00
|
|
|
- stage: deploy
|
2020-09-26 17:28:16 +00:00
|
|
|
if: (NOT type IN (pull_request)) AND (branch = trunk)
|
2020-03-22 15:40:42 +00:00
|
|
|
name: Deploy Storybook
|
|
|
|
env:
|
2020-06-05 19:13:51 +00:00
|
|
|
- WOOCOMMERCE_BLOCKS_PHASE=3
|
2020-03-22 15:40:42 +00:00
|
|
|
install:
|
|
|
|
- npm ci
|
2020-03-22 16:31:57 +00:00
|
|
|
script:
|
2020-03-22 15:40:42 +00:00
|
|
|
- npm run storybook:build
|
|
|
|
deploy:
|
|
|
|
provider: pages
|
2020-03-22 16:31:57 +00:00
|
|
|
skip_cleanup: true
|
2020-03-22 15:40:42 +00:00
|
|
|
github_token: $GITHUB_TOKEN
|
|
|
|
keep_history: true
|
|
|
|
local_dir: storybook/dist
|
|
|
|
on:
|
2020-09-26 17:28:16 +00:00
|
|
|
branch: trunk
|
2020-08-11 15:13:03 +00:00
|
|
|
|