forked from wp-cli/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (178 loc) · 6.31 KB
/
reusable-testing.yml
File metadata and controls
208 lines (178 loc) · 6.31 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Testing
on:
workflow_call:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
has_unit_tests:
runs-on: ubuntu-20.04
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Check existence of composer.json file
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "composer.json, phpunit.xml.dist"
outputs:
exists: ${{ steps.check_files.outputs.files_exists }}
unit:
name: Unit tests on PHP ${{ matrix.php }}
needs:
- has_unit_tests
if: ${{ needs.has_unit_tests.outputs.exists == 'true' }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
runs-on: ubuntu-20.04
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Set up PHP environment (PHP 5.6 - 7.1)
if: ${{ matrix.php < '7.2' }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
tools: composer:2.2,cs2pr
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up PHP environment (PHP 7.2+)
if: ${{ matrix.php >= '7.2' }}
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
tools: composer,cs2pr
- name: Install Composer dependencies & cache dependencies
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: |
$(date -u "+%Y-%m")
- name: Setup problem matcher to provide annotations for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPUnit
run: composer phpunit
continue-on-error: ${{ matrix.php == '8.2' }}
has_functional_tests:
runs-on: ubuntu-20.04
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Check existence of composer.json & behat.yml files
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "composer.json, behat.yml"
outputs:
exists: ${{ steps.check_files.outputs.files_exists }}
functional:
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
needs:
- has_functional_tests
if: ${{ needs.has_functional_tests.outputs.exists == 'true' }}
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
wp: ['latest']
mysql: ['8.0']
include:
- php: '5.6'
wp: 'trunk'
mysql: '8.0'
- php: '5.6'
wp: 'trunk'
mysql: '5.7'
- php: '5.6'
wp: 'trunk'
mysql: '5.6'
- php: '7.4'
wp: 'trunk'
mysql: '8.0'
- php: '8.0'
wp: 'trunk'
mysql: '8.0'
- php: '8.0'
wp: 'trunk'
mysql: '5.7'
- php: '8.0'
wp: 'trunk'
mysql: '5.6'
- php: '8.1'
wp: 'trunk'
mysql: '8.0'
- php: '8.2'
wp: 'trunk'
mysql: '8.0'
- php: '5.6'
wp: '3.7'
mysql: '5.6'
runs-on: ubuntu-20.04
services:
mysql:
image: mysql:${{ matrix.mysql }}
ports:
- 3306
options: |
--health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=10s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Install Ghostscript
run: |
sudo apt-get update
sudo apt-get install -y ghostscript
- name: Set up PHP environment
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: gd, imagick, mysql, zip
coverage: none
tools: composer
- name: Change ImageMagick policy to allow pdf->png conversion.
run: |
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
- name: Install Composer dependencies & cache dependencies
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: |
$(date -u "+%Y-%m")
- name: Start MySQL server
run: sudo systemctl start mysql
- name: Configure DB environment
run: |
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
- name: Prepare test database
run: composer prepare-tests
- name: Check Behat environment
env:
WP_VERSION: '${{ matrix.wp }}'
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
- name: Run Behat
env:
WP_VERSION: '${{ matrix.wp }}'
run: composer behat || composer behat-rerun
continue-on-error: ${{ matrix.php == '8.2' }}