From 4698abe3874722886adeaab8c8cb70014d319bbd Mon Sep 17 00:00:00 2001 From: Anthony Lukach Date: Mon, 14 Sep 2026 13:48:12 -0700 Subject: [PATCH] perf: stop reinstalling psql, which the runner image already has Both workflows ran `apt-get update && apt-get install -y postgresql-client` before touching the database. The ubuntu-24.04 runner image already ships PostgreSQL 16.15 -- only the service is disabled, so psql is on PATH already -- and the install cost about 9 seconds of index refresh for nothing. In the reset job that was most of the wall clock. Install only when psql is genuinely missing, rather than deleting the step, so this still works if a future image drops PostgreSQL. The fallback also gains --no-install-recommends. Verified both branches of the guard: with psql present it prints the version and exits 0; with it off PATH it takes the install path. Both workflows still parse and their shell is valid. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01P1CCcrx5fDKuAGsNh8DUFG --- .github/workflows/deploy.yml | 12 +++++++++--- .github/workflows/reset-data.yml | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f40b51b..b958e32 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -101,9 +101,15 @@ jobs: echo "✓ Database credentials fetched successfully" - # Install PostgreSQL client - sudo apt-get update - sudo apt-get install -y postgresql-client + # The runner image already ships PostgreSQL (only the service is disabled), so + # psql is normally on PATH. Install only if that stops being true. + if command -v psql > /dev/null; then + psql --version + else + echo "psql not on the runner image; installing" + sudo apt-get update + sudo apt-get install -y --no-install-recommends postgresql-client + fi echo 'loading North American ecoregions into database' psql -c "CREATE SCHEMA IF NOT EXISTS features; DROP TABLE IF EXISTS features.ecoregions;" diff --git a/.github/workflows/reset-data.yml b/.github/workflows/reset-data.yml index 985aefc..56dafa8 100644 --- a/.github/workflows/reset-data.yml +++ b/.github/workflows/reset-data.yml @@ -59,10 +59,19 @@ jobs: fi echo "Confirmed: deleting non-fixture collections from '$PROJECT'." - - name: Install PostgreSQL client + # The ubuntu-24.04 runner image already ships PostgreSQL (only the *service* is + # disabled), so psql is normally on PATH and installing it cost ~9s of `apt-get + # update` for nothing. Kept as a fallback rather than deleted, so this still works + # if a future image drops it. + - name: Ensure psql run: | - sudo apt-get update - sudo apt-get install -y postgresql-client + if command -v psql > /dev/null; then + psql --version + else + echo "psql not on the runner image; installing" + sudo apt-get update + sudo apt-get install -y --no-install-recommends postgresql-client + fi - name: Reset collections env: