@@ -22,18 +22,61 @@ 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+ # Foundation version: Simplified build process - just ensure we have a zip
26+ # Compute a signature of sources relevant to the release build and
27+ # skip rebuilding if nothing has changed since the last build.
28+ compute_build_signature () {
29+ # Hash tracked files that affect the release artifact. This includes
30+ # sources packaged in the zip and build/config files that affect the output.
31+ git ls-files -z -- \
32+ assets \
33+ i18n \
34+ includes \
35+ languages \
36+ lib \
37+ src \
38+ templates \
39+ client \
40+ tasks/release.js \
41+ webpack \
42+ webpack.config.js \
43+ babel.config.js \
44+ package.json \
45+ package-lock.json \
46+ composer.json \
47+ composer.lock \
48+ woocommerce-payments.php \
49+ changelog.txt \
50+ readme.txt \
51+ SECURITY.md \
52+ 2> /dev/null \
53+ | xargs -0 shasum -a 256 2> /dev/null \
54+ | shasum -a 256 \
55+ | awk ' {print $1}'
56+ }
2757
2858BUILD_HASH_FILE=" $WCP_ROOT /woocommerce-payments.zip.hash"
2959
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..."
60+ CURRENT_SIG=" $( compute_build_signature) "
61+
62+ # If WCP_FORCE_BUILD is set, always rebuild
63+ if [[ -n " ${WCP_FORCE_BUILD:- } " ]]; then
64+ echo " WCP_FORCE_BUILD set; forcing build of WooPayments plugin..."
3365 npm run build:release
34- echo " foundation-build-$( date +%s) " > " $BUILD_HASH_FILE "
66+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
67+ elif [[ -f " woocommerce-payments.zip" && -f " $BUILD_HASH_FILE " ]]; then
68+ LAST_SIG=" $( cat " $BUILD_HASH_FILE " 2> /dev/null || true) "
69+ if [[ " $CURRENT_SIG " == " $LAST_SIG " && -n " $CURRENT_SIG " ]]; then
70+ echo " No relevant changes detected since last build; skipping build."
71+ else
72+ echo " Changes detected; rebuilding WooPayments plugin..."
73+ npm run build:release
74+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
75+ fi
3576else
36- echo " Using existing woocommerce-payments.zip"
77+ echo " Building WooPayments plugin..."
78+ npm run build:release
79+ echo " $CURRENT_SIG " > " $BUILD_HASH_FILE "
3780fi
3881
3982# Change to QIT directory so qit.yml is automatically found
0 commit comments