2024-05-13 12:58:26 +00:00
|
|
|
name: Blocks Playwright Tests
|
2024-03-07 19:32:58 +00:00
|
|
|
|
2023-12-15 17:34:29 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
paths:
|
2024-03-07 19:32:58 +00:00
|
|
|
- '.github/workflows/blocks-playwright.yml' # This file
|
2023-12-15 17:34:29 +00:00
|
|
|
- 'plugins/woocommerce-blocks/**'
|
|
|
|
- 'plugins/woocommerce/src/Blocks/**'
|
|
|
|
- 'plugins/woocommerce/templates/**'
|
|
|
|
- 'plugins/woocommerce/patterns/**'
|
2024-03-07 13:01:22 +00:00
|
|
|
# Allow manually triggering the workflow.
|
|
|
|
workflow_dispatch:
|
2024-06-05 14:19:28 +00:00
|
|
|
# Run workflow when a PR is merged to trunk branch
|
|
|
|
# to create github issues for flaky tests.
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- trunk
|
|
|
|
paths:
|
|
|
|
- '.github/workflows/blocks-playwright.yml' # This file
|
|
|
|
- 'plugins/woocommerce-blocks/**'
|
|
|
|
- 'plugins/woocommerce/src/Blocks/**'
|
|
|
|
- 'plugins/woocommerce/templates/**'
|
|
|
|
- 'plugins/woocommerce/patterns/**'
|
2024-03-07 13:01:22 +00:00
|
|
|
|
2024-05-23 09:51:06 +00:00
|
|
|
concurrency:
|
|
|
|
group: '${{ github.workflow }}-${{ github.ref }}'
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-12-15 17:34:29 +00:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 1
|
|
|
|
|
|
|
|
jobs:
|
2024-05-13 12:58:26 +00:00
|
|
|
blocks-playwright-tests:
|
|
|
|
name: Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }}
|
2023-12-15 17:34:29 +00:00
|
|
|
timeout-minutes: 60
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: plugins/woocommerce-blocks
|
|
|
|
strategy:
|
2024-02-15 17:27:17 +00:00
|
|
|
fail-fast: false
|
2023-12-15 17:34:29 +00:00
|
|
|
matrix:
|
2024-05-13 12:58:26 +00:00
|
|
|
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
|
|
shardTotal: [10]
|
|
|
|
|
2023-12-15 17:34:29 +00:00
|
|
|
steps:
|
2024-05-13 12:58:26 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-12-15 17:34:29 +00:00
|
|
|
|
|
|
|
- name: Setup WooCommerce Monorepo
|
|
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
|
|
with:
|
|
|
|
install: '@woocommerce/plugin-woocommerce...'
|
|
|
|
build: '@woocommerce/plugin-woocommerce'
|
2024-07-04 04:55:24 +00:00
|
|
|
pull-playwright-cache: true
|
2024-07-10 12:39:49 +00:00
|
|
|
pull-package-deps: '@woocommerce/plugin-woocommerce'
|
2023-12-15 17:34:29 +00:00
|
|
|
|
2024-05-13 12:58:26 +00:00
|
|
|
- name: Install Playwright dependencies
|
|
|
|
run: pnpm exec playwright install chromium --with-deps
|
2023-12-15 17:34:29 +00:00
|
|
|
|
2024-05-13 12:58:26 +00:00
|
|
|
- name: Setup testing environment and start the server
|
|
|
|
run: pnpm env:start
|
2023-12-15 17:34:29 +00:00
|
|
|
|
|
|
|
- name: Run Playwright tests
|
2024-05-13 12:58:26 +00:00
|
|
|
run: pnpm test:e2e --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
|
|
|
|
|
|
|
- name: Archive debug artifacts (screenshots, traces)
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
if: ${{ !cancelled() }}
|
|
|
|
with:
|
|
|
|
name: failures-artifacts-shard-${{ matrix.shardIndex }}
|
|
|
|
path: plugins/woocommerce-blocks/tests/e2e/artifacts/test-results
|
|
|
|
if-no-files-found: ignore
|
2023-12-15 17:34:29 +00:00
|
|
|
|
2024-06-05 14:19:28 +00:00
|
|
|
- name: Archive flaky test reports
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
if: ${{ !cancelled() }}
|
|
|
|
with:
|
|
|
|
name: flaky-tests-report-shard-${{ matrix.shardIndex }}
|
|
|
|
path: plugins/woocommerce-blocks/flaky-tests
|
|
|
|
if-no-files-found: ignore
|
|
|
|
|
2024-05-13 12:58:26 +00:00
|
|
|
merge-artifacts:
|
|
|
|
# Merges all artifacts from all shards into a single zip and
|
|
|
|
# deletes the parts. In case of a rerun, artifacts from the
|
2024-06-05 14:19:28 +00:00
|
|
|
# previous run will be retained by merging them with the new ones.
|
2024-05-13 12:58:26 +00:00
|
|
|
name: Merge Artifacts
|
|
|
|
if: ${{ !cancelled() }}
|
|
|
|
needs: [blocks-playwright-tests]
|
|
|
|
runs-on: ubuntu-latest
|
2024-06-05 14:19:28 +00:00
|
|
|
outputs:
|
|
|
|
has-flaky-test-report: ${{ !!steps.merge-flaky-tests-reports.outputs.artifact-id }}
|
2024-05-13 12:58:26 +00:00
|
|
|
steps:
|
2024-06-05 14:19:28 +00:00
|
|
|
- name: Merge failures artifacts
|
2024-05-13 12:58:26 +00:00
|
|
|
uses: actions/upload-artifact/merge@v4
|
|
|
|
# Don't fail the job if there aren't any artifacts to merge.
|
|
|
|
continue-on-error: true
|
2023-12-15 17:34:29 +00:00
|
|
|
with:
|
2024-05-13 12:58:26 +00:00
|
|
|
name: failures-artifacts
|
2024-06-05 14:19:28 +00:00
|
|
|
pattern: failures-artifacts*
|
2024-05-13 12:58:26 +00:00
|
|
|
delete-merged: true
|
2024-06-05 14:19:28 +00:00
|
|
|
|
|
|
|
- name: Merge flaky tests reports
|
|
|
|
id: merge-flaky-tests-reports
|
|
|
|
uses: actions/upload-artifact/merge@v4
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
name: flaky-tests-report
|
|
|
|
pattern: flaky-tests-report*
|
|
|
|
delete-merged: true
|
|
|
|
|
|
|
|
create-github-issues-for-flaky-tests:
|
|
|
|
name: Create GitHub issues for flaky tests
|
|
|
|
needs: [merge-artifacts]
|
|
|
|
if: ${{ !cancelled() && needs.merge-artifacts.outputs.has-flaky-test-report == 'true' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
issues: write
|
|
|
|
steps:
|
|
|
|
# We are using @wordpress/report-flaky-tests package from Gutenberg repo
|
|
|
|
# to create GitHub issues for flaky tests.
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
repository: WordPress/gutenberg
|
|
|
|
# We are using commit hash to checkout the exact version of the script.
|
|
|
|
# This is to avoid any breaking changes.
|
|
|
|
ref: dbf201449e9736f672b61e422787d47659db327a
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: flaky-tests-report
|
|
|
|
path: flaky-tests
|
|
|
|
|
|
|
|
- name: Setup Node.js and install dependencies
|
|
|
|
uses: ./.github/setup-node
|
|
|
|
|
|
|
|
- name: Npm build
|
|
|
|
# TODO: We don't have to build the entire project, just the action itself.
|
|
|
|
run: npm run build:packages
|
|
|
|
|
|
|
|
- name: Report flaky tests
|
|
|
|
uses: ./packages/report-flaky-tests
|
|
|
|
with:
|
|
|
|
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
2024-06-06 15:21:23 +00:00
|
|
|
label: 'metric: flaky e2e test'
|
2024-06-05 14:19:28 +00:00
|
|
|
artifact-path: flaky-tests
|