-
Notifications
You must be signed in to change notification settings - Fork 6
127 lines (108 loc) · 4.21 KB
/
Copy pathtests.yml
File metadata and controls
127 lines (108 loc) · 4.21 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
name: E2E Tests
on:
workflow_call:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare-matrix:
name: Prepare test matrix
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- name: Checkout plugin
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Build dynamic WordPress + PHP matrix
id: build-matrix
shell: bash
run: |
set -euo pipefail
matrix="$(python3 scripts/get-wordpress-matrix.py)"
echo "Using matrix: ${matrix}"
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
e2e:
needs: prepare-matrix
name: WP ${{ matrix.wp }} / PHP ${{ matrix.php }}
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }}
steps:
- name: Checkout plugin
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: lts/*
cache: "pnpm"
- name: Install pnpm dependencies
run: pnpm install
- name: Restore Playwright browsers cache
id: playwright-cache
uses: actions/cache/restore@v5
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Set WordPress and PHP version override
run: |
echo '{
"core": "https://wordpress.org/wordpress-${{ matrix.wp }}.zip",
"phpVersion": "${{ matrix.php }}"
}' > .wp-env.override.json
- name: Start wp-env
run: pnpm exec wp-env start
- name: Verify WordPress login page
run: |
for attempt in {1..10}; do
if curl -fsS http://localhost:8888/wp-login.php | grep -q 'id="user_login"'; then
exit 0
fi
sleep 3
done
curl -fsS http://localhost:8888/wp-login.php || true
exit 1
- name: Use Ubuntu archive mirror
run: |
if [ -f /etc/apt/apt-mirrors.txt ]; then
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://archive.ubuntu.com/ubuntu|g' /etc/apt/apt-mirrors.txt
fi
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
sudo sed -i 's|http://azure.archive.ubuntu.com/ubuntu|http://archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list.d/ubuntu.sources
fi
sudo apt-get update
- name: Install Playwright
timeout-minutes: 5
run: pnpm exec playwright install --with-deps chromium
- name: Save Playwright browsers cache
if: steps.playwright-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
continue-on-error: true
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
- name: Run Playwright tests
run: pnpm exec playwright test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-php${{ matrix.php }}-wp${{ matrix.wp }}
path: test-results
if-no-files-found: ignore
retention-days: 30