Repository navigation
173 lines (146 loc) · 4.52 KB
/
Copy pathtests-e2e.yml
File metadata and controls
173 lines (146 loc) · 4.52 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: E2E Tests
on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
paths:
- '**/*.php'
- 'src/**'
- 'tests/playwright/**'
- 'tests/bin/initialize.sh'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- '.wp-env.test.json'
- '.github/workflows/tests-e2e.yml'
push:
branches:
- main
paths:
- '**/*.php'
- 'src/**'
- 'tests/playwright/**'
- 'tests/bin/initialize.sh'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- '.wp-env.test.json'
- '.github/workflows/tests-e2e.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
prepare:
name: Build assets and prepare Chromium
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Build plugin assets
run: npm run build
- name: Archive build assets
uses: actions/upload-artifact@v4
with:
name: dist-assets
path: build
- name: Cache Chromium
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}
- name: Install Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium
# Zip artifacts strip Unix execute bits; tar preserves them for Playwright binaries.
- name: Pack Chromium cache
run: tar -C "$HOME/.cache" -czf playwright-chromium.tar.gz ms-playwright
- name: Archive Chromium
uses: actions/upload-artifact@v4
with:
name: playwright-chromium
path: playwright-chromium.tar.gz
test-e2e:
name: E2E - WP ${{ matrix.core || 'latest' }} / PHP ${{ matrix.php }}
needs: prepare
runs-on: ubuntu-22.04
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- php: '8.1'
core: 'WordPress/WordPress#6.4'
# null = latest official WordPress release (wp-env default).
- php: '8.3'
core: null
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version-file: 'package.json'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Restore build assets
uses: actions/download-artifact@v4
with:
name: dist-assets
path: build
- name: Restore Chromium
uses: actions/download-artifact@v4
with:
name: playwright-chromium
path: .
- name: Unpack Chromium cache
run: |
mkdir -p "$HOME/.cache"
tar -C "$HOME/.cache" -xzf playwright-chromium.tar.gz
- name: Install Chromium operating-system dependencies
run: npx playwright install-deps chromium
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Launch test environment
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.core }}
run: npm run env:start-ci
- name: Run E2E tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
run: npm run test:e2e
- name: Sanitize Core version for artifact name
id: core-label
if: failure()
run: |
echo "core=${{ matrix.core || 'latest' }}" | tr '/\\#:*?"<>|' '-' >> "$GITHUB_OUTPUT"
- name: Archive failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-${{ steps.core-label.outputs.core }}-php-${{ matrix.php }}
path: artifacts/test-results
if-no-files-found: ignore
- name: Stop test environment
if: always()
continue-on-error: true
run: npm run env:stop-tests