Skip to content

Commit 5b2dcbb

Browse files
authored
Start MySQL in the background while PHP is set up (#76)
1 parent 8d3ce7e commit 5b2dcbb

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

‎.github/workflows/reusable-testing.yml‎

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ jobs:
5959
id: check_files
6060
run: echo "files_exists=$([ -f composer.json ] && [ -f behat.yml ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
6161

62+
# Downloading and starting the database server is the slowest part of the
63+
# setup, and nothing needs it until the test database is prepared, so it
64+
# runs in the background alongside the PHP and Composer setup below. The
65+
# action only downloads its own binaries, so it cannot contend with apt.
66+
- name: Setup MySQL Server
67+
id: setup-mysql
68+
if: ${{ inputs.dbtype != 'sqlite' }}
69+
background: true
70+
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
71+
with:
72+
mysql-version: '8.0' # Standard MySQL version for these tests
73+
auto-start: true
74+
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
75+
user: ${{ env.WP_CLI_TEST_DBUSER}}
76+
password: ${{ env.WP_CLI_TEST_DBPASS}}
77+
my-cnf: |
78+
default_authentication_plugin=mysql_native_password
79+
6280
# Ghostscript ships with the GitHub hosted images, so the `apt-get update`
6381
# this used to run unconditionally cost every job ~25s for a package that
6482
# was already there. Keep the install as a fallback in case a future image
@@ -103,18 +121,10 @@ jobs:
103121
run: |
104122
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
105123
106-
- name: Setup MySQL Server
107-
id: setup-mysql
108-
if: ${{ inputs.dbtype != 'sqlite' }}
109-
uses: shogo82148/actions-setup-mysql@334a29f22d90428932f75b11e0d5fcc00bb6b4f4 # v1
110-
with:
111-
mysql-version: '8.0' # Standard MySQL version for these tests
112-
auto-start: true
113-
root-password: ${{ env.WP_CLI_TEST_DBROOTPASS }}
114-
user: ${{ env.WP_CLI_TEST_DBUSER}}
115-
password: ${{ env.WP_CLI_TEST_DBPASS}}
116-
my-cnf: |
117-
default_authentication_plugin=mysql_native_password
124+
# Waits for the database server started in the background above. `wait-all`
125+
# rather than `wait: setup-mysql`, as the step is skipped for SQLite legs.
126+
- name: Wait for the MySQL server
127+
wait-all:
118128

119129
- name: Prepare test database
120130
if: steps.check_files.outputs.files_exists == 'true' && inputs.dbtype != 'sqlite'

0 commit comments

Comments
 (0)