1
0
Fork 0
mirror of https://github.com/elementor/hello-theme.git synced 2026-07-27 14:01:37 +08:00
hello-theme/.github/workflows/playwright-with-specific-hello-plus-version.yml
2026-05-20 14:28:10 +02:00

578 lines
24 KiB
YAML

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
type: string
hello_theme_version:
description: "Hello Theme version to test (e.g., 3.4.4 or main)"
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
type: string
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
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
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 }}
elementor-version: ${{ steps.download-elementor.outputs.effective-version }}
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: |
HELLO_PLUS_VERSION="${{ inputs.hello_plus_version }}"
HELLO_THEME_INPUT="${{ inputs.hello_theme_version || 'main' }}"
ELEMENTOR_CORE_BRANCH="${{ inputs.elementor_core_branch || 'latest-stable' }}"
HT_VERSION=$(node -p "require('./package.json').version")
echo "HELLO_PLUS_VERSION=${HELLO_PLUS_VERSION}" >> $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
ARTIFACT_NAME="plus-ht${HELLO_THEME_INPUT}-hp${HELLO_PLUS_VERSION}-el${ELEMENTOR_CORE_BRANCH}-${{ 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: 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 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
- 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
- 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
./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 | ${{ 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
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 }}
ELEMENTOR_VERSION: ${{ needs.build-plus-components.outputs.elementor-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
uses: ./.github/actions/extract-hello-theme-zip
- 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: ${{ 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 (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 }}"
GREP_INVERT_FLAG='--grep-invert="should navigate to correct pages from Quick Links"'
echo "Skipping known failing test: 'should navigate to correct pages from Quick Links'"
eval npm run test:playwright -- tests/playwright/tests/ $GREP_INVERT_FLAG
- 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 }}
ELEMENTOR_VERSION: ${{ needs.build-plus-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-plus-components.outputs.artifact-name }}
path: ./
- name: Extract Hello Theme build
uses: ./.github/actions/extract-hello-theme-zip
- 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: ${{ 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: |
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