-
Notifications
You must be signed in to change notification settings - Fork 11
191 lines (161 loc) · 6.35 KB
/
Copy pathtests.yml
File metadata and controls
191 lines (161 loc) · 6.35 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Tests
on:
pull_request:
push:
branches:
- main
jobs:
unit-test:
name: "PHPStan + unit tests"
runs-on: ubuntu-latest
steps:
- name: "Checkout repo"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: "Install PHP"
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: "8.3"
tools: composer:v2
coverage: xdebug
- name: "Cache Composer downloads"
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress
- name: "Run PHPStan"
run: composer run phpstan
- name: "Run unit tests with coverage"
run: composer run test:unit:coverage
- name: "Send coverage to Coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
if: ${{ env.COVERALLS_REPO_TOKEN }}
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2
with:
github-token: ${{ env.COVERALLS_REPO_TOKEN }}
flag-name: "unit"
allow-empty: false
parallel: true
wp-test:
name: "WordPress tests with WP ${{ matrix.wp_version }}"
runs-on: ubuntu-latest
needs: unit-test
strategy:
matrix:
wp_version: ["6.5", "6.6", "6.7", "6.8", "6.9", "7.0", "latest"]
services:
mysql:
image: mysql:9.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
steps:
- name: "Checkout repo"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: "Install PHP"
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: "8.3"
tools: composer:v2
coverage: xdebug
- name: "Cache Composer downloads"
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-wp${{ matrix.wp_version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-wp${{ matrix.wp_version }}-
${{ runner.os }}-composer-
- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress
# WordPress tests works only with PHPUnit 9.x
# https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/
- name: "Install PHPUnit v9 and WordPress ${{ matrix.wp_version }}"
run: |
composer require --dev --update-with-all-dependencies 'phpunit/phpunit:^9.0' 'yoast/phpunit-polyfills:^3.0'
if [ "${{ matrix.wp_version }}" = "latest" ]; then
composer require --dev --update-with-all-dependencies 'wp-phpunit/wp-phpunit:*' 'roots/wordpress:*'
else
composer require --dev --update-with-all-dependencies 'wp-phpunit/wp-phpunit:${{ matrix.wp_version }}.*' 'roots/wordpress:${{ matrix.wp_version }}.*'
fi
- name: "Create test database"
run: mysql -uroot -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS wordpress_test;"
- name: "Run WordPress tests with coverage"
env:
DB_HOST: "127.0.0.1:3306"
DB_USER: "root"
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: "wordpress_test"
run: composer run test:wordPress:coverage
- name: "Send coverage to Coveralls"
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
if: ${{ env.COVERALLS_REPO_TOKEN }}
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2
with:
github-token: ${{ env.COVERALLS_REPO_TOKEN }}
flag-name: wp-test-$
allow-empty: false
parallel: true
wp-test-multisite:
name: "WordPress tests (multisite, WP latest)"
runs-on: ubuntu-latest
needs: unit-test
services:
mysql:
image: mysql:9.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
steps:
- name: "Checkout repo"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: "Install PHP"
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2
with:
php-version: "8.3"
tools: composer:v2
- name: "Cache Composer downloads"
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-wplatest-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-wplatest-
${{ runner.os }}-composer-
- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress
- name: "Install PHPUnit v9 and WordPress latest"
run: |
composer require --dev --update-with-all-dependencies 'phpunit/phpunit:^9.0' 'yoast/phpunit-polyfills:^3.0'
composer require --dev --update-with-all-dependencies 'wp-phpunit/wp-phpunit:*' 'roots/wordpress:*'
- name: "Create test database"
run: mysql -uroot -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS wordpress_test;"
- name: "Run WordPress tests in multisite mode"
env:
DB_HOST: "127.0.0.1:3306"
DB_USER: "root"
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: "wordpress_test"
WP_MULTISITE: "1"
run: composer run test:wordPress
finish:
needs:
- unit-test
- wp-test
- wp-test-multisite
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Close parallel build
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2
with:
parallel-finished: true
carryforward: "wp-test-1,wp-test-2,wp-test-3,wp-test-4,wp-test-5,wp-test-6,unit"