Skip to content

Commit 7618a3a

Browse files
committed
Merge branch 'main' into copilot/enable-xdebug-in-behat-tests-again
2 parents 21b82d3 + cd47ff8 commit 7618a3a

25 files changed

+1444
-215
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Check Branch Alias
2+
3+
on:
4+
release:
5+
types: [released]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
check-branch-alias:
14+
uses: wp-cli/.github/.github/workflows/reusable-check-branch-alias.yml@main
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
21+
22+
- name: Check existence of composer.json file
23+
id: check_composer_file
24+
run: echo "files_exists=$(test -f composer.json && echo true || echo false)" >> "$GITHUB_OUTPUT"
25+
26+
- name: Set up PHP environment
27+
if: steps.check_composer_file.outputs.files_exists == 'true'
28+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
29+
with:
30+
php-version: 'latest'
31+
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
32+
coverage: 'none'
33+
tools: composer,cs2pr
34+
env:
35+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Install Composer dependencies & cache dependencies
38+
if: steps.check_composer_file.outputs.files_exists == 'true'
39+
uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3
40+
env:
41+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
42+
with:
43+
# Bust the cache at least once a month - output format: YYYY-MM.
44+
custom-cache-suffix: $(date -u "+%Y-%m")

.github/workflows/issue-triage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Issue and PR Triage
3+
4+
'on':
5+
issues:
6+
types: [opened]
7+
pull_request_target:
8+
types: [opened]
9+
workflow_dispatch:
10+
inputs:
11+
issue_number:
12+
description: 'Issue/PR number to triage (leave empty to process all)'
13+
required: false
14+
type: string
15+
16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
23+
jobs:
24+
issue-triage:
25+
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main
26+
with:
27+
issue_number: >-
28+
${{
29+
(github.event_name == 'workflow_dispatch' && inputs.issue_number) ||
30+
(github.event_name == 'pull_request_target' && github.event.pull_request.number) ||
31+
(github.event_name == 'issues' && github.event.issue.number) ||
32+
''
33+
}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Manage Labels
3+
4+
'on':
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
- master
10+
paths:
11+
- 'composer.json'
12+
13+
permissions:
14+
issues: write
15+
contents: read
16+
17+
jobs:
18+
manage-labels:
19+
uses: wp-cli/.github/.github/workflows/reusable-manage-labels.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Welcome New Contributors
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
branches:
7+
- main
8+
- master
9+
10+
permissions:
11+
pull-requests: write
12+
13+
jobs:
14+
welcome:
15+
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

.typos.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
"(#|//)\\s*spellchecker:ignore-next-line\\n.*"
6+
]

bin/install-package-tests

Lines changed: 48 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ is_numeric() {
1515
*) return 0;; # returns 0 if numeric
1616
esac
1717
}
18-
# Promt color vars.
18+
# Prompt color vars.
1919
C_RED="\033[31m"
2020
C_BLUE="\033[34m"
2121
NO_FORMAT="\033[0m"
@@ -87,14 +87,16 @@ fi
8787

8888
echo "Detecting database version..."
8989

90-
TYPE="MySQL"
91-
CLIENT_VERSION=$(mysql --version 2>/dev/null)
92-
93-
case "${CLIENT_VERSION}" in
94-
*"MariaDB"*)
95-
TYPE="MariaDB"
96-
;;
97-
esac
90+
# Detect which client binary is available.
91+
CLIENT_BINARY=""
92+
if command -v mysql >/dev/null 2>&1; then
93+
CLIENT_BINARY="mysql"
94+
elif command -v mariadb >/dev/null 2>&1; then
95+
CLIENT_BINARY="mariadb"
96+
else
97+
echo "${C_RED}Error: Neither 'mysql' nor 'mariadb' client binary found.${NO_FORMAT}"
98+
exit 1
99+
fi
98100

99101
if [ -z "$PS1" ]; then
100102
# These vars are because github actions gave problems in the past.
@@ -105,11 +107,16 @@ else
105107
MYSQL_WAIT=0
106108
fi
107109

108-
if [ "${TYPE}" = "MySQL" ]; then
109-
SERVER_VERSION=$(mysql -e "SELECT VERSION()" --skip-column-names ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}")
110-
else
111-
SERVER_VERSION=$(mariadb -e "SELECT VERSION()" --skip-column-names ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}")
112-
fi
110+
# Use the detected client binary to query the server version.
111+
SERVER_VERSION=$(${CLIENT_BINARY} -e "SELECT VERSION()" --skip-column-names ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}" 2>/dev/null)
112+
113+
# Detect the database type from the server version string.
114+
TYPE="MySQL"
115+
case "${SERVER_VERSION}" in
116+
*"MariaDB"*|*"mariadb"*)
117+
TYPE="MariaDB"
118+
;;
119+
esac
113120

114121
VERSION=$(echo "${SERVER_VERSION}" | grep -o '^[^-]*')
115122
MAJOR=$(echo "${VERSION}" | cut -d. -f1)
@@ -119,66 +126,49 @@ echo "Detected ${TYPE} at version ${MAJOR}.${MINOR}"
119126

