-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add CI workflow that runs only changed E2E tests, and succeeds when no tests have changed #10233
Changes from 11 commits
558878f
9dfce49
ebd587d
0cc8ed6
97561ba
260152b
1695058
14d2158
df3a74b
c49570e
55233bc
dff95dc
0f3ffae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'Run Changed Tests' | ||
description: 'Runs Playwright E2E Only Changed Tests' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: First Run Playwright E2E Tests (Only Changed) | ||
id: first_run_e2e_pw_tests_only_changed | ||
# Use +e to trap errors when running E2E tests. | ||
shell: /bin/bash +e {0} | ||
run: npm run test:e2e-pw-ci-only-changed | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 7 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: E2E Playwright Tests - Pull Request - Only Changed | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- trunk | ||
workflow_dispatch: | ||
workflow_call: | ||
inputs: | ||
wcpay-use-build-artifact: | ||
type: boolean | ||
required: false | ||
default: false | ||
repo-branch: | ||
type: string | ||
required: false | ||
description: 'Branch to be used for running tests' | ||
|
||
env: | ||
E2E_GH_TOKEN: ${{ secrets.E2E_GH_TOKEN }} | ||
WCP_DEV_TOOLS_REPO: ${{ secrets.WCP_DEV_TOOLS_REPO }} | ||
WCP_DEV_TOOLS_BRANCH: 'trunk' | ||
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }} | ||
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }} | ||
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }} | ||
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }} | ||
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }} | ||
WC_E2E_SCREENSHOTS: 1 | ||
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }} | ||
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }} | ||
E2E_USE_LOCAL_SERVER: false | ||
E2E_RESULT_FILEPATH: 'tests/e2e/results.json' | ||
WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }} | ||
WCPAY_ARTIFACT_DIRECTORY: 'zipfile' | ||
NODE_ENV: 'test' | ||
FORCE_E2E_DEPS_SETUP: true | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
wcpay-e2e-tests-only-changed: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.draft == true | ||
name: WC - latest | ||
|
||
env: | ||
E2E_WP_VERSION: 'latest' | ||
E2E_WC_VERSION: 'latest' | ||
|
||
steps: | ||
- name: Checkout WCPay repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.repo-branch || github.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: 'Download WooCommerce Payments build file' | ||
if: ${{ inputs.wcpay-use-build-artifact }} | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: woocommerce-payments | ||
path: ${{ env.WCPAY_ARTIFACT_DIRECTORY }} | ||
|
||
- name: Setup E2E environment | ||
uses: ./.github/actions/e2e/env-setup | ||
|
||
- name: Install Playwright | ||
shell: bash | ||
run: npx playwright install chromium | ||
|
||
- name: Run tests, upload screenshots & logs | ||
uses: ./.github/actions/e2e-pw/run-changed-tests |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ on: | |
- develop | ||
- trunk | ||
workflow_dispatch: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would happen if E2E tests are run as usual and then someone adds a new review? Would the tests trigger again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right, Edit: It ran again when I added an answer on the main thread :D Confirmed this. |
||
workflow_call: | ||
inputs: | ||
wcpay-use-build-artifact: | ||
|
@@ -43,7 +46,7 @@ concurrency: | |
jobs: | ||
wcpay-e2e-tests: | ||
runs-on: ubuntu-latest | ||
|
||
if: github.event.pull_request.draft == false | ||
name: WC - latest | ||
|
||
env: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Add workflow that only runs changed E2E tests, and succeeds if nothing changed |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
"test:e2e-pw-update-snapshots": "npm run test:e2e-pw -- --update-snapshots", | ||
"test:e2e-pw-ui": "./tests/e2e-pw/test-e2e-pw-ui.sh", | ||
"test:e2e-pw-ci": "npx playwright test --config=tests/e2e-pw/playwright.config.ts --grep-invert @todo", | ||
"test:e2e-pw-ci-only-changed": "npx playwright test --only-changed=origin/develop --pass-with-no-tests --config=tests/e2e-pw/playwright.config.ts --grep-invert @todo", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
"test:update-snapshots": "npm run test:js -- --updateSnapshot", | ||
"test:php": "./bin/run-tests.sh", | ||
"test:php-coverage": "./bin/check-test-coverage.sh", | ||
|
@@ -96,7 +97,7 @@ | |
"devDependencies": { | ||
"@automattic/color-studio": "2.3.1", | ||
"@jest/test-sequencer": "29.5.0", | ||
"@playwright/test": "1.43.1", | ||
"@playwright/test": "1.50.0", | ||
"@pmmmwh/react-refresh-webpack-plugin": "0.5.7", | ||
"@testing-library/jest-dom": "5.14.1", | ||
"@testing-library/react": "11.2.5", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
E2E tests - All
workflow runs tests against different versions of WP and WC (7.7.0, latest and beta, for example). Would we want to consider this in this workflow? There will be times when tests will pass against latest but fail against beta, like with the Coming Soon mode introduced in the latest WC release.