@@ -11,12 +11,7 @@ concurrency:
11
11
12
12
jobs :
13
13
14
- unit : # -----------------------------------------------------------------------
15
- name : Unit test / PHP ${{ matrix.php }}
16
- strategy :
17
- fail-fast : false
18
- matrix :
19
- php : ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
14
+ has_unit_tests :
20
15
runs-on : ubuntu-20.04
21
16
22
17
steps :
29
24
with :
30
25
files : " composer.json, phpunit.xml.dist"
31
26
27
+ outputs :
28
+ exists : ${{ steps.check_files.outputs.files_exists }}
29
+
30
+ unit :
31
+ name : Unit tests on PHP ${{ matrix.php }}
32
+ needs :
33
+ - has_unit_tests
34
+ if : ${{ needs.has_unit_tests.outputs.exists == 'true' }}
35
+ strategy :
36
+ fail-fast : false
37
+ matrix :
38
+ php : ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
39
+ runs-on : ubuntu-20.04
40
+
41
+ steps :
42
+ - name : Check out source code
43
+ uses : actions/checkout@v3
44
+
32
45
- name : Set up PHP environment (PHP 5.6 - 7.1)
33
- if : ${{ matrix.php < '7.2' && steps.check_files.outputs.files_exists == 'true' }}
46
+ if : ${{ matrix.php < '7.2' }}
34
47
uses : shivammathur/setup-php@v2
35
48
with :
36
49
php-version : ' ${{ matrix.php }}'
@@ -41,35 +54,52 @@ jobs:
41
54
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42
55
43
56
- name : Set up PHP environment (PHP 7.2+)
44
- if : ${{ matrix.php >= '7.2' && steps.check_files.outputs.files_exists == 'true'}}
57
+ if : ${{ matrix.php >= '7.2' }}
58
+ env :
59
+ COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
45
60
uses : shivammathur/setup-php@v2
46
61
with :
47
62
php-version : ' ${{ matrix.php }}'
48
63
coverage : none
49
64
tools : composer,cs2pr
50
- env :
51
- COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52
65
53
66
- name : Install Composer dependencies & cache dependencies
54
- if : steps.check_files.outputs.files_exists == 'true'
55
- uses : " ramsey/composer-install@v2"
56
67
env :
57
68
COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
69
+ uses : " ramsey/composer-install@v2"
58
70
with :
59
71
# Bust the cache at least once a month - output format: YYYY-MM.
60
- custom-cache-suffix : $(date -u "+%Y-%m")
72
+ custom-cache-suffix : |
73
+ $(date -u "+%Y-%m")
61
74
62
75
- name : Setup problem matcher to provide annotations for PHPUnit
63
- if : steps.check_files.outputs.files_exists == 'true'
64
76
run : echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
65
77
66
78
- name : Run PHPUnit
67
- if : steps.check_files.outputs.files_exists == 'true'
68
- continue-on-error : ${{ matrix.php == '8.2' }}
69
79
run : composer phpunit
80
+ continue-on-error : ${{ matrix.php == '8.2' }}
81
+
82
+ has_functional_tests :
83
+ runs-on : ubuntu-20.04
70
84
71
- functional : # ----------------------------------------------------------------------
85
+ steps :
86
+ - name : Check out source code
87
+ uses : actions/checkout@v3
88
+
89
+ - name : Check existence of composer.json & behat.yml files
90
+ id : check_files
91
+ uses : andstor/file-existence-action@v2
92
+ with :
93
+ files : " composer.json, behat.yml"
94
+
95
+ outputs :
96
+ exists : ${{ steps.check_files.outputs.files_exists }}
97
+
98
+ functional :
72
99
name : Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
100
+ needs :
101
+ - has_functional_tests
102
+ if : ${{ needs.has_functional_tests.outputs.exists == 'true' }}
73
103
strategy :
74
104
fail-fast : false
75
105
matrix :
@@ -114,55 +144,45 @@ jobs:
114
144
image : mysql:${{ matrix.mysql }}
115
145
ports :
116
146
- 3306
117
- options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -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"
147
+ options : |
148
+ --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -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"
118
149
119
150
steps :
120
151
- name : Check out source code
121
152
uses : actions/checkout@v3
122
153
123
- - name : Check existence of composer.json & behat.yml files
124
- id : check_files
125
- uses : andstor/file-existence-action@v2
126
- with :
127
- files : " composer.json, behat.yml"
128
-
129
154
- name : Install Ghostscript
130
- if : steps.check_files.outputs.files_exists == 'true'
131
155
run : |
132
156
sudo apt-get update
133
- sudo apt-get install ghostscript -y
157
+ sudo apt-get install -y ghostscript
134
158
135
159
- name : Set up PHP environment
136
- if : steps.check_files.outputs.files_exists == 'true'
160
+ env :
161
+ COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
137
162
uses : shivammathur/setup-php@v2
138
163
with :
139
164
php-version : ' ${{ matrix.php }}'
140
165
extensions : gd, imagick, mysql, zip
141
166
coverage : none
142
167
tools : composer
143
- env :
144
- COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145
168
146
169
- name : Change ImageMagick policy to allow pdf->png conversion.
147
- if : steps.check_files.outputs.files_exists == 'true'
148
170
run : |
149
171
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
150
172
151
173
- name : Install Composer dependencies & cache dependencies
152
- if : steps.check_files.outputs.files_exists == 'true'
153
- uses : " ramsey/composer-install@v2"
154
174
env :
155
175
COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
176
+ uses : " ramsey/composer-install@v2"
156
177
with :
157
178
# Bust the cache at least once a month - output format: YYYY-MM.
158
- custom-cache-suffix : $(date -u "+%Y-%m")
179
+ custom-cache-suffix : |
180
+ $(date -u "+%Y-%m")
159
181
160
182
- name : Start MySQL server
161
- if : steps.check_files.outputs.files_exists == 'true'
162
183
run : sudo systemctl start mysql
163
184
164
185
- name : Configure DB environment
165
- if : steps.check_files.outputs.files_exists == 'true'
166
186
run : |
167
187
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
168
188
echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
@@ -174,18 +194,15 @@ jobs:
174
194
echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
175
195
176
196
- name : Prepare test database
177
- if : steps.check_files.outputs.files_exists == 'true'
178
197
run : composer prepare-tests
179
198
180
199
- name : Check Behat environment
181
- if : steps.check_files.outputs.files_exists == 'true'
182
200
env :
183
201
WP_VERSION : ' ${{ matrix.wp }}'
184
202
run : WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
185
203
186
204
- name : Run Behat
187
- if : steps.check_files.outputs.files_exists == 'true'
188
- continue-on-error : ${{ matrix.php == '8.2' }}
189
205
env :
190
206
WP_VERSION : ' ${{ matrix.wp }}'
191
207
run : composer behat || composer behat-rerun
208
+ continue-on-error : ${{ matrix.php == '8.2' }}
0 commit comments