ci: add wp-env Playwright E2E workflow #1
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: E2E (wp-env) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| suite: | |
| description: "Which tagged suite to run" | |
| type: choice | |
| default: both | |
| options: | |
| - both | |
| - lite | |
| - pro | |
| concurrency: | |
| group: e2e-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| e2e: | |
| name: Playwright @lite + @pro | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 40 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Detect Pro access | |
| id: pro_token | |
| env: | |
| PRO_REPO_TOKEN: ${{ secrets.PRO_REPO_TOKEN }} | |
| run: | | |
| if [ -n "$PRO_REPO_TOKEN" ]; then | |
| echo "enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "::notice::PRO_REPO_TOKEN not set — the @pro suite will be skipped." | |
| fi | |
| - name: Checkout tryaura-pro | |
| if: steps.pro_token.outputs.enabled == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: getdokan/tryaura-pro | |
| token: ${{ secrets.PRO_REPO_TOKEN }} | |
| path: .tryaura-pro-src | |
| - name: Setup PHP 8.2 | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| cache-dependency-path: | | |
| package-lock.json | |
| tests/pw/package-lock.json | |
| - name: Build plugin | |
| # Dev install on purpose: Mozart (post-install-cmd) only runs in dev | |
| # mode and generates lib/packages/, which the plugin loads at runtime. | |
| run: | | |
| composer install --no-interaction --no-progress | |
| npm ci | |
| npm run build | |
| - name: Prepare tryaura-pro mapping | |
| # .wp-env.json maps ../../../tryaura-pro — a sibling of the workspace. | |
| # Without Pro source, a stub keeps `wp-env start` from aborting; @lite | |
| # never activates it. | |
| env: | |
| HAS_PRO: ${{ steps.pro_token.outputs.enabled }} | |
| run: | | |
| PRO_DIR="$(dirname "$GITHUB_WORKSPACE")/tryaura-pro" | |
| rm -rf "$PRO_DIR" | |
| if [ "$HAS_PRO" = "true" ]; then | |
| mv "$GITHUB_WORKSPACE/.tryaura-pro-src" "$PRO_DIR" | |
| cd "$PRO_DIR" | |
| if [ -f composer.json ]; then | |
| composer install --no-interaction --no-progress | |
| fi | |
| if [ -f package-lock.json ]; then | |
| npm ci | |
| npm run build --if-present | |
| fi | |
| else | |
| mkdir -p "$PRO_DIR" | |
| cat > "$PRO_DIR/tryaura-pro.php" <<'PHP' | |
| <?php | |
| /** | |
| * Plugin Name: TryAura Pro (CI stub) | |
| * Description: Placeholder so the wp-env mapping resolves when Pro source is unavailable. | |
| */ | |
| PHP | |
| fi | |
| - name: Install E2E dependencies | |
| working-directory: tests/pw | |
| run: | | |
| npm ci | |
| npx playwright install --with-deps chromium | |
| - name: Start wp-env | |
| working-directory: tests/pw | |
| run: npx wp-env start | |
| - name: Run @lite specs | |
| if: ${{ !cancelled() && (github.event_name != 'workflow_dispatch' || inputs.suite != 'pro') }} | |
| working-directory: tests/pw | |
| env: | |
| WP_BASE_URL: http://localhost:8899 | |
| run: npm run test:lite -- --output=test-results/lite | |
| - name: Run @pro specs | |
| # Runs even if @lite failed, so one run reports both suites. | |
| if: ${{ !cancelled() && steps.pro_token.outputs.enabled == 'true' && (github.event_name != 'workflow_dispatch' || inputs.suite != 'lite') }} | |
| working-directory: tests/pw | |
| env: | |
| WP_BASE_URL: http://localhost:8899 | |
| run: npm run test:pro -- --output=test-results/pro | |
| - name: wp-env logs | |
| if: failure() | |
| working-directory: tests/pw | |
| run: npx wp-env logs tests --no-watch || true | |
| - name: Upload Playwright artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-artifacts | |
| path: | | |
| tests/pw/playwright-report | |
| tests/pw/test-results | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| - name: Stop wp-env | |
| if: always() | |
| working-directory: tests/pw | |
| run: npx wp-env stop || true |