Skip to content

Stabilize database workflow by retrying SQL Server PDO readiness#5

Merged
Kowts merged 2 commits into
mainfrom
copilot/fix-database-github-actions-job
Jul 19, 2026
Merged

Stabilize database workflow by retrying SQL Server PDO readiness#5
Kowts merged 2 commits into
mainfrom
copilot/fix-database-github-actions-job

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

The database GitHub Actions job was failing in run 88133959937 during SQL Server preparation. The workflow treated an open TCP port as readiness, but SQL Server was not always ready for authenticated PDO connections yet.

  • Root cause

    • SQL Server startup race in CI: port 1433 becomes reachable before the server is ready to accept PDO login/query operations.
  • Workflow changes

    • In .github/workflows/ci.yml (database job, Aguardar e preparar SQL Server step):
      • Kept the existing TCP port wait.
      • Replaced single-shot PDO admin connect + DB creation with a bounded retry loop.
      • Added explicit terminal error when PDO readiness does not happen within retry budget.
  • Behavioral impact

    • Reduces flaky failures caused by transient SQL Server warm-up delays without changing test scope or DB semantics.
for attempt in {1..30}; do
  if php -r '$pdo = new PDO(getenv("SISP_TEST_SQLSRV_ADMIN_DSN"), getenv("SISP_TEST_SQLSRV_USER"), getenv("SISP_TEST_SQLSRV_PASSWORD")); if ((int) $pdo->query("SELECT DB_ID(NCHAR(115) + NCHAR(105) + NCHAR(115) + NCHAR(112))")->fetchColumn() === 0) { $pdo->exec("CREATE DATABASE [sisp]"); }'; then
    break
  fi
  if [ "$attempt" -eq 30 ]; then
    echo 'SQL Server abriu a porta 1433, mas não aceitou conexões PDO a tempo.' >&2
    exit 1
  fi
  sleep 2
done

Copilot AI changed the title [WIP] Fix failing GitHub Actions job database Stabilize database workflow by retrying SQL Server PDO readiness Jul 18, 2026
Copilot AI requested a review from Kowts July 18, 2026 23:50
Copilot finished work on behalf of Kowts July 18, 2026 23:50
@Kowts
Kowts marked this pull request as ready for review July 19, 2026 00:01
@Kowts
Kowts merged commit db076ce into main Jul 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants