Skip to content

Commit cb89ead

Browse files
committed
ci: fix pipefail and unauthed mysqladmin in migration job
Two issues caught in review: 1. The pre-flight `count=$(ls ... | wc -l | ...)` runs under the GitHub Actions default `bash -eo pipefail`. When the glob matches zero files, ls exits non-zero and pipefail aborts the command substitution before the custom "no compiled migrations" message can print. Replaced with a bash array + `shopt -s nullglob`, which handles both missing-directory and no-matches identically (count=0) without invoking a pipeline. 2. `mysqladmin ping` without credentials returns exit 0 even when MySQL replies "Access denied" — so the wait loop terminated as soon as the TCP port opened, before the auth subsystem was ready, racing the migration step. Pass MYSQL_PWD via `docker compose exec -e` and `-uroot` to force a real authenticated ping; exit code is now non-zero until the server accepts our credentials.
1 parent d9c8f2f commit cb89ead

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ jobs:
170170
- name: Verify compiled migrations exist
171171
working-directory: apps/server-core
172172
run: |
173-
count=$(ls dist/adapters/database/migrations/${{ matrix.db }}/*.mjs 2>/dev/null | wc -l | tr -d ' ')
173+
shopt -s nullglob
174+
files=(dist/adapters/database/migrations/${{ matrix.db }}/*.mjs)
175+
count=${#files[@]}
174176
if [ "$count" = "0" ]; then
175177
echo "ERROR: no compiled migrations in dist/adapters/database/migrations/${{ matrix.db }}/"
176178
exit 1
@@ -184,7 +186,7 @@ jobs:
184186
- name: Wait for ${{ matrix.db }} to be ready
185187
run: |
186188
if [ "${{ matrix.db }}" = "mysql" ]; then
187-
timeout 120 bash -c 'until docker compose exec -T mysql mysqladmin ping -h127.0.0.1 --silent; do sleep 2; done'
189+
timeout 120 bash -c 'until docker compose exec -T -e MYSQL_PWD="$DB_PASSWORD" mysql mysqladmin ping -h127.0.0.1 -uroot --silent; do sleep 2; done'
188190
else
189191
timeout 60 bash -c 'until docker compose exec -T postgres pg_isready -U postgres; do sleep 2; done'
190192
fi

0 commit comments

Comments
 (0)