Playwright with Specific Hello Plus Version #330
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 Hello Plus Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| hello_plus_version: | |
| description: "Hello Plus version to test (e.g., 1.7.2 or latest-stable)" | |
| 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: | |
| hello_plus_version: | |
| description: "Hello Plus version to test (e.g., 1.7.2 or latest-stable)" | |
| 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 | |
| concurrency: | |
| group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('plus-{0}-{1}', github.run_id, github.event.inputs.hello_plus_version || github.ref) }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| permissions: | |
| contents: read | |
| actions: read | |
| jobs: | |
| build-plus-components: | |
| name: Build Plus Components (Hello Theme + Hello Plus) | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| hello-theme-version: ${{ steps.set-versions.outputs.hello-theme-version }} | |
| hello-plus-version: ${{ steps.set-versions.outputs.hello-plus-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 variables and Hello Plus version | |
| id: set-versions | |
| run: | | |
| # Set Hello Plus version from input (released versions only) | |
| HELLO_PLUS_VERSION="${{ inputs.hello_plus_version }}" | |
| # Hello Theme source ref (main or specific GA version) - always use main actions | |
| # Always use main actions regardless of source version - this is the key principle | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| HELLO_THEME_SOURCE="${{ inputs.hello_theme_version || 'main' }}" | |
| else | |
| HELLO_THEME_SOURCE="main" | |
| fi | |
| # Current Hello Theme version from package.json (actual version string) | |
| 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 | |
| # Create artifact name | |
| ARTIFACT_NAME="plus-ht${HELLO_THEME_SOURCE}-hp${HELLO_PLUS_VERSION}-$(date +%Y%m%d-%H%M)" | |
| echo "artifact-name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT | |
| echo "✅ Hello Theme version: ${HT_VERSION}" | |
| echo "✅ Hello Theme source: ${HELLO_THEME_SOURCE}" | |
| echo "✅ Hello Plus Version: ${HELLO_PLUS_VERSION}" | |
| - name: Validate and preserve workflow infrastructure | |
| run: | | |
| set -e # Exit on any error | |
| echo "🔍 DEBUG: Validating version $HELLO_THEME_SOURCE" | |
| # Validate version exists (if not main) | |
| if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then | |
| git fetch --all --tags | |
| if ! git rev-parse --verify "v$HELLO_THEME_SOURCE" >/dev/null 2>&1 && ! git rev-parse --verify "$HELLO_THEME_SOURCE" >/dev/null 2>&1; then | |
| echo "❌ ERROR: Version $HELLO_THEME_SOURCE not found" | |
| exit 1 | |
| fi | |
| echo "✅ Version $HELLO_THEME_SOURCE exists" | |
| fi | |
| # Preserve entire .github directory | |
| echo "📦 DEBUG: Preserving .github directory from main branch" | |
| if ! cp -r .github .github-main-backup; then | |
| echo "❌ ERROR: Failed to preserve .github directory" | |
| exit 1 | |
| fi | |
| echo "✅ .github directory preserved" | |
| - name: Checkout specific Hello Theme version | |
| run: | | |
| set -e # Exit on any error | |
| if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then | |
| echo "🔄 DEBUG: Checking out Hello Theme version: $HELLO_THEME_SOURCE" | |
| # Attempt checkout with proper error handling | |
| if git checkout "v$HELLO_THEME_SOURCE" 2>/dev/null || git checkout "$HELLO_THEME_SOURCE" 2>/dev/null; then | |
| echo "✅ Successfully checked out $HELLO_THEME_SOURCE" | |
| else | |
| echo "❌ ERROR: Failed to checkout $HELLO_THEME_SOURCE" | |
| exit 1 | |
| fi | |
| # Validate package.json version matches | |
| 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 | |
| echo "✅ Version validated: $ACTUAL_VERSION" | |
| echo "HELLO_THEME_SOURCE_TYPE=git-tag" >> $GITHUB_ENV | |
| else | |
| echo "✅ DEBUG: Using main branch" | |
| echo "HELLO_THEME_SOURCE_TYPE=git-branch" >> $GITHUB_ENV | |
| fi | |
| - name: Restore main branch workflow infrastructure | |
| run: | | |
| set -e # Exit on any error | |
| if [[ "$HELLO_THEME_SOURCE" != "main" ]]; then | |
| echo "🔄 DEBUG: Restoring .github directory from main branch" | |
| # Remove old .github and restore main version | |
| if ! rm -rf .github; then | |
| echo "❌ ERROR: Failed to remove old .github directory" | |
| exit 1 | |
| fi | |
| if ! mv .github-main-backup .github; then | |
| echo "❌ ERROR: Failed to restore .github directory" | |
| exit 1 | |
| fi | |
| echo "✅ Main branch actions restored" | |
| echo "🎯 DEBUG: Using $HELLO_THEME_SOURCE source code with main branch actions" | |
| else | |
| # Clean up backup if we didn't need it | |
| rm -rf .github-main-backup 2>/dev/null || true | |
| echo "✅ DEBUG: Using main branch (no restore needed)" | |
| fi | |
| # Set final version for build | |
| FINAL_VERSION=$(node -p "require('./package.json').version") | |
| echo "HELLO_THEME_VERSION=$FINAL_VERSION" >> $GITHUB_ENV | |
| echo "📋 DEBUG: Final state - Version: $FINAL_VERSION, Actions: main branch" | |
| - name: Build Hello Theme | |
| uses: ./.github/workflows/build-theme | |
| with: | |
| 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}" | |
| # Create Hello Plus build directory | |
| mkdir -p ./tmp | |
| if [[ "$HELLO_PLUS_VERSION" == "latest-stable" ]]; then | |
| # Download latest stable from WordPress.org | |
| 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 | |
| # Download specific version from WordPress.org | |
| 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 | |
| - name: Upload plus build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.set-versions.outputs.artifact-name }} | |
| path: | | |
| ./hello-elementor-*.zip | |
| ./tmp/hello-plus | |
| retention-days: 3 | |
| - name: Cleanup backup files | |
| if: always() | |
| run: | | |
| echo "🧹 DEBUG: Cleaning up backup files" | |
| rm -rf .github-main-backup 2>/dev/null || true | |
| echo "✅ Cleanup complete" | |
| - 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 "| Hello Plus | ${{ steps.set-versions.outputs.hello-plus-version }} | WordPress.org |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Strategy:** GitHub source for Hello Theme (always built), WordPress.org for Hello Plus" >> $GITHUB_STEP_SUMMARY | |
| plus-playwright-tests: | |
| name: Hello Theme + Hello Plus Tests | |
| needs: [build-plus-components] | |
| if: github.event.inputs.tag == '' | |
| env: | |
| HELLO_THEME_VERSION: ${{ needs.build-plus-components.outputs.hello-theme-version }} | |
| HELLO_PLUS_VERSION: ${{ needs.build-plus-components.outputs.hello-plus-version }} | |
| RUN_IDENTIFIER: plus-${{ 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: 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-plus-components.outputs.artifact-name }} | |
| path: ./ | |
| - 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 }} | |
| HELLO_PLUS_VERSION: ${{ env.HELLO_PLUS_VERSION }} | |
| ELEMENTOR_VERSION: "latest-stable" | |
| 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 (Plus Matrix) | |
| if: steps.extract-version-tests.outputs.tests-available == 'true' | |
| run: | | |
| export TEST_TITLE="Hello Theme Plus Test - HT ${HELLO_THEME_VERSION} + HP ${HELLO_PLUS_VERSION}" | |
| export DAILY_MATRIX_WORKFLOW=true | |
| echo "🧪 Running tests from: ${{ steps.extract-version-tests.outputs.test-source-type }}" | |
| # Only run Hello Theme tests, not Hello Plus 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 plus test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: plus-test-results-ht${{ env.HELLO_THEME_VERSION }}-hp${{ env.HELLO_PLUS_VERSION }} | |
| path: test-results/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Upload Plus Playwright HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: plus-playwright-report-ht${{ env.HELLO_THEME_VERSION }}-hp${{ env.HELLO_PLUS_VERSION }} | |
| path: playwright-report/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Stop wp-env | |
| if: always() | |
| run: npx wp-env stop || true | |
| plus-playwright-tagged-tests: | |
| name: Plus Tagged Tests | |
| needs: [build-plus-components] | |
| if: ${{ github.event.inputs.tag }} | |
| env: | |
| HELLO_THEME_VERSION: ${{ needs.build-plus-components.outputs.hello-theme-version }} | |
| HELLO_PLUS_VERSION: ${{ needs.build-plus-components.outputs.hello-plus-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-plus-components.outputs.artifact-name }} | |
| path: ./ | |
| - 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 }} | |
| HELLO_PLUS_VERSION: ${{ env.HELLO_PLUS_VERSION }} | |
| ELEMENTOR_VERSION: "latest-stable" | |
| 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: | | |
| 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 plus tagged test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: plus-tagged-test-results-ht${{ env.HELLO_THEME_VERSION }}-hp${{ env.HELLO_PLUS_VERSION }} | |
| path: test-results/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Upload Plus Tagged Playwright HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: plus-tagged-playwright-report-ht${{ env.HELLO_THEME_VERSION }}-hp${{ env.HELLO_PLUS_VERSION }} | |
| path: playwright-report/ | |
| if-no-files-found: ignore | |
| retention-days: 3 | |
| - name: Stop wp-env | |
| if: always() | |
| run: npx wp-env stop || true | |
| plus-matrix-results: | |
| needs: [plus-playwright-tests, plus-playwright-tagged-tests] | |
| if: needs.plus-playwright-tests.result != 'skipped' || needs.plus-playwright-tagged-tests.result != 'skipped' | |
| runs-on: ubuntu-22.04 | |
| name: Plus Matrix - Test Results | |
| steps: | |
| - name: Plus Matrix test status | |
| run: echo "Plus Matrix test status is - ${{ needs.plus-playwright-tests.result }}" | |
| - name: Check Plus Matrix status | |
| if: ${{ needs.plus-playwright-tests.result != 'success' && needs.plus-playwright-tests.result != 'skipped' }} | |
| run: exit 1 | |
| - name: Cleanup backup files (final) | |
| if: always() | |
| run: | | |
| echo "🧹 DEBUG: Final cleanup of any remaining backup files" | |
| rm -rf .github-main-backup 2>/dev/null || true | |
| echo "✅ Final cleanup complete" |