@@ -22,18 +22,63 @@ echo "Running E2E tests..."
2222# Change to project root directory to build plugin
2323cd " $WCP_ROOT "
2424
25- # Foundation version: Simplified build process for easier testing
26- # For this foundation PR, we'll always build to avoid complex signature computation issues
25+ # Compute a signature of sources relevant to the release build and
26+ # skip rebuilding if nothing has changed since the last build.
27+ compute_build_signature () {
28+ # Hash tracked files that affect the release artifact. This includes
29+ # sources packaged in the zip and build/config files that affect the output.
30+ git ls-files -z -- \
31+ assets \
32+ i18n \
33+ includes \
34+ languages \
35+ lib \
36+ src \
37+ templates \
38+ client \
39+ tasks/release.js \
40+ webpack \
41+ webpack.config.js \
42+ babel.config.js \
43+ package.json \
44+ package-lock.json \
45+ composer.json \
46+ composer.lock \
47+ woocommerce-payments.php \
48+ changelog.txt \
49+ readme.txt \
50+ SECURITY.md \
51+ 2> /dev/null \
52+ | xargs -0 shasum -a 256 2> /dev/null \
53+ | shasum -a 256 \
54+ | awk ' {print $1}'
55+
56+ # Explicitly return 0 to avoid pipefail issues
57+ return 0
58+ }
2759
2860BUILD_HASH_FILE=" $WCP_ROOT /woocommerce-payments.zip.hash"
2961
30- # For this foundation PR, always build if zip doesn't exist or if forced
31- if [[ -n " ${WCP_FORCE_BUILD:- } " ]] || [[ ! -f " woocommerce-payments.zip" ]]; then
32- echo " Building WooPayments plugin..."
62+ CURRENT_SIG=" $( compute_build_signature) "
63+
64+ # If WCP_FORCE_BUILD is set, always rebuild
65+ if [[ -n " ${WCP_FORCE_BUILD:- } " ]]; then
66+ echo " WCP_FORCE_BUILD set; forcing build of WooPayments plugin..."
3367 npm run build:release
34- echo " foundation-build-$( date +%s) " > " $BUILD_HASH_FILE "
68+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
69+ elif [[ -f " woocommerce-payments.zip" && -f " $BUILD_HASH_FILE " ]]; then
70+ LAST_SIG=" $( cat " $BUILD_HASH_FILE " 2> /dev/null || true) "
71+ if [[ " $CURRENT_SIG " == " $LAST_SIG " && -n " $CURRENT_SIG " ]]; then
72+ echo " No relevant changes detected since last build; skipping build."
73+ else
74+ echo " Changes detected; rebuilding WooPayments plugin..."
75+ npm run build:release
76+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
77+ fi
3578else
36- echo " Using existing woocommerce-payments.zip"
79+ echo " Building WooPayments plugin..."
80+ npm run build:release
81+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
3782fi
3883
3984# Change to QIT directory so qit.yml is automatically found
4691 QIT_CMD=" $QIT_BINARY "
4792fi
4893
49- echo " Running QIT E2E foundation tests (no Jetpack credentials)..."
94+ # Pass basic Jetpack environment variables
95+ env_args=()
96+ if [[ -n " ${E2E_JP_SITE_ID:- } " ]]; then
97+ env_args+=( --env " E2E_JP_SITE_ID=${E2E_JP_SITE_ID} " )
98+ fi
99+ if [[ -n " ${E2E_JP_BLOG_TOKEN:- } " ]]; then
100+ env_args+=( --env " E2E_JP_BLOG_TOKEN=${E2E_JP_BLOG_TOKEN} " )
101+ fi
102+ if [[ -n " ${E2E_JP_USER_TOKEN:- } " ]]; then
103+ env_args+=( --env " E2E_JP_USER_TOKEN=${E2E_JP_USER_TOKEN} " )
104+ fi
50105
51106# Run our QIT E2E tests (qit.yml automatically loaded from current directory)
52- " $QIT_CMD " run:e2e woocommerce-payments ./e2e \
53- --source " $WCP_ROOT /woocommerce-payments.zip"
107+ echo " Running QIT E2E tests with Jetpack functionality..."
108+ if [ ${# env_args[@]} -eq 0 ]; then
109+ " $QIT_CMD " run:e2e woocommerce-payments ./e2e \
110+ --source " $WCP_ROOT /woocommerce-payments.zip"
111+ else
112+ " $QIT_CMD " run:e2e woocommerce-payments ./e2e \
113+ --source " $WCP_ROOT /woocommerce-payments.zip" \
114+ " ${env_args[@]} "
115+ fi
54116
55117echo " QIT E2E foundation tests completed!"
0 commit comments