Skip to content

Commit b59056a

Browse files
CI: derive changes job's PG floor from META.json instead of a hardcoded 10 (#51)
1 parent 3c74100 commit b59056a

1 file changed

Lines changed: 48 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ jobs:
6868
# would never report on doc-only pushes and get stuck Pending in branch
6969
# protection.
7070
#
71-
# Also derives, from a SINGLE set of constants, the supported-PostgreSQL-
72-
# major list the test job consumes: every job that cares which majors are
73-
# supported reads the SAME list, so they can't silently drift onto
74-
# different sets, and adding a new major is a one-line change here
75-
# instead of an edit in several jobs. `newest_pg` is the same NEWEST
76-
# constant emitted again as a bare scalar (not wrapped in the JSON-array
77-
# `supported_pg`), consumed only by the `test` job's draft-PR matrix
78-
# reduction (see the top-of-file comment and that job's own comment) - so
79-
# NEWEST still only needs to change in one place.
71+
# Also derives the supported-PostgreSQL-major list the test job consumes,
72+
# from a single NEWEST constant plus META.json's own declared minimum
73+
# (not a second hand-maintained floor constant): every job that cares
74+
# which majors are supported reads the SAME list, so they can't silently
75+
# drift onto different sets, and adding a new major is a one-line change
76+
# here instead of an edit in several jobs. `newest_pg` is the same
77+
# NEWEST constant emitted again as a bare scalar (not wrapped in the
78+
# JSON-array `supported_pg`), consumed only by the `test` job's draft-PR
79+
# matrix reduction (see the top-of-file comment and that job's own
80+
# comment) - so NEWEST still only needs to change in one place.
8081
changes:
8182
name: 🔍 Detect docs-only changes & derive PG matrix
8283
runs-on: ubuntu-latest
@@ -158,22 +159,48 @@ jobs:
158159
# it cannot silently drift onto a different list. Adding a new
159160
# major is a one-line NEWEST bump here, not an edit in N places.
160161
#
161-
# Only one floor is needed here: 0.9.6 (the oldest version
162-
# count_nulls still ships a full install script for) is pure SQL
163-
# over anyarray/json/jsonb with no catalog-version sensitivity, so
164-
# it installs on every PostgreSQL major count_nulls supports -
165-
# there's no separate legacy-only floor to carve out.
162+
# The floor itself is NOT a second hardcoded constant here: it's
163+
# read straight from META.json's own build prereq (see
164+
# META.in.json's comment: "Depends on JSONB, created in 9.4"),
165+
# which is the actual source of truth for count_nulls' minimum
166+
# supported major. Hand-maintaining a duplicate floor constant in
167+
# this workflow is exactly how it ended up testing down to 10 while
168+
# META.json claimed 9.4 - 9.4/9.5/9.6 went untested for a while
169+
# even though pg-start genuinely installs them fine on current
170+
# Actions infra, and nobody noticed the gap.
166171
NEWEST=18
167-
FLOOR=10
168172
169-
supported=$(seq "$NEWEST" -1 "$FLOOR")
173+
DECLARED_FLOOR=$(jq -r '.prereqs.build.requires.PostgreSQL' META.json) # e.g. "9.4.0"
174+
FLOOR_MAJOR=$(echo "$DECLARED_FLOOR" | cut -d. -f1)
175+
if [ "$FLOOR_MAJOR" -lt 10 ]; then
176+
# PostgreSQL's pre-10 versioning used X.Y as the major identifier
177+
# (10+ switched to a single integer) - e.g. "9.4.0" -> major
178+
# "9.4", not "9".
179+
FLOOR=$(echo "$DECLARED_FLOOR" | cut -d. -f1,2)
180+
else
181+
FLOOR="$FLOOR_MAJOR"
182+
fi
183+
184+
# A sub-10 floor needs two `seq` runs stitched together: one for
185+
# the integer majors (10..NEWEST) and one for the X.Y majors
186+
# (9.FLOOR_MINOR..9.6, since 9.6 was the last 9.x release).
187+
if [[ "$FLOOR" == 9.* ]]; then
188+
FLOOR_MINOR=$(echo "$FLOOR" | cut -d. -f2)
189+
supported="$(seq "$NEWEST" -1 10) $(seq 6 -1 "$FLOOR_MINOR" | sed 's/^/9./')"
190+
else
191+
supported=$(seq "$NEWEST" -1 "$FLOOR")
192+
fi
170193
171-
# Emit a JSON array from a list of ints, for the job matrices to
172-
# consume with fromJSON (GitHub evaluates a literal dollar-brace
173-
# expression even inside a run block, so none is written here).
174-
json() { printf '%s\n' "$@" | paste -sd, - | sed 's/^/[/; s/$/]/'; }
194+
# Emit a JSON array of STRINGS, not bare numbers - "9.4" isn't a
195+
# valid bare integer token, and keeping every leg (10+ and 9.x
196+
# alike) as a string keeps matrix.pg comparisons/interpolations
197+
# consistent regardless of which leg they're in. $supported is
198+
# deliberately unquoted below: it word-splits (on both the spaces
199+
# AND the newlines `seq`/the concatenation above produce) into
200+
# individual version tokens for printf to repeat over.
201+
json() { printf '"%s",' $supported | sed 's/,$//; s/^/[/; s/$/]/'; }
175202
176-
echo "supported_pg=$(json $supported)" >> "$GITHUB_OUTPUT"
203+
echo "supported_pg=$(json)" >> "$GITHUB_OUTPUT"
177204
178205
# Also emitted as a bare scalar (not a JSON array) so the `test`
179206
# job's draft-PR matrix reduction (see its own comment) can build a

0 commit comments

Comments
 (0)