diff --git a/.github/scripts/build-wp-env.js b/.github/scripts/build-wp-env.js index fc20901c..9808d311 100644 --- a/.github/scripts/build-wp-env.js +++ b/.github/scripts/build-wp-env.js @@ -68,17 +68,15 @@ const isValidLocalElementor = fs.existsSync( './tmp/elementor/elementor.php' ) & fs.existsSync( './tmp/elementor/includes' ) && fs.existsSync( './tmp/elementor/assets' ); -let elementorSource; -if ( isValidLocalElementor ) { - wpEnv.plugins.push( './tmp/elementor' ); - elementorSource = './tmp/elementor'; -} else { - const versionMatch = ( ELEMENTOR_VERSION || '' ).match( /^v?([0-9]+\.[0-9]+\.[0-9]+)$/ ); - const wpOrgVersion = versionMatch ? versionMatch[ 1 ] : 'latest-stable'; - wpEnv.plugins.push( `https://downloads.wordpress.org/plugin/elementor.${ wpOrgVersion }.zip` ); - elementorSource = `WordPress.org ${ wpOrgVersion }`; +if ( ! isValidLocalElementor ) { + // eslint-disable-next-line no-console + console.error( 'Elementor not found at ./tmp/elementor — run download-elementor-core.sh first' ); + process.exit( 1 ); } +wpEnv.plugins.push( './tmp/elementor' ); +const elementorSource = './tmp/elementor'; + // Test configuration wpEnv.config = { ...wpEnv.config, diff --git a/.github/scripts/download-elementor-core.sh b/.github/scripts/download-elementor-core.sh new file mode 100755 index 00000000..ca8c3fa0 --- /dev/null +++ b/.github/scripts/download-elementor-core.sh @@ -0,0 +1,83 @@ +#!/bin/bash +set -eo pipefail + +ELEMENTOR_CORE_BRANCH="${ELEMENTOR_CORE_BRANCH:-$1}" +OUTPUT_DIR="${OUTPUT_DIR:-./tmp/elementor}" +REPO="elementor/elementor" + +if [[ -z "$ELEMENTOR_CORE_BRANCH" ]]; then + echo "ERROR: ELEMENTOR_CORE_BRANCH is required" + exit 1 +fi + +if [[ "$ELEMENTOR_CORE_BRANCH" == "latest-stable" ]]; then + echo "ERROR: latest-stable is not supported; use main or a GitHub release tag" + exit 1 +fi + +write_effective_version() { + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "effective-version=$1" >>"$GITHUB_OUTPUT" + fi +} + +resolve_release_tag() { + if [[ "$ELEMENTOR_CORE_BRANCH" == "main" ]]; then + local latest_tag + latest_tag=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | jq -r '.tag_name // empty') + latest_tag=${latest_tag#v} + if [[ -z "$latest_tag" || "$latest_tag" == "null" ]]; then + echo "ERROR: Could not resolve latest Elementor release" + exit 1 + fi + echo "$latest_tag" + return 0 + fi + + echo "$ELEMENTOR_CORE_BRANCH" +} + +install_release_zip() { + local tag="$1" + local release_json asset_url extract_dir zip_file + + release_json=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/tags/${tag}") + asset_url=$(echo "$release_json" | jq -r '[.assets[] | select(.name | endswith(".zip"))][0].browser_download_url // empty') + + if [[ -z "$asset_url" || "$asset_url" == "null" ]]; then + echo "ERROR: No zip asset found for Elementor release ${tag}" + exit 1 + fi + + extract_dir="${OUTPUT_DIR}.extract" + zip_file="./elementor-core-download.zip" + + rm -rf "$OUTPUT_DIR" "$extract_dir" + mkdir -p "$extract_dir" + + curl -fsSL -o "$zip_file" "$asset_url" + unzip -q "$zip_file" -d "$extract_dir" + rm -f "$zip_file" + + if [[ -f "$extract_dir/elementor/elementor.php" ]]; then + mv "$extract_dir/elementor" "$OUTPUT_DIR" + elif [[ -f "$extract_dir/elementor.php" ]]; then + mv "$extract_dir" "$OUTPUT_DIR" + else + echo "ERROR: elementor.php not found in release ${tag}" + exit 1 + fi + + rm -rf "$extract_dir" + + if [[ ! -f "$OUTPUT_DIR/elementor.php" ]]; then + echo "ERROR: Elementor install failed for ${tag}" + exit 1 + fi + + write_effective_version "$tag" + echo "Elementor ${tag} installed to ${OUTPUT_DIR}" +} + +TAG=$(resolve_release_tag) +install_release_zip "$TAG" diff --git a/.github/scripts/generate-targeted-matrix.sh b/.github/scripts/generate-targeted-matrix.sh new file mode 100755 index 00000000..14e9ad16 --- /dev/null +++ b/.github/scripts/generate-targeted-matrix.sh @@ -0,0 +1,291 @@ +#!/bin/bash +set -eo pipefail + +HT_VERSION="${1:-main}" +HP_VERSION="${2:-latest-stable}" +EL_VERSION="${3:-main}" +DEPTH="${4:-2}" +RUN_TARGETED_TESTS="${5:-true}" + +HT_VERSION_DISPLAY="$HT_VERSION" +HP_VERSION_DISPLAY="$HP_VERSION" +EL_VERSION_DISPLAY="$EL_VERSION" + +get_latest_version() { + local repo=$1 + local latest_version + + latest_version=$(curl -s "https://api.github.com/repos/${repo}/releases/latest" | jq -r '.tag_name // empty') + latest_version=${latest_version#v} + + if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then + echo "" + else + echo "$latest_version" + fi +} + +get_wp_org_latest_version() { + local plugin_slug=$1 + local latest_version + + latest_version=$(curl -s "https://api.wordpress.org/plugins/info/1.0/${plugin_slug}.json" | jq -r '.version // empty') + + if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then + echo "" + else + echo "$latest_version" + fi +} + +get_wp_org_theme_latest_version() { + local theme_slug=$1 + local latest_version + + latest_version=$(curl -s "https://api.wordpress.org/themes/info/1.1/?action=theme_information&request%5Bslug%5D=${theme_slug}" | jq -r '.version // empty') + + if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then + echo "" + else + echo "$latest_version" + fi +} + +validate_version_availability() { + local version=$1 + local plugin_name=$2 + + if [[ "$version" == "main" ]]; then + echo "$version" + return 0 + fi + + if [[ "$plugin_name" == "Hello Plus" && "$version" == "latest-stable" ]]; then + echo "$version" + return 0 + fi + + if [[ $version =~ ^([0-9]+)\.([0-9]+) ]]; then + echo "$version" + else + if [[ "$plugin_name" == "Hello Plus" ]]; then + echo "latest-stable" + else + echo "main" + fi + fi +} + +calculate_previous_versions() { + local version=$1 + local depth=$2 + local strategy=${3:-"elementor"} + + if [[ "$version" == "main" || "$version" == "latest-stable" ]]; then + echo "" + return 0 + fi + + if [[ "$strategy" == "elementor" ]]; then + if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then + local major=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local previous_versions="" + + for i in $(seq 1 "$depth"); do + local prev_minor=$((minor - i)) + if [ $prev_minor -ge 0 ]; then + local prev_version="${major}.${prev_minor}.7" + if [ -z "$previous_versions" ]; then + previous_versions="$prev_version" + else + previous_versions="$previous_versions,$prev_version" + fi + fi + done + echo "$previous_versions" + else + echo "" + fi + else + if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then + local major=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local patch=${BASH_REMATCH[3]} + local previous_versions="" + local patches_added=0 + + for i in $(seq 1 "$depth"); do + if [ $patches_added -ge "$depth" ]; then + break + fi + + local prev_patch=$((patch - i)) + if [ $prev_patch -ge 0 ]; then + local prev_version="${major}.${minor}.${prev_patch}" + if [ -z "$previous_versions" ]; then + previous_versions="$prev_version" + else + previous_versions="$previous_versions,$prev_version" + fi + patches_added=$((patches_added + 1)) + else + local prev_minor=$((minor - 1)) + if [ $prev_minor -ge 0 ] && [ $patches_added -lt "$depth" ]; then + local prev_version="${major}.${prev_minor}.9" + if [ -z "$previous_versions" ]; then + previous_versions="$prev_version" + else + previous_versions="$previous_versions,$prev_version" + fi + patches_added=$((patches_added + 1)) + fi + break + fi + done + + echo "$previous_versions" + else + echo "" + fi + fi +} + +write_github_output() { + local key="$1" + local value="$2" + + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "${key}=${value}" >>"$GITHUB_OUTPUT" + fi +} + +if [[ "$HT_VERSION" == "main" ]]; then + HT_GA_LATEST=$(get_wp_org_theme_latest_version "hello-elementor") + if [[ -n "$HT_GA_LATEST" ]]; then + HT_VERSION_FOR_MATRIX="$HT_GA_LATEST" + else + HT_GA_LATEST=$(get_latest_version "elementor/hello-theme") + if [[ -n "$HT_GA_LATEST" ]]; then + HT_VERSION_FOR_MATRIX="$HT_GA_LATEST" + else + HT_VERSION_FOR_MATRIX="main" + fi + fi +else + HT_VERSION_FOR_MATRIX="$HT_VERSION" +fi + +if [[ "$HP_VERSION" == "latest-stable" ]]; then + HP_LATEST=$(get_wp_org_latest_version "hello-plus") + if [[ -n "$HP_LATEST" ]]; then + HP_VERSION_FOR_MATRIX="$HP_LATEST" + else + HP_VERSION_FOR_MATRIX="latest-stable" + fi +else + HP_VERSION_FOR_MATRIX="$HP_VERSION" +fi + +HT_VERSION=$(validate_version_availability "$HT_VERSION" "Hello Theme") +HP_VERSION=$(validate_version_availability "$HP_VERSION" "Hello Plus") +EL_VERSION=$(validate_version_availability "$EL_VERSION" "Elementor") + +write_github_output "hello-theme-version" "$HT_VERSION" +write_github_output "hello-plus-version" "$HP_VERSION" +write_github_output "elementor-version" "$EL_VERSION" +write_github_output "hello-theme-version-for-display" "$HT_VERSION_DISPLAY" + +TARGETED_TESTS="[]" + +if [[ "$RUN_TARGETED_TESTS" == "true" ]]; then + ELEMENTOR_PREVIOUS=$(calculate_previous_versions "$EL_VERSION" "$DEPTH" "elementor") + HELLO_PLUS_PREVIOUS=$(calculate_previous_versions "$HP_VERSION" "$DEPTH" "theme") + HELLO_THEME_PREVIOUS=$(calculate_previous_versions "$HT_VERSION_FOR_MATRIX" "$DEPTH" "theme") + + write_github_output "hello-theme-previous" "$HELLO_THEME_PREVIOUS" + + TARGETED_TESTS="[" + DELAY_COUNTER=0 + + add_test_combination() { + local combination=$1 + local name=$2 + local ht_ver=$3 + local el_ver=$4 + local hp_ver=$5 + local delay=$6 + + if [[ "$TARGETED_TESTS" != "[" ]]; then + TARGETED_TESTS="${TARGETED_TESTS}," + fi + + if [[ -n "$hp_ver" ]]; then + TARGETED_TESTS="${TARGETED_TESTS}{\"combination\":\"${combination}\",\"name\":\"${name}\",\"hello_theme_version\":\"${ht_ver}\",\"hello_plus_version\":\"${hp_ver}\",\"delay\":${delay}}" + else + TARGETED_TESTS="${TARGETED_TESTS}{\"combination\":\"${combination}\",\"name\":\"${name}\",\"hello_theme_version\":\"${ht_ver}\",\"elementor_version\":\"${el_ver}\",\"delay\":${delay}}" + fi + } + + add_test_combination "ht-main-el-main" "Hello Theme main + Elementor main" "main" "main" "" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + + if [[ -n "$ELEMENTOR_PREVIOUS" ]]; then + IFS=',' read -ra EL_PREV_ARRAY <<<"$ELEMENTOR_PREVIOUS" + for el_prev in "${EL_PREV_ARRAY[@]}"; do + add_test_combination "ht-main-el-prev" "Hello Theme main + Elementor ${el_prev} (GA)" "main" "$el_prev" "" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + done + fi + + if [[ "$HT_VERSION_FOR_MATRIX" != "main" ]]; then + add_test_combination "ht-ga-el-main" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Elementor main" "$HT_VERSION_FOR_MATRIX" "main" "" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + + if [[ -n "$ELEMENTOR_PREVIOUS" ]]; then + IFS=',' read -ra EL_PREV_ARRAY <<<"$ELEMENTOR_PREVIOUS" + for el_prev in "${EL_PREV_ARRAY[@]}"; do + add_test_combination "ht-ga-el-prev" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Elementor ${el_prev} (GA)" "$HT_VERSION_FOR_MATRIX" "$el_prev" "" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + done + fi + fi + + add_test_combination "ht-main-hp-latest" "Hello Theme main + Hello Plus ${HP_VERSION}" "main" "$EL_VERSION" "$HP_VERSION" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + + if [[ -n "$HELLO_PLUS_PREVIOUS" ]]; then + IFS=',' read -ra HP_PREV_ARRAY <<<"$HELLO_PLUS_PREVIOUS" + for hp_prev in "${HP_PREV_ARRAY[@]}"; do + add_test_combination "ht-main-hp-prev" "Hello Theme main + Hello Plus ${hp_prev}" "main" "$EL_VERSION" "$hp_prev" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + done + fi + + if [[ "$HT_VERSION_FOR_MATRIX" != "main" ]]; then + add_test_combination "ht-ga-hp-latest" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Hello Plus ${HP_VERSION}" "$HT_VERSION_FOR_MATRIX" "$EL_VERSION" "$HP_VERSION" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + + if [[ -n "$HELLO_PLUS_PREVIOUS" ]]; then + IFS=',' read -ra HP_PREV_ARRAY <<<"$HELLO_PLUS_PREVIOUS" + for hp_prev in "${HP_PREV_ARRAY[@]}"; do + add_test_combination "ht-ga-hp-prev" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Hello Plus ${hp_prev}" "$HT_VERSION_FOR_MATRIX" "$EL_VERSION" "$hp_prev" $((DELAY_COUNTER * 15)) + DELAY_COUNTER=$((DELAY_COUNTER + 1)) + done + fi + fi + + TARGETED_TESTS="${TARGETED_TESTS}]" +fi + +write_github_output "targeted-tests" "$TARGETED_TESTS" + +echo "OUTPUT_START" +echo "hello-theme-version=${HT_VERSION}" +echo "hello-plus-version=${HP_VERSION}" +echo "elementor-version=${EL_VERSION}" +echo "hello-theme-version-for-display=${HT_VERSION_DISPLAY}" +echo "OUTPUT_END" +echo "JSON_START" +echo "$TARGETED_TESTS" +echo "JSON_END" diff --git a/.github/scripts/resolve-version-ref.sh b/.github/scripts/resolve-version-ref.sh new file mode 100755 index 00000000..df5723e0 --- /dev/null +++ b/.github/scripts/resolve-version-ref.sh @@ -0,0 +1,187 @@ +#!/bin/bash +set -eo pipefail + +VERSION_REF_SCRIPT_USAGE="Usage: resolve-version-ref.sh [--fetch] + +Commands: + resolve Print the matching git ref (v, V, or bare version) + exists Exit 0 when a matching ref exists, 1 otherwise + checkout Check out the matching ref + extract-playwright-tests + Extract tests/playwright/ from the matching ref and write workflow outputs" + +version_ref_candidates() { + local version="$1" + printf '%s\n' "v${version}" "V${version}" "${version}" +} + +maybe_fetch_tags() { + if [[ "${1:-}" == "--fetch" ]]; then + git fetch --all --tags --force + fi +} + +find_version_ref() { + local version="$1" + local candidate + + while IFS= read -r candidate; do + if git rev-parse --verify "$candidate" >/dev/null 2>&1; then + echo "$candidate" + return 0 + fi + done < <(version_ref_candidates "$version") + + return 1 +} + +write_github_output() { + local key="$1" + local value="$2" + + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "${key}=${value}" >>"$GITHUB_OUTPUT" + else + echo "${key}=${value}" + fi +} + +cmd_resolve() { + local version="$1" + shift + + maybe_fetch_tags "$@" + + find_version_ref "$version" +} + +cmd_exists() { + cmd_resolve "$@" >/dev/null +} + +report_version_not_found() { + local version="$1" + + echo "ERROR: Version ${version} not found" + git tag --sort=-version:refname | head -20 || true +} + +cmd_checkout() { + local version="$1" + shift + local ref + + if [[ "$version" == "main" ]]; then + echo "ERROR: Cannot checkout main with resolve-version-ref.sh" + return 1 + fi + + maybe_fetch_tags "$@" + + if ! ref="$(find_version_ref "$version")"; then + report_version_not_found "$version" + return 1 + fi + + if ! git checkout "$ref" 2>/dev/null; then + echo "ERROR: Failed to checkout ${ref}" + return 1 + fi + + echo "Checked out ${ref}" +} + +cmd_extract_playwright_tests() { + local version="$1" + shift + local candidate + local tests_available="false" + local test_version="$version" + local test_source_type="version-specific" + + maybe_fetch_tags "$@" + + if [[ "$version" == "main" ]]; then + echo "Using main branch tests (already available)" + write_github_output "test-version" "main" + write_github_output "test-source-type" "main-branch" + write_github_output "tests-available" "true" + return 0 + fi + + echo "Extracting tests from version: ${version}" + + while IFS= read -r candidate; do + echo "Checking for tag: ${candidate}" + + if ! git rev-parse --verify "$candidate" >/dev/null 2>&1; then + echo "Tag ${candidate} not found" + continue + fi + + echo "Found tag: ${candidate}" + + if ! git ls-tree -r "$candidate" | grep -q "tests/playwright/"; then + echo "No playwright tests found in ${candidate}" + continue + fi + + echo "Playwright tests found in ${candidate}" + echo "Extracting tests directory from ${candidate}..." + rm -rf ./tests/playwright/ + git archive "$candidate" tests/playwright/ | tar -x + + if [[ -d "./tests/playwright/" ]]; then + echo "Successfully extracted tests from ${candidate}" + tests_available="true" + test_version="$version" + test_source_type="extracted-from-${candidate}" + break + fi + + echo "Failed to extract tests from ${candidate}" + done < <(version_ref_candidates "$version") + + if [[ "$tests_available" != "true" ]]; then + echo "No compatible tests found for version ${version}" + echo "Will skip testing for this version (tests don't exist yet)" + test_version="none" + test_source_type="not-available" + fi + + write_github_output "test-version" "$test_version" + write_github_output "test-source-type" "$test_source_type" + write_github_output "tests-available" "$tests_available" +} + +main() { + local command="${1:-}" + + if [[ -z "$command" ]]; then + echo "$VERSION_REF_SCRIPT_USAGE" + exit 1 + fi + + shift + + case "$command" in + resolve) + cmd_resolve "$@" + ;; + exists) + cmd_exists "$@" + ;; + checkout) + cmd_checkout "$@" + ;; + extract-playwright-tests) + cmd_extract_playwright_tests "$@" + ;; + *) + echo "$VERSION_REF_SCRIPT_USAGE" + exit 1 + ;; + esac +} + +main "$@" diff --git a/.github/workflows/daily-test-matrix.yml b/.github/workflows/daily-test-matrix.yml index 9d0d9f41..0c5e2b87 100644 --- a/.github/workflows/daily-test-matrix.yml +++ b/.github/workflows/daily-test-matrix.yml @@ -89,358 +89,19 @@ jobs: targeted-tests: ${{ steps.matrix.outputs.targeted-tests }} hello-theme-version-for-display: ${{ steps.matrix.outputs.hello-theme-version-for-display }} steps: + - name: Checkout for scripts + uses: actions/checkout@v4 + - name: Calculate version matrix id: matrix run: | - # Use defaults for scheduled runs, inputs for manual runs HT_VERSION="${{ inputs.hello_theme_version || 'main' }}" HP_VERSION="${{ inputs.hello_plus_version || 'latest-stable' }}" EL_VERSION="${{ inputs.elementor_version || 'main' }}" DEPTH="${{ inputs.compatibility_depth || '2' }}" - - # Preserve original input values for display purposes - HT_VERSION_DISPLAY="$HT_VERSION" - HP_VERSION_DISPLAY="$HP_VERSION" - EL_VERSION_DISPLAY="$EL_VERSION" - - # Function to get latest released version from GitHub - get_latest_version() { - local repo=$1 - local latest_version - - # Get latest release tag from GitHub API - latest_version=$(curl -s "https://api.github.com/repos/${repo}/releases/latest" | jq -r '.tag_name // empty') - - # Remove 'v' prefix if present - latest_version=${latest_version#v} - - # If no version found or empty, return empty - if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then - echo "" - else - echo "$latest_version" - fi - } - - # Function to get latest version from WordPress.org API (plugins) - get_wp_org_latest_version() { - local plugin_slug=$1 - local latest_version - - # Get plugin info from WordPress.org API - latest_version=$(curl -s "https://api.wordpress.org/plugins/info/1.0/${plugin_slug}.json" | jq -r '.version // empty') - - # If no version found or empty, return empty - if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then - echo "" - else - echo "$latest_version" - fi - } - - # Function to get latest version from WordPress.org API (themes) - get_wp_org_theme_latest_version() { - local theme_slug=$1 - local latest_version - - # Get theme info from WordPress.org API (URL-encoded array syntax) - latest_version=$(curl -s "https://api.wordpress.org/themes/info/1.1/?action=theme_information&request%5Bslug%5D=${theme_slug}" | jq -r '.version // empty') - - # If no version found or empty, return empty - if [[ -z "$latest_version" || "$latest_version" == "null" ]]; then - echo "" - else - echo "$latest_version" - fi - } - - echo "🧮 Calculating Hello Theme Daily Test Matrix" - echo "==============================================" - echo "Input versions:" - echo "- Hello Theme: $HT_VERSION" - echo "- Hello Plus: $HP_VERSION" - echo "- Elementor: $EL_VERSION" - echo "- Compatibility depth: $DEPTH" - echo "" - - # Resolve Hello Theme GA version for matrix calculation - if [[ "$HT_VERSION" == "main" ]]; then - # For scheduled runs, try to detect the latest GA version - HT_GA_LATEST="" - - # Hello Theme is published to WordPress.org, try there first - HT_GA_LATEST=$(get_wp_org_theme_latest_version "hello-elementor") - if [[ -n "$HT_GA_LATEST" ]]; then - echo "🔍 Detected Hello Theme GA -> ${HT_GA_LATEST} (from WordPress.org)" - HT_VERSION_FOR_MATRIX="$HT_GA_LATEST" - else - # Fallback to GitHub (may not be publicly available for themes) - HT_GA_LATEST=$(get_latest_version "elementor/hello-theme") - if [[ -n "$HT_GA_LATEST" ]]; then - echo "🔍 Detected Hello Theme GA -> ${HT_GA_LATEST} (from GitHub)" - HT_VERSION_FOR_MATRIX="$HT_GA_LATEST" - else - echo "⚠️ Could not detect Hello Theme GA version, using main only" - HT_VERSION_FOR_MATRIX="main" - fi - fi - else - HT_VERSION_FOR_MATRIX="$HT_VERSION" - fi - - # Handle Hello Plus (WordPress.org releases only) - if [[ "$HP_VERSION" == "latest-stable" ]]; then - # For latest-stable, we need to resolve to actual version number for matrix calculation - HP_LATEST=$(get_wp_org_latest_version "hello-plus") - if [[ -n "$HP_LATEST" ]]; then - echo "🔍 Resolved Hello Plus latest-stable -> ${HP_LATEST} (from WordPress.org)" - HP_VERSION_FOR_MATRIX="$HP_LATEST" - else - echo "⚠️ Could not resolve Hello Plus latest version from WordPress.org, using latest-stable" - HP_VERSION_FOR_MATRIX="latest-stable" - fi - else - HP_VERSION_FOR_MATRIX="$HP_VERSION" - fi + RUN_TARGETED_TESTS="${{ inputs.run_targeted_tests == false && 'false' || 'true' }}" - # Validation: If WordPress version is required but not available, use main version - # This handles the case when no GA versions exist yet (e.g., releasing 3.5.0) - validate_version_availability() { - local version=$1 - local plugin_name=$2 - - # If version is "main", it's always available - if [[ "$version" == "main" ]]; then - echo "$version" - return 0 - fi - - # Special case for Hello Plus: "latest-stable" is valid - if [[ "$plugin_name" == "Hello Plus" && "$version" == "latest-stable" ]]; then - echo "$version" - return 0 - fi - - # Check if it's a semantic version format - if [[ $version =~ ^([0-9]+)\.([0-9]+) ]]; then - # For Hello Theme 3.5.0 (first release), previous versions won't exist - # For other plugins, we assume the version exists if it's in semantic format - echo "$version" - else - if [[ "$plugin_name" == "Hello Plus" ]]; then - echo "⚠️ Invalid version format for $plugin_name: '$version', falling back to latest-stable" - echo "latest-stable" - else - echo "⚠️ Invalid version format for $plugin_name: '$version', falling back to main" - echo "main" - fi - fi - } - - # Validate and potentially fallback versions - HT_VERSION=$(validate_version_availability "$HT_VERSION" "Hello Theme") - HP_VERSION=$(validate_version_availability "$HP_VERSION" "Hello Plus") - EL_VERSION=$(validate_version_availability "$EL_VERSION" "Elementor") - - echo "hello-theme-version=${HT_VERSION}" >> $GITHUB_OUTPUT - echo "hello-plus-version=${HP_VERSION}" >> $GITHUB_OUTPUT - echo "elementor-version=${EL_VERSION}" >> $GITHUB_OUTPUT - echo "hello-theme-version-for-display=${HT_VERSION_DISPLAY}" >> $GITHUB_OUTPUT - - # Function to calculate previous versions with different strategies - calculate_previous_versions() { - local version=$1 - local depth=$2 - local strategy=${3:-"elementor"} # "elementor" for minor-based, "theme" for patch-based - - if [[ "$version" == "main" || "$version" == "latest-stable" ]]; then - echo "" - return 0 - fi - - # Different strategies based on plugin type - if [[ "$strategy" == "elementor" ]]; then - # Elementor: Minor-level versioning (3.30.4 -> 3.29.x, 3.28.x) - if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then - major=${BASH_REMATCH[1]} - minor=${BASH_REMATCH[2]} - patch=${BASH_REMATCH[3]} - - previous_versions="" - for i in $(seq 1 $depth); do - prev_minor=$((minor - i)) - if [ $prev_minor -ge 0 ]; then - # For Elementor, assume latest patch in previous minor (e.g., 3.29.7) - prev_version="${major}.${prev_minor}.7" - if [ -z "$previous_versions" ]; then - previous_versions="$prev_version" - else - previous_versions="$previous_versions,$prev_version" - fi - fi - done - echo "$previous_versions" - else - echo "" - return 0 - fi - else - # Hello Theme & Hello Plus: Patch-level versioning (3.4.4 -> 3.4.3, 3.4.2) - if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then - major=${BASH_REMATCH[1]} - minor=${BASH_REMATCH[2]} - patch=${BASH_REMATCH[3]} - - previous_versions="" - - # Strategy: Get patch versions in current minor, then latest of previous minor - # Example: 3.4.4 -> 3.4.3, then 3.3.x (latest) - - # First, get previous patch versions in current minor - local patches_added=0 - for i in $(seq 1 $depth); do - if [ $patches_added -ge $depth ]; then - break - fi - - prev_patch=$((patch - i)) - if [ $prev_patch -ge 0 ]; then - prev_version="${major}.${minor}.${prev_patch}" - if [ -z "$previous_versions" ]; then - previous_versions="$prev_version" - else - previous_versions="$previous_versions,$prev_version" - fi - patches_added=$((patches_added + 1)) - else - # If we run out of patches, try previous minor - prev_minor=$((minor - 1)) - if [ $prev_minor -ge 0 ] && [ $patches_added -lt $depth ]; then - # Assume latest patch in previous minor (e.g., 3.3.9) - prev_version="${major}.${prev_minor}.9" - if [ -z "$previous_versions" ]; then - previous_versions="$prev_version" - else - previous_versions="$previous_versions,$prev_version" - fi - patches_added=$((patches_added + 1)) - fi - break - fi - done - - echo "$previous_versions" - else - echo "" - return 0 - fi - fi - } - - # Calculate previous versions for each component - if [[ "${{ inputs.run_targeted_tests || 'true' }}" == "true" ]]; then - ELEMENTOR_PREVIOUS=$(calculate_previous_versions "$EL_VERSION" "$DEPTH" "elementor") - HELLO_PLUS_PREVIOUS=$(calculate_previous_versions "$HP_VERSION" "$DEPTH" "theme") - HELLO_THEME_PREVIOUS=$(calculate_previous_versions "$HT_VERSION_FOR_MATRIX" "$DEPTH" "theme") - - echo "hello-theme-previous=${HELLO_THEME_PREVIOUS}" >> $GITHUB_OUTPUT - - echo "" - echo "📋 Version Matrix Calculation Complete:" - echo "- Hello Theme: $HT_VERSION (previous: ${HELLO_THEME_PREVIOUS:-none})" - echo "- Hello Plus: $HP_VERSION (previous: ${HELLO_PLUS_PREVIOUS:-none})" - echo "- Elementor: $EL_VERSION (previous: ${ELEMENTOR_PREVIOUS:-none})" - echo "" - - # Generate targeted test matrix - TARGETED_TESTS="[" - DELAY_COUNTER=0 - - # Helper function to add test combination - add_test_combination() { - local combination=$1 - local name=$2 - local ht_ver=$3 - local el_ver=$4 - local hp_ver=$5 - local delay=$6 - - if [[ "$TARGETED_TESTS" != "[" ]]; then - TARGETED_TESTS="${TARGETED_TESTS}," - fi - - if [[ -n "$hp_ver" ]]; then - TARGETED_TESTS="${TARGETED_TESTS}{\"combination\":\"${combination}\",\"name\":\"${name}\",\"hello_theme_version\":\"${ht_ver}\",\"hello_plus_version\":\"${hp_ver}\",\"elementor_version\":\"${el_ver}\",\"delay\":${delay}}" - else - TARGETED_TESTS="${TARGETED_TESTS}{\"combination\":\"${combination}\",\"name\":\"${name}\",\"hello_theme_version\":\"${ht_ver}\",\"elementor_version\":\"${el_ver}\",\"delay\":${delay}}" - fi - } - - # Core Matrix: Hello Theme × Elementor - # Main Hello Theme combinations - add_test_combination "ht-main-el-main" "Hello Theme main + Elementor main" "main" "main" "" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - - if [[ -n "$ELEMENTOR_PREVIOUS" ]]; then - IFS=',' read -ra EL_PREV_ARRAY <<< "$ELEMENTOR_PREVIOUS" - for el_prev in "${EL_PREV_ARRAY[@]}"; do - add_test_combination "ht-main-el-prev" "Hello Theme main + Elementor ${el_prev} (GA)" "main" "$el_prev" "" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - done - fi - - # GA Hello Theme combinations (if detected) - if [[ "$HT_VERSION_FOR_MATRIX" != "main" ]]; then - add_test_combination "ht-ga-el-main" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Elementor main" "$HT_VERSION_FOR_MATRIX" "main" "" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - - if [[ -n "$ELEMENTOR_PREVIOUS" ]]; then - IFS=',' read -ra EL_PREV_ARRAY <<< "$ELEMENTOR_PREVIOUS" - for el_prev in "${EL_PREV_ARRAY[@]}"; do - add_test_combination "ht-ga-el-prev" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Elementor ${el_prev} (GA)" "$HT_VERSION_FOR_MATRIX" "$el_prev" "" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - done - fi - fi - - # Plus Matrix: Hello Theme × Hello Plus - # Main Hello Theme combinations - add_test_combination "ht-main-hp-latest" "Hello Theme main + Hello Plus ${HP_VERSION}" "main" "$EL_VERSION" "$HP_VERSION" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - - if [[ -n "$HELLO_PLUS_PREVIOUS" ]]; then - IFS=',' read -ra HP_PREV_ARRAY <<< "$HELLO_PLUS_PREVIOUS" - for hp_prev in "${HP_PREV_ARRAY[@]}"; do - add_test_combination "ht-main-hp-prev" "Hello Theme main + Hello Plus ${hp_prev}" "main" "$EL_VERSION" "$hp_prev" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - done - fi - - # GA Hello Theme combinations (if detected) - if [[ "$HT_VERSION_FOR_MATRIX" != "main" ]]; then - add_test_combination "ht-ga-hp-latest" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Hello Plus ${HP_VERSION}" "$HT_VERSION_FOR_MATRIX" "$EL_VERSION" "$HP_VERSION" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - - if [[ -n "$HELLO_PLUS_PREVIOUS" ]]; then - IFS=',' read -ra HP_PREV_ARRAY <<< "$HELLO_PLUS_PREVIOUS" - for hp_prev in "${HP_PREV_ARRAY[@]}"; do - add_test_combination "ht-ga-hp-prev" "Hello Theme ${HT_VERSION_FOR_MATRIX} (GA) + Hello Plus ${hp_prev}" "$HT_VERSION_FOR_MATRIX" "$EL_VERSION" "$hp_prev" $((DELAY_COUNTER * 15)) - DELAY_COUNTER=$((DELAY_COUNTER + 1)) - done - fi - fi - - TARGETED_TESTS="${TARGETED_TESTS}]" - - echo "targeted-tests=${TARGETED_TESTS}" >> $GITHUB_OUTPUT - - echo "" - echo "🎯 Generated Targeted Test Matrix:" - echo "$TARGETED_TESTS" | jq '.' - else - echo "⏭️ Skipping targeted test matrix generation (run_targeted_tests=false)" - echo "targeted-tests=[]" >> $GITHUB_OUTPUT - fi + ./.github/scripts/generate-targeted-matrix.sh "$HT_VERSION" "$HP_VERSION" "$EL_VERSION" "$DEPTH" "$RUN_TARGETED_TESTS" notify-on-early-failure: name: Notify on Early Failure @@ -498,8 +159,7 @@ jobs: } else { inputs = { hello_plus_version: '${{ matrix.hello_plus_version || 'latest-stable' }}', - hello_theme_version: '${{ matrix.hello_theme_version || 'main' }}', - elementor_core_branch: '${{ matrix.elementor_version || 'main' }}' + hello_theme_version: '${{ matrix.hello_theme_version || 'main' }}' }; } @@ -712,7 +372,7 @@ jobs: echo "|-----------|---------------|-------------------|" >> $GITHUB_STEP_SUMMARY echo "| Hello Theme | \`${{ needs.calculate-test-matrix.outputs.hello-theme-version-for-display }}\` | GitHub/WordPress.org |" >> $GITHUB_STEP_SUMMARY echo "| Hello Plus | \`${{ needs.calculate-test-matrix.outputs.hello-plus-version }}\` | WordPress.org |" >> $GITHUB_STEP_SUMMARY - echo "| Elementor | \`${{ needs.calculate-test-matrix.outputs.elementor-version }}\` | WordPress.org/GitHub |" >> $GITHUB_STEP_SUMMARY + echo "| Elementor | \`${{ needs.calculate-test-matrix.outputs.elementor-version }}\` | GitHub Releases |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Previous versions included in matrix:** ${{ needs.calculate-test-matrix.outputs.hello-theme-previous || 'none' }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/playwright-with-specific-elementor-version.yml b/.github/workflows/playwright-with-specific-elementor-version.yml index 670f3ef4..f8e5176c 100644 --- a/.github/workflows/playwright-with-specific-elementor-version.yml +++ b/.github/workflows/playwright-with-specific-elementor-version.yml @@ -48,7 +48,6 @@ jobs: hello-theme-version: ${{ steps.set-versions.outputs.hello-theme-version }} elementor-core-branch: ${{ steps.set-versions.outputs.elementor-core-branch }} elementor-version: ${{ steps.download-elementor.outputs.effective-version }} - hello-theme-source: ${{ steps.set-versions.outputs.hello-theme-source }} artifact-name: ${{ steps.set-versions.outputs.artifact-name }} steps: - name: Checkout Hello Theme @@ -56,90 +55,72 @@ jobs: with: fetch-depth: 0 - - name: Set version outputs + - name: Install Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "npm" + + - name: Setup PHP + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 + with: + php-version: "8.1" + tools: composer + coverage: none + + - name: Set version variables id: set-versions run: | - # Set Elementor Core branch from input (can be branch name or version) - ELEMENTOR_CORE_BRANCH="${{ inputs.core_branch }}" - - # Hello Theme version from current repo (like Hello Commerce pattern) + ELEMENTOR_CORE_BRANCH="${{ inputs.core_branch || 'main' }}" + HELLO_THEME_SOURCE="${{ inputs.hello_theme_version || 'main' }}" HT_VERSION=$(node -p "require('./package.json').version") - # Input version for reference (main, etc.) - HELLO_THEME_INPUT="${{ inputs.hello_theme_version || 'main' }}" - - # Determine source type for reporting - Hello Theme always builds from GitHub - # Unlike Hello Commerce/Biz, Hello Theme doesn't download from WordPress.org - if [[ "$HELLO_THEME_INPUT" == "main" ]]; then - HELLO_THEME_SOURCE_TYPE="git-branch" - HELLO_THEME_SOURCE="github" - elif [[ "$HELLO_THEME_INPUT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - # Released version input, but still built from GitHub source - HELLO_THEME_SOURCE_TYPE="git-tag" - HELLO_THEME_SOURCE="github" - else - # Other cases (branches, etc.) - HELLO_THEME_SOURCE_TYPE="git-branch" - HELLO_THEME_SOURCE="github" - fi + echo "ELEMENTOR_CORE_BRANCH=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_ENV + echo "HELLO_THEME_SOURCE=${HELLO_THEME_SOURCE}" >> $GITHUB_ENV + echo "HELLO_THEME_VERSION=${HT_VERSION}" >> $GITHUB_ENV echo "hello-theme-version=${HT_VERSION}" >> $GITHUB_OUTPUT - echo "hello-theme-input=${HELLO_THEME_INPUT}" >> $GITHUB_OUTPUT - echo "hello-theme-source-type=${HELLO_THEME_SOURCE_TYPE}" >> $GITHUB_OUTPUT - echo "hello-theme-source=${HELLO_THEME_SOURCE}" >> $GITHUB_OUTPUT + echo "hello-theme-input=${HELLO_THEME_SOURCE}" >> $GITHUB_OUTPUT echo "elementor-core-branch=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_OUTPUT - # Set environment variables for later steps - echo "HELLO_THEME_VERSION=${HT_VERSION}" >> $GITHUB_ENV - echo "HELLO_THEME_INPUT=${HELLO_THEME_INPUT}" >> $GITHUB_ENV - echo "HELLO_THEME_SOURCE_TYPE=${HELLO_THEME_SOURCE_TYPE}" >> $GITHUB_ENV - - # Generate artifact name using input version for readability - ARTIFACT_NAME="core-ht${HELLO_THEME_INPUT}-el${ELEMENTOR_CORE_BRANCH}-${{ github.run_id }}" + ARTIFACT_NAME="core-ht${HELLO_THEME_SOURCE}-el${ELEMENTOR_CORE_BRANCH}-${{ github.run_id }}" echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT - echo "Set versions: Hello Theme=${HT_VERSION} (${HELLO_THEME_INPUT}), Elementor=${ELEMENTOR_CORE_BRANCH}" + - name: Preserve workflow infrastructure + run: cp -r .github .github-main-backup + + - name: Checkout specific Hello Theme version + run: | + if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then + bash .github/scripts/resolve-version-ref.sh checkout "$HELLO_THEME_SOURCE" --fetch + ACTUAL_VERSION=$(node -p "require('./package.json').version") + if [[ "$ACTUAL_VERSION" != "$HELLO_THEME_SOURCE" ]]; then + echo "ERROR: Version mismatch - Expected: $HELLO_THEME_SOURCE, Got: $ACTUAL_VERSION" + exit 1 + fi + fi + + - name: Restore main branch workflow infrastructure + run: | + if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then + rm -rf .github + mv .github-main-backup .github + else + rm -rf .github-main-backup + fi + echo "HELLO_THEME_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - name: Build Hello Theme uses: ./.github/workflows/build-theme with: - PACKAGE_VERSION: ${{ steps.set-versions.outputs.hello-theme-version }} + PACKAGE_VERSION: ${{ env.HELLO_THEME_VERSION }} BUILD_SCRIPT_PATH: "npm run build:prod" - name: Download Elementor Core id: download-elementor - run: | - ELEMENTOR_CORE_BRANCH="${{ steps.set-versions.outputs.elementor-core-branch }}" - echo "Downloading Elementor Core branch: ${ELEMENTOR_CORE_BRANCH}" - - # Create Elementor build directory - mkdir -p ./tmp - - if [[ "$ELEMENTOR_CORE_BRANCH" == "latest-stable" ]]; then - # Download latest stable from WordPress.org - curl --location -o ./elementor-core.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "Elementor latest-stable downloaded and extracted" - echo "effective-version=latest-stable" >> $GITHUB_OUTPUT - elif [[ "$ELEMENTOR_CORE_BRANCH" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - # Download specific version from WordPress.org - curl --location -o ./elementor-core.zip "https://downloads.wordpress.org/plugin/elementor.${ELEMENTOR_CORE_BRANCH}.zip" - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "Elementor ${ELEMENTOR_CORE_BRANCH} downloaded and extracted" - echo "effective-version=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_OUTPUT - else - # For branches like 'main', we need GitHub artifacts - # This should be provided by the calling workflow - echo "GitHub artifacts for Elementor branches not implemented yet" - echo "For now, using latest-stable as fallback" - curl --location -o ./elementor-core.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "Using Elementor latest-stable as fallback for branch: ${ELEMENTOR_CORE_BRANCH}" - echo "effective-version=latest-stable" >> $GITHUB_OUTPUT - fi + env: + ELEMENTOR_CORE_BRANCH: ${{ steps.set-versions.outputs.elementor-core-branch }} + run: bash .github/scripts/download-elementor-core.sh - name: Upload core build artifacts uses: actions/upload-artifact@v4 @@ -153,13 +134,10 @@ jobs: - name: Generate build summary run: | echo "## Build Summary" >> $GITHUB_STEP_SUMMARY - echo "|-----------------|----------------------------|-----------------------|" >> $GITHUB_STEP_SUMMARY - echo "| Component | Version | Source |" >> $GITHUB_STEP_SUMMARY - echo "|-----------------|----------------------------|-----------------------|" >> $GITHUB_STEP_SUMMARY - echo "| Hello Theme | ${{ env.HELLO_THEME_VERSION }} (${{ env.HELLO_THEME_INPUT }}) | ${{ env.HELLO_THEME_SOURCE_TYPE }} |" >> $GITHUB_STEP_SUMMARY - echo "| Elementor Core | ${{ steps.download-elementor.outputs.effective-version }} | WordPress.org/GitHub |" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Strategy:** GitHub source for Hello Theme (always built), WordPress.org for Elementor versions" >> $GITHUB_STEP_SUMMARY + echo "| Component | Version | Source |" >> $GITHUB_STEP_SUMMARY + echo "|-----------|---------|--------|" >> $GITHUB_STEP_SUMMARY + echo "| Hello Theme | ${{ env.HELLO_THEME_VERSION }} (${{ env.HELLO_THEME_SOURCE }}) | GitHub |" >> $GITHUB_STEP_SUMMARY + echo "| Elementor Core | ${{ steps.download-elementor.outputs.effective-version }} | GitHub Releases |" >> $GITHUB_STEP_SUMMARY core-playwright-tests: name: Hello Theme + Elementor Tests @@ -176,88 +154,9 @@ jobs: with: fetch-depth: 0 - - name: Debug artifact download location - run: | - echo "Current directory contents before artifact download:" - ls -la ./ - echo "Creating tmp directory if it doesn't exist:" - mkdir -p ./tmp - - - name: Hybrid Test Setup - Extract tests from target version + - name: Extract tests from target version id: extract-version-tests - run: | - echo "HYBRID APPROACH: Always latest workflows + version-specific tests" - echo "Workflow infrastructure: main branch (latest build-wp-env.js, scripts, etc.)" - echo "Test content: ${{ inputs.hello_theme_version || 'main' }} (matches theme functionality)" - - # Determine the target version for test extraction - TARGET_VERSION="${{ inputs.hello_theme_version || 'main' }}" - - if [ "$TARGET_VERSION" = "main" ]; then - echo "Using main branch tests (already available)" - TEST_VERSION="main" - TEST_SOURCE_TYPE="main-branch" - TESTS_AVAILABLE="true" - else - echo "Extracting tests from version: $TARGET_VERSION" - - # Fetch all tags and branches - git fetch --all --tags - - # Check if target version exists and has tests - TESTS_AVAILABLE="false" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="version-specific" - - # Try different tag formats - for TAG_FORMAT in "v$TARGET_VERSION" "$TARGET_VERSION"; do - echo "Checking for tag: $TAG_FORMAT" - if git rev-parse --verify "$TAG_FORMAT" >/dev/null 2>&1; then - echo "Found tag: $TAG_FORMAT" - - # Check if this version has playwright tests - if git ls-tree -r "$TAG_FORMAT" | grep -q "tests/playwright/"; then - echo "Playwright tests found in $TAG_FORMAT" - - # Extract tests directory from target version - echo "Extracting tests directory from $TAG_FORMAT..." - rm -rf ./tests/playwright/ - git archive "$TAG_FORMAT" tests/playwright/ | tar -x - - if [ -d "./tests/playwright/" ]; then - echo "Successfully extracted tests from $TAG_FORMAT" - TESTS_AVAILABLE="true" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="extracted-from-$TAG_FORMAT" - break - else - echo "Failed to extract tests from $TAG_FORMAT" - fi - else - echo "No playwright tests found in $TAG_FORMAT" - fi - else - echo "Tag $TAG_FORMAT not found" - fi - done - - if [ "$TESTS_AVAILABLE" = "false" ]; then - echo "No compatible tests found for version $TARGET_VERSION" - echo "Will skip testing for this version (tests don't exist yet)" - TEST_VERSION="none" - TEST_SOURCE_TYPE="not-available" - fi - fi - - # Set outputs for workflow control - echo "test-version=$TEST_VERSION" >> $GITHUB_OUTPUT - echo "test-source-type=$TEST_SOURCE_TYPE" >> $GITHUB_OUTPUT - echo "tests-available=$TESTS_AVAILABLE" >> $GITHUB_OUTPUT - - echo "Hybrid setup complete:" - echo "Workflow infrastructure: main branch" - echo "Test content: $TEST_VERSION ($TEST_SOURCE_TYPE)" - echo "Tests available: $TESTS_AVAILABLE" + run: bash .github/scripts/resolve-version-ref.sh extract-playwright-tests "${{ inputs.hello_theme_version || 'main' }}" --fetch - name: Install Node.js 20.x uses: actions/setup-node@v4 @@ -266,7 +165,7 @@ jobs: cache: "npm" - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 with: php-version: "8.1" tools: composer @@ -285,64 +184,8 @@ jobs: name: ${{ needs.build-core-components.outputs.artifact-name }} path: ./ - - name: Debug and fix artifacts structure - run: | - echo "=== ARTIFACT DEBUG & FIX ===" - echo "Current directory contents:" - ls -la ./ - echo "" - - # Ensure tmp directory exists - mkdir -p ./tmp - - echo "Checking for Elementor artifacts:" - if [ -d "./tmp/elementor" ]; then - echo "Elementor directory found in tmp" - echo "Contents of ./tmp/elementor/ (first 10):" - ls -la ./tmp/elementor/ | head -10 - - # Verify Elementor plugin file - if [ -f "./tmp/elementor/elementor.php" ]; then - echo "Elementor plugin file verified" - else - echo "Missing elementor.php - attempting to fix" - # Try to find and move Elementor from other locations - if [ -d "./elementor" ]; then - echo "Found Elementor in root, moving to tmp" - mv "./elementor" "./tmp/elementor" - else - echo "Downloading Elementor latest-stable as fallback" - curl --location -o ./elementor-fallback.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-fallback.zip - mv ./elementor ./tmp/elementor - echo "Elementor fallback installed" - fi - fi - else - echo "No Elementor directory - creating fallback" - # Check for loose Elementor files and move them - if [ -d "./elementor" ]; then - echo "Found Elementor in root, moving to tmp" - mv "./elementor" "./tmp/elementor" - else - echo "Downloading Elementor latest-stable as fallback" - curl --location -o ./elementor-fallback.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-fallback.zip - mv ./elementor ./tmp/elementor - echo "Elementor fallback installed" - fi - fi - - echo "" - echo "Final verification:" - echo "tmp directory contents:" - ls -la ./tmp/ - if [ -f "./tmp/elementor/elementor.php" ]; then - echo "Elementor is ready at ./tmp/elementor/" - else - echo "Elementor setup failed" - exit 1 - fi + - name: Verify Elementor artifact + run: test -f ./tmp/elementor/elementor.php - name: Extract Hello Theme build uses: ./.github/actions/extract-hello-theme-zip @@ -440,81 +283,9 @@ jobs: with: fetch-depth: 0 - - name: Hybrid Test Setup - Extract tests from target version + - name: Extract tests from target version id: extract-version-tests - run: | - echo "HYBRID APPROACH: Always latest workflows + version-specific tests" - echo "Workflow infrastructure: main branch (latest build-wp-env.js, scripts, etc.)" - echo "Test content: ${{ inputs.hello_theme_version || 'main' }} (matches theme functionality)" - - # Determine the target version for test extraction - TARGET_VERSION="${{ inputs.hello_theme_version || 'main' }}" - - if [ "$TARGET_VERSION" = "main" ]; then - echo "Using main branch tests (already available)" - TEST_VERSION="main" - TEST_SOURCE_TYPE="main-branch" - TESTS_AVAILABLE="true" - else - echo "Extracting tests from version: $TARGET_VERSION" - - # Fetch all tags and branches - git fetch --all --tags - - # Check if target version exists and has tests - TESTS_AVAILABLE="false" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="version-specific" - - # Try different tag formats - for TAG_FORMAT in "v$TARGET_VERSION" "$TARGET_VERSION"; do - echo "Checking for tag: $TAG_FORMAT" - if git rev-parse --verify "$TAG_FORMAT" >/dev/null 2>&1; then - echo "Found tag: $TAG_FORMAT" - - # Check if this version has playwright tests - if git ls-tree -r "$TAG_FORMAT" | grep -q "tests/playwright/"; then - echo "Playwright tests found in $TAG_FORMAT" - - # Extract tests directory from target version - echo "Extracting tests directory from $TAG_FORMAT..." - rm -rf ./tests/playwright/ - git archive "$TAG_FORMAT" tests/playwright/ | tar -x - - if [ -d "./tests/playwright/" ]; then - echo "Successfully extracted tests from $TAG_FORMAT" - TESTS_AVAILABLE="true" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="extracted-from-$TAG_FORMAT" - break - else - echo "Failed to extract tests from $TAG_FORMAT" - fi - else - echo "No playwright tests found in $TAG_FORMAT" - fi - else - echo "Tag $TAG_FORMAT not found" - fi - done - - if [ "$TESTS_AVAILABLE" = "false" ]; then - echo "No compatible tests found for version $TARGET_VERSION" - echo "Will skip testing for this version (tests don't exist yet)" - TEST_VERSION="none" - TEST_SOURCE_TYPE="not-available" - fi - fi - - # Set outputs for workflow control - echo "test-version=$TEST_VERSION" >> $GITHUB_OUTPUT - echo "test-source-type=$TEST_SOURCE_TYPE" >> $GITHUB_OUTPUT - echo "tests-available=$TESTS_AVAILABLE" >> $GITHUB_OUTPUT - - echo "Hybrid setup complete:" - echo "Workflow infrastructure: main branch" - echo "Test content: $TEST_VERSION ($TEST_SOURCE_TYPE)" - echo "Tests available: $TESTS_AVAILABLE" + run: bash .github/scripts/resolve-version-ref.sh extract-playwright-tests "${{ inputs.hello_theme_version || 'main' }}" --fetch - name: Install Node.js 20.x uses: actions/setup-node@v4 @@ -523,7 +294,7 @@ jobs: cache: "npm" - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 with: php-version: "8.1" tools: composer @@ -542,64 +313,8 @@ jobs: name: ${{ needs.build-core-components.outputs.artifact-name }} path: ./ - - name: Debug and fix artifacts structure - run: | - echo "=== ARTIFACT DEBUG & FIX ===" - echo "Current directory contents:" - ls -la ./ - echo "" - - # Ensure tmp directory exists - mkdir -p ./tmp - - echo "Checking for Elementor artifacts:" - if [ -d "./tmp/elementor" ]; then - echo "Elementor directory found in tmp" - echo "Contents of ./tmp/elementor/ (first 10):" - ls -la ./tmp/elementor/ | head -10 - - # Verify Elementor plugin file - if [ -f "./tmp/elementor/elementor.php" ]; then - echo "Elementor plugin file verified" - else - echo "Missing elementor.php - attempting to fix" - # Try to find and move Elementor from other locations - if [ -d "./elementor" ]; then - echo "Found Elementor in root, moving to tmp" - mv "./elementor" "./tmp/elementor" - else - echo "Downloading Elementor latest-stable as fallback" - curl --location -o ./elementor-fallback.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-fallback.zip - mv ./elementor ./tmp/elementor - echo "Elementor fallback installed" - fi - fi - else - echo "No Elementor directory - creating fallback" - # Check for loose Elementor files and move them - if [ -d "./elementor" ]; then - echo "Found Elementor in root, moving to tmp" - mv "./elementor" "./tmp/elementor" - else - echo "Downloading Elementor latest-stable as fallback" - curl --location -o ./elementor-fallback.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-fallback.zip - mv ./elementor ./tmp/elementor - echo "Elementor fallback installed" - fi - fi - - echo "" - echo "Final verification:" - echo "tmp directory contents:" - ls -la ./tmp/ - if [ -f "./tmp/elementor/elementor.php" ]; then - echo "Elementor is ready at ./tmp/elementor/" - else - echo "Elementor setup failed" - exit 1 - fi + - name: Verify Elementor artifact + run: test -f ./tmp/elementor/elementor.php - name: Extract Hello Theme build uses: ./.github/actions/extract-hello-theme-zip diff --git a/.github/workflows/playwright-with-specific-hello-plus-version.yml b/.github/workflows/playwright-with-specific-hello-plus-version.yml index 6866b739..8f8de683 100644 --- a/.github/workflows/playwright-with-specific-hello-plus-version.yml +++ b/.github/workflows/playwright-with-specific-hello-plus-version.yml @@ -12,11 +12,6 @@ on: required: false default: "main" type: string - elementor_core_branch: - description: "Elementor version (same as Core matrix core_branch: latest-stable, x.y.z, or main)" - required: false - default: "latest-stable" - type: string tag: description: "Provide @tag or a keyword" required: false @@ -31,11 +26,6 @@ on: description: "Hello Theme version to test (e.g., 3.4.4 or main)" required: false type: string - elementor_core_branch: - description: "Elementor version (same semantics as Core matrix core_branch)" - required: false - type: string - default: "latest-stable" tag: description: "Provide @tag or a keyword" required: false @@ -64,85 +54,89 @@ jobs: with: fetch-depth: 0 - - name: Set version variables and Hello Plus version + - name: Install Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "npm" + + - name: Setup PHP + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 + with: + php-version: "8.1" + tools: composer + coverage: none + + - name: Set version variables id: set-versions run: | HELLO_PLUS_VERSION="${{ inputs.hello_plus_version }}" - HELLO_THEME_INPUT="${{ inputs.hello_theme_version || 'main' }}" - ELEMENTOR_CORE_BRANCH="${{ inputs.elementor_core_branch || 'latest-stable' }}" + HELLO_THEME_SOURCE="${{ inputs.hello_theme_version || 'main' }}" HT_VERSION=$(node -p "require('./package.json').version") echo "HELLO_PLUS_VERSION=${HELLO_PLUS_VERSION}" >> $GITHUB_ENV + echo "HELLO_THEME_SOURCE=${HELLO_THEME_SOURCE}" >> $GITHUB_ENV echo "HELLO_THEME_VERSION=${HT_VERSION}" >> $GITHUB_ENV echo "hello-theme-version=${HT_VERSION}" >> $GITHUB_OUTPUT echo "hello-plus-version=${HELLO_PLUS_VERSION}" >> $GITHUB_OUTPUT - echo "hello-theme-input=${HELLO_THEME_INPUT}" >> $GITHUB_OUTPUT - echo "elementor-core-branch=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_OUTPUT + echo "hello-theme-input=${HELLO_THEME_SOURCE}" >> $GITHUB_OUTPUT - ARTIFACT_NAME="plus-ht${HELLO_THEME_INPUT}-hp${HELLO_PLUS_VERSION}-el${ELEMENTOR_CORE_BRANCH}-${{ github.run_id }}" + ARTIFACT_NAME="plus-ht${HELLO_THEME_SOURCE}-hp${HELLO_PLUS_VERSION}-${{ github.run_id }}" echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT - echo "Hello Theme version: ${HT_VERSION} (tests ref: ${HELLO_THEME_INPUT})" - echo "Hello Plus version: ${HELLO_PLUS_VERSION}" - echo "Elementor core branch: ${ELEMENTOR_CORE_BRANCH}" + - name: Preserve workflow infrastructure + run: cp -r .github .github-main-backup + + - name: Checkout specific Hello Theme version + run: | + if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then + bash .github/scripts/resolve-version-ref.sh checkout "$HELLO_THEME_SOURCE" --fetch + ACTUAL_VERSION=$(node -p "require('./package.json').version") + if [[ "$ACTUAL_VERSION" != "$HELLO_THEME_SOURCE" ]]; then + echo "ERROR: Version mismatch - Expected: $HELLO_THEME_SOURCE, Got: $ACTUAL_VERSION" + exit 1 + fi + fi + + - name: Restore main branch workflow infrastructure + run: | + if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then + rm -rf .github + mv .github-main-backup .github + else + rm -rf .github-main-backup + fi + echo "HELLO_THEME_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - name: Build Hello Theme uses: ./.github/workflows/build-theme with: - PACKAGE_VERSION: ${{ steps.set-versions.outputs.hello-theme-version }} + PACKAGE_VERSION: ${{ env.HELLO_THEME_VERSION }} BUILD_SCRIPT_PATH: "npm run build:prod" - name: Download Hello Plus run: | HELLO_PLUS_VERSION="${{ steps.set-versions.outputs.hello-plus-version }}" - echo "Downloading Hello Plus version: ${HELLO_PLUS_VERSION}" - mkdir -p ./tmp if [[ "$HELLO_PLUS_VERSION" == "latest-stable" ]]; then curl --location -o ./hello-plus.zip https://downloads.wordpress.org/plugin/hello-plus.latest-stable.zip - unzip -q ./hello-plus.zip - mv ./hello-plus ./tmp/hello-plus - echo "Hello Plus latest-stable downloaded and extracted" elif [[ "$HELLO_PLUS_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then curl --location -o ./hello-plus.zip "https://downloads.wordpress.org/plugin/hello-plus.${HELLO_PLUS_VERSION}.zip" - unzip -q ./hello-plus.zip - mv ./hello-plus ./tmp/hello-plus - echo "Hello Plus ${HELLO_PLUS_VERSION} downloaded and extracted" else echo "Unsupported Hello Plus version format: ${HELLO_PLUS_VERSION}" - echo "Supported formats: latest-stable, x.y.z (semantic version)" exit 1 fi + unzip -q ./hello-plus.zip + mv ./hello-plus ./tmp/hello-plus + - name: Download Elementor Core id: download-elementor - run: | - ELEMENTOR_CORE_BRANCH="${{ steps.set-versions.outputs.elementor-core-branch }}" - echo "Downloading Elementor Core: ${ELEMENTOR_CORE_BRANCH}" - - mkdir -p ./tmp - - if [[ "$ELEMENTOR_CORE_BRANCH" == "latest-stable" ]]; then - curl --location -o ./elementor-core.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "Elementor latest-stable downloaded and extracted" - echo "effective-version=latest-stable" >> $GITHUB_OUTPUT - elif [[ "$ELEMENTOR_CORE_BRANCH" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - curl --location -o ./elementor-core.zip "https://downloads.wordpress.org/plugin/elementor.${ELEMENTOR_CORE_BRANCH}.zip" - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "Elementor ${ELEMENTOR_CORE_BRANCH} downloaded and extracted" - echo "effective-version=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_OUTPUT - else - echo "GitHub artifacts for Elementor branches not implemented; using latest-stable" - curl --location -o ./elementor-core.zip https://downloads.wordpress.org/plugin/elementor.latest-stable.zip - unzip -q ./elementor-core.zip - mv ./elementor ./tmp/elementor - echo "effective-version=latest-stable" >> $GITHUB_OUTPUT - fi + env: + ELEMENTOR_CORE_BRANCH: main + run: bash .github/scripts/download-elementor-core.sh - name: Upload plus build artifacts uses: actions/upload-artifact@v4 @@ -157,14 +151,11 @@ jobs: - name: Generate build summary run: | echo "## Build Summary" >> $GITHUB_STEP_SUMMARY - echo "|-----------------|----------------------------|-----------------------|" >> $GITHUB_STEP_SUMMARY - echo "| Component | Version | Source |" >> $GITHUB_STEP_SUMMARY - echo "|-----------------|----------------------------|-----------------------|" >> $GITHUB_STEP_SUMMARY - echo "| Hello Theme | ${{ steps.set-versions.outputs.hello-theme-version }} (${{ steps.set-versions.outputs.hello-theme-input }}) | github (checkout ref) |" >> $GITHUB_STEP_SUMMARY - echo "| Hello Plus | ${{ steps.set-versions.outputs.hello-plus-version }} | WordPress.org |" >> $GITHUB_STEP_SUMMARY - echo "| Elementor Core | ${{ steps.download-elementor.outputs.effective-version }} | WordPress.org |" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Strategy:** Same Hello Theme build ref as Core matrix; WordPress.org for Hello Plus and Elementor" >> $GITHUB_STEP_SUMMARY + echo "| Component | Version | Source |" >> $GITHUB_STEP_SUMMARY + echo "|-----------|---------|--------|" >> $GITHUB_STEP_SUMMARY + echo "| Hello Theme | ${{ env.HELLO_THEME_VERSION }} (${{ env.HELLO_THEME_SOURCE }}) | GitHub |" >> $GITHUB_STEP_SUMMARY + echo "| Hello Plus | ${{ steps.set-versions.outputs.hello-plus-version }} | WordPress.org |" >> $GITHUB_STEP_SUMMARY + echo "| Elementor Core | ${{ steps.download-elementor.outputs.effective-version }} | GitHub Releases |" >> $GITHUB_STEP_SUMMARY plus-playwright-tests: name: Hello Theme + Hello Plus Tests @@ -182,81 +173,9 @@ jobs: with: fetch-depth: 0 - - name: Hybrid Test Setup - Extract tests from target version + - name: Extract tests from target version id: extract-version-tests - run: | - echo "HYBRID APPROACH: Always latest workflows + version-specific tests" - echo "Workflow infrastructure: main branch (latest build-wp-env.js, scripts, etc.)" - echo "Test content: ${{ inputs.hello_theme_version || 'main' }} (matches theme functionality)" - - # Determine the target version for test extraction - TARGET_VERSION="${{ inputs.hello_theme_version || 'main' }}" - - if [ "$TARGET_VERSION" = "main" ]; then - echo "Using main branch tests (already available)" - TEST_VERSION="main" - TEST_SOURCE_TYPE="main-branch" - TESTS_AVAILABLE="true" - else - echo "Extracting tests from version: $TARGET_VERSION" - - # Fetch all tags and branches - git fetch --all --tags - - # Check if target version exists and has tests - TESTS_AVAILABLE="false" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="version-specific" - - # Try different tag formats - for TAG_FORMAT in "v$TARGET_VERSION" "$TARGET_VERSION"; do - echo "Checking for tag: $TAG_FORMAT" - if git rev-parse --verify "$TAG_FORMAT" >/dev/null 2>&1; then - echo "Found tag: $TAG_FORMAT" - - # Check if this version has playwright tests - if git ls-tree -r "$TAG_FORMAT" | grep -q "tests/playwright/"; then - echo "Playwright tests found in $TAG_FORMAT" - - # Extract tests directory from target version - echo "Extracting tests directory from $TAG_FORMAT..." - rm -rf ./tests/playwright/ - git archive "$TAG_FORMAT" tests/playwright/ | tar -x - - if [ -d "./tests/playwright/" ]; then - echo "Successfully extracted tests from $TAG_FORMAT" - TESTS_AVAILABLE="true" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="extracted-from-$TAG_FORMAT" - break - else - echo "Failed to extract tests from $TAG_FORMAT" - fi - else - echo "No playwright tests found in $TAG_FORMAT" - fi - else - echo "Tag $TAG_FORMAT not found" - fi - done - - if [ "$TESTS_AVAILABLE" = "false" ]; then - echo "No compatible tests found for version $TARGET_VERSION" - echo "Will skip testing for this version (tests don't exist yet)" - TEST_VERSION="none" - TEST_SOURCE_TYPE="not-available" - fi - fi - - # Set outputs for workflow control - echo "test-version=$TEST_VERSION" >> $GITHUB_OUTPUT - echo "test-source-type=$TEST_SOURCE_TYPE" >> $GITHUB_OUTPUT - echo "tests-available=$TESTS_AVAILABLE" >> $GITHUB_OUTPUT - - echo "Hybrid setup complete:" - echo " Workflow infrastructure: main branch" - echo " Test content: $TEST_VERSION ($TEST_SOURCE_TYPE)" - echo " Tests available: $TESTS_AVAILABLE" + run: bash .github/scripts/resolve-version-ref.sh extract-playwright-tests "${{ inputs.hello_theme_version || 'main' }}" --fetch - name: Install Node.js 20.x uses: actions/setup-node@v4 @@ -265,7 +184,7 @@ jobs: cache: "npm" - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 with: php-version: "8.1" tools: composer @@ -385,81 +304,9 @@ jobs: with: fetch-depth: 0 - - name: Hybrid Test Setup - Extract tests from target version + - name: Extract tests from target version id: extract-version-tests - run: | - echo "HYBRID APPROACH: Always latest workflows + version-specific tests" - echo "Workflow infrastructure: main branch (latest build-wp-env.js, scripts, etc.)" - echo "Test content: ${{ inputs.hello_theme_version || 'main' }} (matches theme functionality)" - - # Determine the target version for test extraction - TARGET_VERSION="${{ inputs.hello_theme_version || 'main' }}" - - if [ "$TARGET_VERSION" = "main" ]; then - echo "Using main branch tests (already available)" - TEST_VERSION="main" - TEST_SOURCE_TYPE="main-branch" - TESTS_AVAILABLE="true" - else - echo "Extracting tests from version: $TARGET_VERSION" - - # Fetch all tags and branches - git fetch --all --tags - - # Check if target version exists and has tests - TESTS_AVAILABLE="false" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="version-specific" - - # Try different tag formats - for TAG_FORMAT in "v$TARGET_VERSION" "$TARGET_VERSION"; do - echo "Checking for tag: $TAG_FORMAT" - if git rev-parse --verify "$TAG_FORMAT" >/dev/null 2>&1; then - echo "Found tag: $TAG_FORMAT" - - # Check if this version has playwright tests - if git ls-tree -r "$TAG_FORMAT" | grep -q "tests/playwright/"; then - echo "Playwright tests found in $TAG_FORMAT" - - # Extract tests directory from target version - echo "Extracting tests directory from $TAG_FORMAT..." - rm -rf ./tests/playwright/ - git archive "$TAG_FORMAT" tests/playwright/ | tar -x - - if [ -d "./tests/playwright/" ]; then - echo "Successfully extracted tests from $TAG_FORMAT" - TESTS_AVAILABLE="true" - TEST_VERSION="$TARGET_VERSION" - TEST_SOURCE_TYPE="extracted-from-$TAG_FORMAT" - break - else - echo "Failed to extract tests from $TAG_FORMAT" - fi - else - echo "No playwright tests found in $TAG_FORMAT" - fi - else - echo "Tag $TAG_FORMAT not found" - fi - done - - if [ "$TESTS_AVAILABLE" = "false" ]; then - echo "No compatible tests found for version $TARGET_VERSION" - echo "Will skip testing for this version (tests don't exist yet)" - TEST_VERSION="none" - TEST_SOURCE_TYPE="not-available" - fi - fi - - # Set outputs for workflow control - echo "test-version=$TEST_VERSION" >> $GITHUB_OUTPUT - echo "test-source-type=$TEST_SOURCE_TYPE" >> $GITHUB_OUTPUT - echo "tests-available=$TESTS_AVAILABLE" >> $GITHUB_OUTPUT - - echo "Hybrid setup complete:" - echo " Workflow infrastructure: main branch" - echo " Test content: $TEST_VERSION ($TEST_SOURCE_TYPE)" - echo " Tests available: $TESTS_AVAILABLE" + run: bash .github/scripts/resolve-version-ref.sh extract-playwright-tests "${{ inputs.hello_theme_version || 'main' }}" --fetch - name: Install Node.js 20.x uses: actions/setup-node@v4 @@ -468,7 +315,7 @@ jobs: cache: "npm" - name: Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@9882bed06691b3a085010c1602ce43ef18f15c5b # v2 with: php-version: "8.1" tools: composer