120127
echo 'Checking if database is ready...'
121128

122-
if [ "${TYPE}" = "MySQL" ]; then
123-
while ! mysql ${HOST_STRING} --user="${USER}" "${PASSWORD_STRING}" --execute="SHOW DATABASES;" | grep 'information_schema' >/dev/null;
124-
do
125-
i=$((i+1))
126-
if [ "${MYSQL_TRIES}" -gt 1 ]; then
127-
echo "Waiting for MySQL(${i}/${MYSQL_TRIES})..."
128-
sleep ${MYSQL_WAIT}
129-
fi
130-
131-
if [ $i -ge $MYSQL_TRIES ]; then
132-
echo "${C_RED}MySQL failed to start. Aborting.${NO_FORMAT}"
133-
echo "Cannot connect to MySQL server. For all available variables, check the documentation at:"
134-
echo " ${C_BLUE}https://github.com/wp-cli/wp-cli-tests?tab=readme-ov-file#the-database-credentials${NO_FORMAT}"
135-
exit 1
136-
fi
137-
done
138-
else
139-
while ! mariadb ${HOST_STRING} --user="${USER}" "${PASSWORD_STRING}" --execute="SHOW DATABASES;" | grep 'information_schema' >/dev/null;
140-
do
141-
i=$((i+1))
142-
if [ "${MYSQL_TRIES}" -gt 1 ]; then
143-
echo "Waiting for MariaDB(${i}/${MYSQL_TRIES})..."
144-
sleep ${MYSQL_WAIT}
145-
fi
129+
i=0
130+
while ! ${CLIENT_BINARY} ${HOST_STRING} --user="${USER}" "${PASSWORD_STRING}" --execute="SHOW DATABASES;" 2>/dev/null | grep 'information_schema' >/dev/null;
131+
do
132+
i=$((i+1))
133+
if [ "${MYSQL_TRIES}" -gt 1 ]; then
134+
echo "Waiting for database server (${i}/${MYSQL_TRIES})..."
135+
sleep ${MYSQL_WAIT}
136+
fi
146137

147-
if [ $i -ge $MYSQL_TRIES ]; then
148-
echo "${C_RED}MariaDB failed to start. Aborting.${NO_FORMAT}"
149-
echo "Cannot connect to MariaDB server. For all available variables, check the documentation at:"
150-
echo " ${C_BLUE}https://github.com/wp-cli/wp-cli-tests?tab=readme-ov-file#the-database-credentials${NO_FORMAT}"
151-
exit 1
152-
fi
153-
done
154-
fi
138+
if [ $i -ge $MYSQL_TRIES ]; then
139+
echo "${C_RED}Database server failed to start. Aborting.${NO_FORMAT}"
140+
echo "Cannot connect to database server. For all available variables, check the documentation at:"
141+
echo " ${C_BLUE}https://github.com/wp-cli/wp-cli-tests?tab=readme-ov-file#the-database-credentials${NO_FORMAT}"
142+
exit 1
143+
fi
144+
done
155145

156146
# Prepare the database for running the tests with a MySQL version 8.0 or higher.
157147
install_mysql_db_8_0_plus() {
158148
set -ex # print all the commands.
159-
mysql -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
160-
mysql -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED WITH caching_sha2_password BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
161-
mysql -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
162-
mysql -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
149+
${CLIENT_BINARY} -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
150+
${CLIENT_BINARY} -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED WITH caching_sha2_password BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
151+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
152+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
163153
{ set +ex; } 2> /dev/null # stop printing the commands
164154
}
165155

166156
# Prepare the database for running the tests with a MySQL version lower than 8.0.
167157
install_mysql_db_lower_than_8_0() {
168158
set -ex # print all the commands.
169-
mysql -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
170-
mysql -e "GRANT ALL ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
171-
mysql -e "GRANT ALL ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
159+
${CLIENT_BINARY} -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
160+
${CLIENT_BINARY} -e "GRANT ALL ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
161+
${CLIENT_BINARY} -e "GRANT ALL ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
172162
{ set +ex; } 2> /dev/null # stop printing the commands
173163
}
174164

175165
# Prepare the database for running the tests with MariaDB
176166
install_mariadb() {
177167
set -ex
178-
mariadb -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
179-
mariadb -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
180-
mariadb -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
181-
mariadb -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
168+
${CLIENT_BINARY} -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
169+
${CLIENT_BINARY} -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED BY '${TEST_PASSWORD}'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
170+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
171+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'" ${HOST_STRING} -u"${USER}" "${PASSWORD_STRING}"
182172
}
183173

184174
if [ "${TYPE}" = "MariaDB" ]; then
@@ -189,5 +179,5 @@ else
189179
install_mysql_db_lower_than_8_0
190180
fi
191181

192-
echo "Succesfully prepared the database for running tests."
182+
echo "Successfully prepared the database for running tests."
193183
echo "This command does not have to be run again."

0 commit comments

Comments
 (0)