forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (122 loc) · 4.61 KB
/
reusable-end-to-end-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
##
# A reusable workflow that runs end-to-end tests.
#
# Branches 6.3 and earlier used Puppeteer instead of Playwright.
# Use https://github.com/WordPress/wordpress-develop/tree/6.3/.github/workflows/reusable-end-to-end-tests.yml instead.
##
name: End-to-end Tests
on:
workflow_call:
inputs:
LOCAL_SCRIPT_DEBUG:
description: 'Whether to enable script debugging.'
required: false
type: 'boolean'
default: false
php-version:
description: 'The PHP version to use.'
required: false
type: 'string'
default: 'latest'
install-gutenberg:
description: 'Whether to install the Gutenberg plugin.'
required: false
type: 'boolean'
default: true
gutenberg-version:
description: 'A specific version of Gutenberg to install.'
required: false
type: 'string'
env:
LOCAL_DIR: build
LOCAL_PHP: ${{ inputs.php-version }}${{ 'latest' != inputs.php-version && '-fpm' || '' }}
jobs:
# Runs the end-to-end test suite.
#
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
# - Install Playwright browsers.
# - Builds WordPress to run from the `build` directory.
# - Starts the WordPress Docker container.
# - Logs the running Docker containers.
# - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container).
# - Install WordPress within the Docker container.
# - Install Gutenberg.
# - Install additional languages.
# - Run the E2E tests.
# - Uploads screenshots and HTML snapshots as an artifact.
# - Ensures version-controlled files are not modified or deleted.
e2e-tests:
name: Run E2E tests
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
- name: Set up Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: '.nvmrc'
cache: npm
- name: Log debug information
run: |
npm --version
node --version
curl --version
git --version
locale -a
- name: Install npm Dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Build WordPress
run: npm run build
- name: Start Docker environment
run: |
npm run env:start
- name: Log running Docker containers
run: docker ps -a
- name: Docker debug information
run: |
docker -v
docker compose run --rm mysql mysql --version
docker compose run --rm php php --version
docker compose run --rm php php -m
docker compose run --rm php php -i
docker compose run --rm php locale -a
- name: Install WordPress
env:
LOCAL_SCRIPT_DEBUG: ${{ inputs.LOCAL_SCRIPT_DEBUG }}
run: npm run env:install
- name: Install Gutenberg
if: ${{ inputs.install-gutenberg }}
run: npm run env:cli -- plugin install gutenberg${{ inputs.gutenberg-version && format( ' --version={0}', inputs.gutenberg-version ) || '' }} --path=/var/www/${{ env.LOCAL_DIR }}
- name: Install additional languages
run: |
npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
- name: Run E2E tests
run: npm run test:e2e
- name: Archive debug artifacts (screenshots, HTML snapshots)
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: always()
with:
name: failures-artifacts${{ inputs.LOCAL_SCRIPT_DEBUG && '-SCRIPT_DEBUG' || '' }}-${{ github.run_id }}
path: artifacts
if-no-files-found: ignore
include-hidden-files: true
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code