Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks E2E: Create workflow template #45400

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/blocks-playwright-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Blocks Playwright Tests Template

on:
workflow_call:
inputs:
name:
required: true
type: string
config:
required: true
type: string
results-folder:
required: true
type: string
shard-index:
required: true
type: number
shard-total:
required: true
type: number

jobs:
e2e:
name: ${{ inputs.name }} [${{ inputs.shard-index }}/${{ inputs.shard-total }}]
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/woocommerce-blocks
steps:
- uses: actions/checkout@v3

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'

- name: Install Playwright
run: pnpm --filter='@woocommerce/block-library' exec playwright install --with-deps

- name: Start wp-env
run: pnpm --filter='@woocommerce/block-library' env:start

- name: Run Playwright tests
working-directory: plugins/woocommerce-blocks
run: pnpm playwright test --config=tests/e2e/${{ inputs.config }} --shard ${{ inputs.shard-index }}/${{ inputs.shard-total }}

- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: playwright-report-${{ inputs.results-folder }}
path: plugins/woocommerce-blocks/tests/e2e/artifacts/${{ inputs.results-folder }}
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
99 changes: 50 additions & 49 deletions .github/workflows/blocks-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,66 @@ on:
- 'plugins/woocommerce/src/Blocks/**'
- 'plugins/woocommerce/templates/**'
- 'plugins/woocommerce/patterns/**'

# Allow manually triggering the workflow.
workflow_dispatch:


env:
FORCE_COLOR: 1

jobs:
e2e:
name: ${{ matrix.config.name }} [${{ matrix.shards.name }}]
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/woocommerce-blocks
default-theme:
strategy:
fail-fast: false
matrix:
config:
- name: Default (Block) Theme
file: playwright.config.ts
resultPath: test-results
- name: Classic Theme
file: playwright.classic-theme.config.ts
resultPath: test-results-classic-theme
- name: Side Effects
file: playwright.side-effects.config.ts
resultPath: test-results-side-effects
- name: Block Theme With Templates
file: playwright.block-theme-with-templates.config.ts
resultPath: test-results-block-theme-with-templates
shards:
- name: 1/5
- name: 2/5
- name: 3/5
- name: 4/5
- name: 5/5
steps:
- uses: actions/checkout@v3

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'

- name: Install Playwright
run: pnpm --filter='@woocommerce/block-library' exec playwright install --with-deps
shard-index: [1, 2, 3, 4, 5]
shard-total: [5]
uses: ./.github/workflows/blocks-playwright-template.yml
with:
name: Default (Block) Theme
config: playwright.config.ts
results-folder: test-results
shard-index: ${{ matrix.shard-index }}
shard-total: ${{ matrix.shard-total }}

- name: Start wp-env
run: pnpm --filter='@woocommerce/block-library' env:start
classic-theme:
strategy:
fail-fast: false
matrix:
shard-index: [1, 2, 3, 4]
shard-total: [4]
uses: ./.github/workflows/blocks-playwright-template.yml
with:
name: Classic Theme
config: playwright.classic-theme.config.ts
results-folder: test-results-classic-theme
shard-index: ${{ matrix.shard-index }}
shard-total: ${{ matrix.shard-total }}

- name: Run Playwright tests
working-directory: plugins/woocommerce-blocks
run: pnpm playwright test --config=tests/e2e/${{ matrix.config.file }} --shard ${{ matrix.shards.name }}
side-effects:
strategy:
fail-fast: false
matrix:
shard-index: [1, 2, 3, 4, 5]
shard-total: [5]
uses: ./.github/workflows/blocks-playwright-template.yml
with:
name: Side Effects
config: playwright.side-effects.config.ts
results-folder: test-results-side-effects
shard-index: ${{ matrix.shard-index }}
shard-total: ${{ matrix.shard-total }}

- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: playwright-report-${{ matrix.config.name }}
path: plugins/woocommerce-blocks/tests/e2e/artifacts/${{ matrix.config.resultPath }}
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
block-theme-with-templates:
strategy:
fail-fast: false
matrix:
shard-index: [1]
shard-total: [1]
uses: ./.github/workflows/blocks-playwright-template.yml
with:
name: Block Theme With Templates
config: playwright.block-theme-with-templates.config.ts
results-folder: test-results-block-theme-with-templates
shard-index: ${{ matrix.shard-index }}
shard-total: ${{ matrix.shard-total }}