Skip to content

Commit 66d17e0

Browse files
Copilotswissspidy
andauthored
Add SQLite to test matrix (#54)
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com> Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
1 parent 79b8170 commit 66d17e0

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

.github/workflows/testing.yml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ on:
1313
jobs:
1414

1515
functional: #----------------------------------------------------------------------
16-
name: ${{ matrix.test-package }} (Phar ${{ matrix.use-phar }} / WP ${{ matrix.wp }} / PHP ${{ matrix.php }})
16+
name: ${{ matrix.test-package }} (Phar ${{ matrix.use-phar }} / WP ${{ matrix.wp }} / PHP ${{ matrix.php }} / ${{ matrix.dbtype == 'sqlite' && 'SQLite' || format('MySQL {0}', matrix.mysql) }})
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
php: ['7.2', '8.5']
2121
wp: ['latest']
2222
mysql: ['8.0']
23+
dbtype: ['mysql', 'sqlite']
2324
use-phar: [true]
2425
test-package:
2526
- wp-cli-bundle
@@ -221,12 +222,17 @@ jobs:
221222
test-package: widget-command
222223
runs-on: ubuntu-22.04
223224

224-
services:
225-
mysql:
226-
image: mysql:${{ matrix.mysql }}
227-
ports:
228-
- 3306
229-
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"
225+
continue-on-error: ${{ matrix.dbtype == 'sqlite' }}
226+
227+
env:
228+
MYSQL_HOST: 127.0.0.1
229+
MYSQL_TCP_PORT: 3306
230+
WP_CLI_TEST_DBROOTUSER: root
231+
WP_CLI_TEST_DBROOTPASS: root
232+
WP_CLI_TEST_DBNAME: wp_cli_test
233+
WP_CLI_TEST_DBUSER: wp_cli_test
234+
WP_CLI_TEST_DBPASS: password1
235+
WP_CLI_TEST_DBHOST: 127.0.0.1:3306
230236

231237
steps:
232238
- name: Check out source code
@@ -249,7 +255,7 @@ jobs:
249255
uses: shivammathur/setup-php@v2
250256
with:
251257
php-version: '${{ matrix.php }}'
252-
extensions: gd, imagick, mysql, zip
258+
extensions: gd, imagick, mysql, zip, pdo_sqlite
253259
coverage: none
254260
tools: composer
255261

@@ -272,26 +278,14 @@ jobs:
272278
with:
273279
mysql-version: ${{ matrix.mysql }}
274280
auto-start: true
275-
root-password: root
276-
user: wp_cli_test
277-
password: password1
281+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
282+
user: ${{ env.WP_CLI_TEST_DBUSER}}
283+
password: ${{ env.WP_CLI_TEST_DBPASS}}
278284
my-cnf: |
279285
default_authentication_plugin=mysql_native_password
280286
281-
- name: Configure DB environment
282-
if: ${{ matrix.dbtype != 'sqlite' }}
283-
run: |
284-
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
285-
echo "MYSQL_TCP_PORT=3306" >> $GITHUB_ENV
286-
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
287-
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
288-
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
289-
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
290-
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
291-
echo "WP_CLI_TEST_DBHOST=127.0.0.1:3306" >> $GITHUB_ENV
292-
293287
- name: Prepare test database
294-
if: steps.check_files.outputs.files_exists == 'true'
288+
if: steps.check_files.outputs.files_exists == 'true' && matrix.dbtype != 'sqlite'
295289
run: composer prepare-tests
296290

297291
- name: Conditionally use Phar instead of source
@@ -302,13 +296,15 @@ jobs:
302296
if: steps.check_files.outputs.files_exists == 'true'
303297
env:
304298
WP_VERSION: '${{ matrix.wp }}'
299+
WP_CLI_TEST_DBTYPE: ${{ matrix.dbtype }}
305300
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
306301
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
307302

308303
- name: Run Behat
309304
if: steps.check_files.outputs.files_exists == 'true'
310305
env:
311306
WP_VERSION: '${{ matrix.wp }}'
307+
WP_CLI_TEST_DBTYPE: ${{ matrix.dbtype }}
312308
TEST_PACKAGE: 'wp-cli/${{ matrix.test-package }}'
313309
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
314310
run: composer test

0 commit comments

Comments
 (0)