Playwright with Specific Elementor Version #332
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright with Specific Elementor Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| core_branch: | |
| description: "Elementor Core Branch" | |
| required: true | |
| hello_theme_version: | |
| description: "Hello Theme version to test (e.g., 3.4.4 or main)" | |
| required: false | |
| default: "main" | |
| tag: | |
| description: "Provide @tag or a keyword" | |
| required: false | |
| workflow_call: | |
| inputs: | |
| core_branch: | |
| description: "Elementor Core Branch" | |
| required: true | |
| type: string | |
| hello_theme_version: | |
| description: "Hello Theme version to test (e.g., 3.4.4 or main)" | |
| required: false | |
| type: string | |
| tag: | |
| description: "Provide @tag or a keyword" | |
| required: false | |
| type: string | |
| secrets: | |
| CLOUD_DEVOPS_TOKEN: | |
| required: true | |
| concurrency: | |
| group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('core-{0}-{1}', github.run_id, github.event.inputs.core_branch || github.ref) }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| actions: read | |
| id-token: write | |
| jobs: | |
| build-core-components: | |
| name: Build Core Components (Hello Theme + Elementor) | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| hello-theme-version: ${{ steps.set-versions.outputs.hello-theme-version }} | |
| elementor-core-branch: ${{ steps.set-versions.outputs.elementor-core-branch }} | |
| elementor-version: ${{ steps.set-versions.outputs.elementor-version }} | |
| hello-theme-source: ${{ steps.set-versions.outputs.hello-theme-source }} | |
| artifact-name: ${{ steps.set-versions.outputs.artifact-name }} | |
| steps: | |
| - name: Checkout Hello Theme | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set version outputs | |
| 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) | |
| 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 "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 "elementor-core-branch=${ELEMENTOR_CORE_BRANCH}" >> $GITHUB_OUTPUT | |
| echo "elementor-version=${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 }}" | |
| echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT | |
| echo "✅ Set versions: Hello Theme=${HT_VERSION} (${HELLO_THEME_INPUT}), Elementor=${ELEMENTOR_CORE_BRANCH}" | |
| - name: Build Hello Theme | |
| uses: ./.github/workflows/build-theme | |
| with: | |
| PACKAGE_VERSION: ${{ steps.set-versions.outputs.hello-theme-version }} | |
| BUILD_SCRIPT_PATH: "npm run build:prod" | |
| - name: Download Elementor Core | |
| 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" | |
| 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" | |
| 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}" | |
| fi | |
| - name: Upload core build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.set-versions.outputs.artifact-name }} | |
| path: | | |
| ./hello-elementor-*.zip | |
| ./tmp/elementor | |
| retention-days: 3 | |
| - 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.set-versions.outputs.elementor-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 | |
| core-playwright-tests: | |
| name: Hello Theme + Elementor Tests | |
| needs: [build-core-components] | |
| if: github.event.inputs.tag == '' | |
| env: | |
| HELLO_THEME_VERSION: ${{ needs.build-core-components.outputs.hello-theme-version }} | |
| ELEMENTOR_VERSION: ${{ needs.build-core-components.outputs.elementor-version }} | |
| RUN_IDENTIFIER: core-${{ github.event.inputs.hello_theme_version || github.ref }}-${{ github.run_id }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout Hello Theme | |
| uses: actions/checkout@v4 | |
| 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 | |
| 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" | |
| - 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@v2 | |
| with: | |
| php-version: "8.1" | |
| tools: composer | |
| coverage: none | |
| - name: Install Dependencies | |
| run: | | |
| export PUPPETEER_SKIP_DOWNLOAD=true | |
| export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | |
| npm ci --prefer-offline --no-audit --no-fund --silent | |
| composer install --no-dev --no-scripts --optimize-autoloader --quiet | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| 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: Extract Hello Theme build | |
| run: | | |
| echo "Extracting Hello Theme build..." | |
| HT_ZIP=$(find . -name "hello-elementor-*.zip" -type f | head -1) | |
| if [ -n "$HT_ZIP" ]; then | |
| echo "Found Hello Theme build: $HT_ZIP" | |
| mkdir -p ./tmp | |
| unzip -q "$HT_ZIP" -d ./tmp/ | |
| if [ -d "./tmp/hello-elementor" ]; then | |
| echo "✅ Hello Theme extracted to ./tmp/hello-elementor/" | |
| elif [ -d "./tmp" ] && [ "$(ls -A ./tmp/)" ]; then | |
| mkdir -p ./tmp/hello-elementor-temp | |
| mv ./tmp/* ./tmp/hello-elementor-temp/ 2>/dev/null || true | |
| mv ./tmp/hello-elementor-temp ./tmp/hello-elementor | |
| echo "✅ Hello Theme organized at ./tmp/hello-elementor/" | |
| else | |
| echo "❌ Theme content not found in expected location" | |
| exit 1 | |
| fi | |
| else | |
| echo "❌ No Hello Theme build ZIP found" | |
| echo "Available files:" | |
| ls -la ./ | |
| exit 1 | |
| fi | |
| - name: Update wp-env.json file | |
| env: | |
| PHP_VERSION: "8.1" | |
| WP_CORE_VERSION: "latest" | |
| HELLO_THEME_VERSION: ${{ env.HELLO_THEME_VERSION }} | |
| ELEMENTOR_VERSION: ${{ env.ELEMENTOR_VERSION }} | |
| run: node ./.github/scripts/build-wp-env.js | |
| - name: Install WordPress environment | |
| run: | | |
| echo "Starting WordPress environment with retry logic..." | |
| for i in {1..5}; do | |
| echo "Attempt $i/5: Starting wp-env..." | |
| if npx wp-env start; then | |
| echo "✅ WordPress environment started successfully" | |
| break | |
| else | |
| echo "❌ Attempt $i failed" | |
| if [ $i -eq 5 ]; then | |
| echo "🚨 All attempts failed, exiting..." | |
| exit 1 | |
| else | |
| echo "⏳ Waiting 30 seconds before retry..." | |
| npx wp-env stop || true | |
| sleep 30 | |
| fi | |
| fi | |
| done | |
| - name: Setup WordPress environment (activate plugins and themes) | |
| run: | | |
| npx wp-env run cli bash hello-elementor-config/setup.sh | |
| npx wp-env run tests-cli bash hello-elementor-config/setup.sh | |
| - name: WordPress and plugin information | |
| run: | | |
| npx wp-env run cli wp --info | |
| - name: Install Playwright | |
| run: npx playwright install chromium | |
| - name: Run Hello Theme tests only (Core Matrix) | |
| if: steps.extract-version-tests.outputs.tests-available == 'true' | |
| run: | | |
| export TEST_TITLE="Hello Theme Core Test - HT ${HELLO_THEME_VERSION} + EL ${ELEMENTOR_VERSION}" | |
| export DAILY_MATRIX_WORKFLOW=true | |
| echo "🧪 Running tests from: ${{ steps.extract-version-tests.outputs.test-source-type }}" | |
| # Only run Hello Theme tests, not Elementor or other plugin tests | |
| npm run test:playwright -- tests/playwright/tests/ | |
| - name: Skip tests - version incompatible | |
| if: steps.extract-version-tests.outputs.tests-available != 'true' | |
| run: | | |
| echo "⏭️ Skipping tests for Hello Theme ${{ inputs.hello_theme_version || 'main' }}" | |
| echo "📋 Reason: ${{ steps.extract-version-tests.outputs.test-source-type }}" | |
| echo "✅ This is expected for older versions that predate Playwright testing" | |
| - name: Upload core test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: core-test-results-ht${{ env.HELLO_THEME_VERSION }}-el${{ env.ELEMENTOR_VERSION }} | |
| path: test-results/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Upload Core Playwright HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: core-playwright-report-ht${{ env.HELLO_THEME_VERSION }}-el${{ env.ELEMENTOR_VERSION }} | |
| path: playwright-report/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Stop wp-env | |
| if: always() | |
| run: npx wp-env stop || true | |
| core-playwright-tagged-tests: | |
| name: Core Tagged Tests | |
| needs: [build-core-components] | |
| if: ${{ github.event.inputs.tag }} | |
| env: | |
| HELLO_THEME_VERSION: ${{ needs.build-core-components.outputs.hello-theme-version }} | |
| ELEMENTOR_VERSION: ${{ needs.build-core-components.outputs.elementor-version }} | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout Hello Theme | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Hybrid Test Setup - 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" | |
| - 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@v2 | |
| with: | |
| php-version: "8.1" | |
| tools: composer | |
| coverage: none | |
| - name: Install Dependencies | |
| run: | | |
| export PUPPETEER_SKIP_DOWNLOAD=true | |
| export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | |
| npm ci --prefer-offline --no-audit --no-fund --silent | |
| composer install --no-dev --no-scripts --optimize-autoloader --quiet | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| 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: Extract Hello Theme build | |
| run: | | |
| echo "Extracting Hello Theme build..." | |
| HT_ZIP=$(find . -name "hello-elementor-*.zip" -type f | head -1) | |
| if [ -n "$HT_ZIP" ]; then | |
| echo "Found Hello Theme build: $HT_ZIP" | |
| mkdir -p ./tmp | |
| unzip -q "$HT_ZIP" -d ./tmp/ | |
| if [ -d "./tmp/hello-elementor" ]; then | |
| echo "✅ Hello Theme extracted to ./tmp/hello-elementor/" | |
| elif [ -d "./tmp" ] && [ "$(ls -A ./tmp/)" ]; then | |
| mkdir -p ./tmp/hello-elementor-temp | |
| mv ./tmp/* ./tmp/hello-elementor-temp/ 2>/dev/null || true | |
| mv ./tmp/hello-elementor-temp ./tmp/hello-elementor | |
| echo "✅ Hello Theme organized at ./tmp/hello-elementor/" | |
| else | |
| echo "❌ Theme content not found in expected location" | |
| exit 1 | |
| fi | |
| else | |
| echo "❌ No Hello Theme build ZIP found" | |
| echo "Available files:" | |
| ls -la ./ | |
| exit 1 | |
| fi | |
| - name: Update wp-env.json file | |
| env: | |
| PHP_VERSION: "8.1" | |
| WP_CORE_VERSION: "latest" | |
| HELLO_THEME_VERSION: ${{ env.HELLO_THEME_VERSION }} | |
| ELEMENTOR_VERSION: ${{ env.ELEMENTOR_VERSION }} | |
| run: node ./.github/scripts/build-wp-env.js | |
| - name: Install WordPress environment | |
| run: | | |
| echo "Starting WordPress environment with retry logic..." | |
| for i in {1..5}; do | |
| echo "Attempt $i/5: Starting wp-env..." | |
| if npx wp-env start; then | |
| echo "✅ WordPress environment started successfully" | |
| break | |
| else | |
| echo "❌ Attempt $i failed" | |
| if [ $i -eq 5 ]; then | |
| echo "🚨 All attempts failed, exiting..." | |
| exit 1 | |
| else | |
| echo "⏳ Waiting 30 seconds before retry..." | |
| npx wp-env stop || true | |
| sleep 30 | |
| fi | |
| fi | |
| done | |
| - name: Setup WordPress environment (activate plugins and themes) | |
| run: | | |
| npx wp-env run cli bash hello-elementor-config/setup.sh | |
| npx wp-env run tests-cli bash hello-elementor-config/setup.sh | |
| - name: Install Playwright | |
| run: npx playwright install chromium | |
| - name: Run Hello Theme tagged tests only | |
| if: steps.extract-version-tests.outputs.tests-available == 'true' | |
| run: | | |
| export DAILY_MATRIX_WORKFLOW=true | |
| echo "🧪 Running tagged tests from: ${{ steps.extract-version-tests.outputs.test-source-type }}" | |
| # Only run Hello Theme tests with the specified tag | |
| npm run test:playwright -- tests/playwright/tests/ --grep="${{ github.event.inputs.tag }}" | |
| - name: Skip tagged tests - version incompatible | |
| if: steps.extract-version-tests.outputs.tests-available != 'true' | |
| run: | | |
| echo "⏭️ Skipping tagged tests for Hello Theme ${{ inputs.hello_theme_version || 'main' }}" | |
| echo "📋 Reason: ${{ steps.extract-version-tests.outputs.test-source-type }}" | |
| echo "✅ This is expected for older versions that predate Playwright testing" | |
| - name: Upload core tagged test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: core-tagged-test-results-ht${{ env.HELLO_THEME_VERSION }}-el${{ env.ELEMENTOR_VERSION }} | |
| path: test-results/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Upload Core Tagged Playwright HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: core-tagged-playwright-report-ht${{ env.HELLO_THEME_VERSION }}-el${{ env.ELEMENTOR_VERSION }} | |
| path: playwright-report/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Stop wp-env | |
| if: always() | |
| run: npx wp-env stop || true | |
| core-matrix-results: | |
| needs: [core-playwright-tests, core-playwright-tagged-tests] | |
| if: needs.core-playwright-tests.result != 'skipped' || needs.core-playwright-tagged-tests.result != 'skipped' | |
| runs-on: ubuntu-22.04 | |
| name: Core Matrix - Test Results | |
| steps: | |
| - name: Core Matrix test status | |
| run: echo "Core Matrix test status is - ${{ needs.core-playwright-tests.result }}" | |
| - name: Check Core Matrix status | |
| if: ${{ needs.core-playwright-tests.result != 'success' && needs.core-playwright-tests.result != 'skipped' }} | |
| run: exit 1 |