Skip to content

Commit 6ac3f13

Browse files
committed
Add QIT script for WooCommerce version matrix and update workflows to use it
1 parent 3e75a48 commit 6ac3f13

File tree

3 files changed

+125
-36
lines changed

3 files changed

+125
-36
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
# Simplified script for QIT WooCommerce version matrix
4+
# QIT handles version resolution for stable, rc, beta, nightly keywords
5+
# We only need to fetch L-1 version for backward compatibility testing
6+
7+
set -e
8+
9+
# Function to get the latest WooCommerce version from WordPress.org API
10+
get_latest_wc_version() {
11+
curl -s https://api.wordpress.org/plugins/info/1.0/woocommerce.json | jq -r '.version'
12+
}
13+
14+
# Function to get the latest stable version for a specific major version
15+
get_latest_stable_for_major() {
16+
local major_version=$1
17+
curl -s https://api.wordpress.org/plugins/info/1.0/woocommerce.json | \
18+
jq -r --arg major "$major_version" '.versions | with_entries(select(.key | startswith($major + ".") and (contains("-") | not))) | keys | sort_by( . | split(".") | map(tonumber) ) | last'
19+
}
20+
21+
# Function to get the L-1 version (previous major version's latest stable)
22+
get_l1_version() {
23+
local latest_version=$1
24+
local major_version=$(echo "$latest_version" | cut -d. -f1)
25+
local l1_major=$((major_version - 1))
26+
get_latest_stable_for_major "$l1_major"
27+
}
28+
29+
# Get the latest WooCommerce version
30+
echo "Fetching latest WooCommerce version..." >&2
31+
LATEST_WC_VERSION=$(get_latest_wc_version)
32+
echo "Latest WC version: $LATEST_WC_VERSION" >&2
33+
34+
# Get the L-1 version (we need the actual version number for this)
35+
L1_VERSION=$(get_l1_version "$LATEST_WC_VERSION")
36+
echo "L-1 version: $L1_VERSION" >&2
37+
38+
# Validate L-1 version
39+
if [[ -z "$L1_VERSION" || "$L1_VERSION" == "null" ]]; then
40+
echo "Error: Could not extract L-1 version" >&2
41+
exit 1
42+
fi
43+
44+
if [[ ! "$L1_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
45+
echo "Error: Invalid L-1 version: $L1_VERSION" >&2
46+
exit 1
47+
fi
48+
49+
# Check if RC and beta are available (for metadata only)
50+
# QIT will handle the actual version resolution
51+
RC_AVAILABLE="false"
52+
BETA_AVAILABLE="false"
53+
54+
LATEST_RC=$(curl -s https://api.wordpress.org/plugins/info/1.0/woocommerce.json | \
55+
jq -r '.versions | with_entries(select(.key|match("rc";"i"))) | keys | sort_by( . | split("-")[0] | split(".") | map(tonumber) ) | last')
56+
57+
if [[ -n "$LATEST_RC" && "$LATEST_RC" != "null" ]]; then
58+
RC_BASE="${LATEST_RC%%-*}"
59+
HIGHEST=$(printf '%s\n%s\n' "$RC_BASE" "$LATEST_WC_VERSION" | sort -V | tail -n1)
60+
if [[ "$HIGHEST" == "$RC_BASE" && "$RC_BASE" != "$LATEST_WC_VERSION" ]]; then
61+
RC_AVAILABLE="true"
62+
echo "RC available: $LATEST_RC" >&2
63+
else
64+
echo "RC not applicable (stable $LATEST_WC_VERSION already released)" >&2
65+
fi
66+
else
67+
echo "No RC version available" >&2
68+
fi
69+
70+
LATEST_BETA=$(curl -s https://api.wordpress.org/plugins/info/1.0/woocommerce.json | \
71+
jq -r --arg major "$(echo "$LATEST_WC_VERSION" | cut -d. -f1)" \
72+
'.versions | with_entries(select(.key | startswith($major + ".") and contains("beta"))) | keys | sort_by( . | split("-")[0] | split(".") | map(tonumber) ) | last')
73+
74+
if [[ -n "$LATEST_BETA" && "$LATEST_BETA" != "null" ]]; then
75+
BETA_AVAILABLE="true"
76+
echo "Beta available: $LATEST_BETA" >&2
77+
else
78+
echo "No beta version available" >&2
79+
fi
80+
81+
# Output JSON with L-1 version and availability flags
82+
# QIT workflows will use keywords (stable, rc, beta) and check availability flags
83+
RESULT=$(jq -n \
84+
--arg l1_version "$L1_VERSION" \
85+
--arg rc_available "$RC_AVAILABLE" \
86+
--arg beta_available "$BETA_AVAILABLE" \
87+
'{
88+
l1_version: $l1_version,
89+
rc_available: ($rc_available == "true"),
90+
beta_available: ($beta_available == "true")
91+
}')
92+
93+
echo "$RESULT"

.github/workflows/qit-e2e-pull-request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ jobs:
6565
- name: "Generate matrix"
6666
id: generate_matrix
6767
run: |
68-
# Use dynamic script to get WooCommerce versions (L-1 policy)
69-
SCRIPT_RESULT=$( .github/scripts/generate-wc-matrix.sh )
68+
# Use simplified QIT script - QIT handles version resolution for stable
69+
SCRIPT_RESULT=$( .github/scripts/generate-qit-wc-matrix.sh )
7070
71-
# Extract versions and metadata from JSON
72-
L1_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.metadata.l1_version')
71+
# Extract L-1 version from JSON
72+
L1_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.l1_version')
7373
7474
echo "Using L-1 version: $L1_VERSION" >&2
7575

.github/workflows/qit-e2e.yml

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,17 @@ jobs:
7070
- name: "Generate matrix"
7171
id: generate_matrix
7272
run: |
73-
# Use dynamic script to get WooCommerce versions (L-1 policy)
74-
SCRIPT_RESULT=$( .github/scripts/generate-wc-matrix.sh )
73+
# Use simplified QIT script - QIT handles version resolution for stable/rc/beta
74+
SCRIPT_RESULT=$( .github/scripts/generate-qit-wc-matrix.sh )
7575
76-
# Extract versions and metadata from JSON
77-
L1_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.metadata.l1_version')
78-
RC_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.metadata.rc_version')
79-
BETA_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.metadata.beta_version')
80-
81-
if [[ "$BETA_VERSION" == "null" ]]; then
82-
BETA_VERSION=""
83-
fi
76+
# Extract L-1 version and availability flags from JSON
77+
L1_VERSION=$(echo "$SCRIPT_RESULT" | jq -r '.l1_version')
78+
RC_AVAILABLE=$(echo "$SCRIPT_RESULT" | jq -r '.rc_available')
79+
BETA_AVAILABLE=$(echo "$SCRIPT_RESULT" | jq -r '.beta_available')
8480
8581
echo "Using L-1 version: $L1_VERSION" >&2
86-
echo "Using RC version: $RC_VERSION" >&2
87-
if [[ -n "$BETA_VERSION" ]]; then
88-
echo "Using beta version: $BETA_VERSION" >&2
89-
else
90-
echo "No beta version available" >&2
91-
fi
82+
echo "RC available: $RC_AVAILABLE" >&2
83+
echo "Beta available: $BETA_AVAILABLE" >&2
9284
9385
# Define common values to reduce repetition
9486
PHP_LEGACY="7.4"
@@ -107,37 +99,41 @@ jobs:
10799
MATRIX_ENTRIES+=("{\"woocommerce\":\"7.7.0\",\"php\":\"$PHP_LEGACY\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
108100
MATRIX_ENTRIES+=("{\"woocommerce\":\"7.7.0\",\"php\":\"$PHP_LEGACY\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
109101
110-
# Add L-1 version with PHP 8.3
102+
# Add L-1 version with PHP 8.3 (QIT uses actual version number)
111103
MATRIX_ENTRIES+=("{\"woocommerce\":\"$L1_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
112104
MATRIX_ENTRIES+=("{\"woocommerce\":\"$L1_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
113105
MATRIX_ENTRIES+=("{\"woocommerce\":\"$L1_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
114106
MATRIX_ENTRIES+=("{\"woocommerce\":\"$L1_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
115107
MATRIX_ENTRIES+=("{\"woocommerce\":\"$L1_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper blocks\",\"test_name\":\"blocks-shopper\"}")
116108
117-
# Add latest with PHP 8.3
109+
# Add stable with PHP 8.3 (QIT keyword - resolves to latest stable)
118110
MATRIX_ENTRIES+=("{\"woocommerce\":\"stable\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
119111
MATRIX_ENTRIES+=("{\"woocommerce\":\"stable\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
120112
MATRIX_ENTRIES+=("{\"woocommerce\":\"stable\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
121113
MATRIX_ENTRIES+=("{\"woocommerce\":\"stable\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
122114
MATRIX_ENTRIES+=("{\"woocommerce\":\"stable\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper blocks\",\"test_name\":\"blocks-shopper\"}")
123115
124-
# Add beta with PHP 8.3 (if available)
125-
if [[ -n "$BETA_VERSION" ]]; then
126-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$BETA_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
127-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$BETA_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
128-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$BETA_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
129-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$BETA_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
130-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$BETA_VERSION\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper blocks\",\"test_name\":\"blocks-shopper\"}")
116+
# Add beta with PHP 8.3 (QIT keyword - only if available)
117+
if [[ "$BETA_AVAILABLE" == "true" ]]; then
118+
MATRIX_ENTRIES+=("{\"woocommerce\":\"beta\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
119+
MATRIX_ENTRIES+=("{\"woocommerce\":\"beta\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
120+
MATRIX_ENTRIES+=("{\"woocommerce\":\"beta\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
121+
MATRIX_ENTRIES+=("{\"woocommerce\":\"beta\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
122+
MATRIX_ENTRIES+=("{\"woocommerce\":\"beta\",\"php\":\"$PHP_STABLE\",\"test_tag\":\"shopper blocks\",\"test_name\":\"blocks-shopper\"}")
123+
echo "Including beta tests (QIT will resolve to latest beta)" >&2
124+
else
125+
echo "Skipping beta tests - no beta available" >&2
131126
fi
132127
133-
# Add rc with PHP 8.4 (only if RC version is available)
134-
if [[ -n "$RC_VERSION" && "$RC_VERSION" != "null" ]]; then
135-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$RC_VERSION\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
136-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$RC_VERSION\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
137-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$RC_VERSION\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
138-
MATRIX_ENTRIES+=("{\"woocommerce\":\"$RC_VERSION\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
128+
# Add rc with PHP 8.4 (QIT keyword - only if available)
129+
if [[ "$RC_AVAILABLE" == "true" ]]; then
130+
MATRIX_ENTRIES+=("{\"woocommerce\":\"rc\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"merchant\",\"test_name\":\"merchant\"}")
131+
MATRIX_ENTRIES+=("{\"woocommerce\":\"rc\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"shopper\",\"test_name\":\"shopper\"}")
132+
MATRIX_ENTRIES+=("{\"woocommerce\":\"rc\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"merchant subscriptions\",\"test_name\":\"subscriptions-merchant\"}")
133+
MATRIX_ENTRIES+=("{\"woocommerce\":\"rc\",\"php\":\"$PHP_LATEST\",\"test_tag\":\"shopper subscriptions\",\"test_name\":\"subscriptions-shopper\"}")
134+
echo "Including RC tests (QIT will resolve to latest RC)" >&2
139135
else
140-
echo "No RC version available, skipping RC matrix entries" >&2
136+
echo "Skipping RC tests - no RC available" >&2
141137
fi
142138
143139
# Add WordPress nightly with WC latest and PHP 8.3 (match e2e-test.yml wp-nightly-tests)

0 commit comments

Comments
 (0)