Skip to content

Commit 48cc4c9

Browse files
committed
Read CI PG versions from versions.json and dispatch to citus
1 parent be937ba commit 48cc4c9

5 files changed

Lines changed: 113 additions & 27 deletions

File tree

‎.github/workflows/build-test-images.yml‎

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,31 @@ on:
77

88
workflow_dispatch:
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref_name != 'master' && !startsWith(github.ref_name, 'release-') }}
13+
1014
jobs:
1115
prepare_pgversion_matrix:
12-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04
1317
steps:
14-
# Need the repo checked out in order to read the file
15-
- uses: actions/checkout@v3
18+
# Need the repo checked out in order to read versions.json
19+
- uses: actions/checkout@v5
1620
- id: get_versions
17-
run: cat circleci/images/PG_VERSIONS >> $GITHUB_OUTPUT
21+
run: |
22+
pgversions=$(jq -ec '.postgres_ci | to_entries | sort_by(.key | tonumber) | map(.value)' versions.json)
23+
line=$(jq -er '.line' versions.json)
24+
echo "pgversions=${pgversions}" >> "$GITHUB_OUTPUT"
25+
echo "line=${line}" >> "$GITHUB_OUTPUT"
1826
outputs:
19-
# Will look like '["13.9", "14.6", "15.1"]'
20-
pgversions: ${{ toJSON(steps.get_versions.outputs.*) }}
27+
# Will look like '["14.25","15.20","16.16"]'
28+
pgversions: ${{ steps.get_versions.outputs.pgversions }}
29+
line: ${{ steps.get_versions.outputs.line }}
2130

2231
build_dev_images_per_postgres:
2332
if: github.ref_name != 'master' && !startsWith(github.ref_name, 'release-')
2433
name: push-test-images-for-dev
25-
runs-on: ubuntu-latest
34+
runs-on: ubuntu-24.04
2635
permissions:
2736
packages: write
2837
needs:
@@ -38,10 +47,10 @@ jobs:
3847

3948
steps:
4049
- name: Checkout repository
41-
uses: actions/checkout@v2
50+
uses: actions/checkout@v5
4251

4352
- name: 'Login to GitHub Container Registry'
44-
uses: docker/login-action@v3
53+
uses: docker/login-action@v4
4554
with:
4655
registry: ghcr.io
4756
username: ${{ github.actor }}
@@ -56,7 +65,7 @@ jobs:
5665
build_dev_images_shared:
5766
if: github.ref_name != 'master' && !startsWith(github.ref_name, 'release-')
5867
name: push-test-images-for-dev
59-
runs-on: ubuntu-latest
68+
runs-on: ubuntu-24.04
6069
permissions:
6170
packages: write
6271
strategy:
@@ -69,10 +78,10 @@ jobs:
6978

7079
steps:
7180
- name: Checkout repository
72-
uses: actions/checkout@v2
81+
uses: actions/checkout@v5
7382

7483
- name: 'Login to GitHub Container Registry'
75-
uses: docker/login-action@v3
84+
uses: docker/login-action@v4
7685
with:
7786
registry: ghcr.io
7887
username: ${{ github.actor }}
@@ -88,18 +97,18 @@ jobs:
8897
build_release_images:
8998
if: github.ref_name == 'master' || startsWith(github.ref_name, 'release-')
9099
name: push-test-images-for-release
91-
runs-on: ubuntu-latest
100+
runs-on: ubuntu-24.04
92101
permissions:
93102
packages: write
94103
strategy:
95104
fail-fast: false
96105

97106
steps:
98107
- name: Checkout repository
99-
uses: actions/checkout@v2
108+
uses: actions/checkout@v5
100109

101110
- name: 'Login to GitHub Container Registry'
102-
uses: docker/login-action@v3
111+
uses: docker/login-action@v4
103112
with:
104113
registry: ghcr.io
105114
username: ${{ github.actor }}
@@ -109,3 +118,47 @@ jobs:
109118
run: |
110119
cd circleci/images
111120
RELEASE=1 make push-all
121+
122+
notify_citus:
123+
needs:
124+
- prepare_pgversion_matrix
125+
- build_release_images
126+
if: github.repository == 'citusdata/the-process' && (github.ref_name == 'master' || startsWith(github.ref_name, 'release-')) && needs.prepare_pgversion_matrix.outputs.line == github.ref_name
127+
runs-on: ubuntu-24.04
128+
permissions:
129+
contents: read
130+
steps:
131+
- uses: actions/checkout@v5
132+
133+
- name: Generate GitHub App token
134+
id: app-token
135+
uses: actions/create-github-app-token@v3
136+
with:
137+
app-id: ${{ vars.GH_APP_ID }}
138+
private-key: ${{ secrets.GH_APP_KEY }}
139+
owner: citusdata
140+
repositories: citus
141+
142+
- name: Dispatch citus-ci-images-ready to citus
143+
env:
144+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
145+
SHA: ${{ github.sha }}
146+
REF_NAME: ${{ github.ref_name }}
147+
run: |
148+
line=$(jq -er '.line' versions.json)
149+
if [ "$line" != "$REF_NAME" ]; then
150+
echo "Skipping dispatch: versions.json line ($line) != ref ($REF_NAME)"
151+
exit 0
152+
fi
153+
tag_suffix=$(RELEASE=1 make -C circleci/images -s print-tag-suffix)
154+
if ! [[ "$tag_suffix" =~ ^-v[0-9a-f]{7,}$ ]]; then
155+
echo "::error::Invalid tag_suffix from print-tag-suffix: '${tag_suffix}'"
156+
exit 1
157+
fi
158+
jq -n \
159+
--arg event_type "citus-ci-images-ready" \
160+
--arg line "$line" \
161+
--arg sha "$SHA" \
162+
--arg tag_suffix "$tag_suffix" \
163+
'{event_type: $event_type, client_payload: {line: $line, sha: $sha, tag_suffix: $tag_suffix}}' \
164+
| gh api --method POST repos/citusdata/citus/dispatches --input -

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This image contains all the artifacts required to produce a build of citus binar
4444

4545
The postgres version is installed from the pgdg apt archive. This allows us to install older versions, and therefore keep the versions of postgres pinned during normal release cycles. To bump the version of the Postgres to build against one should change the version as pinned in the `Makefile`
4646

47-
The PostgreSQL images use Debian Bookworm, with versions selected in `circleci/images/PG_VERSIONS`. Server, client, server-dev, debug, and libpq packages remain pinned to those versions. The matching libpq packages require PGDG's major-specific repository components in addition to `main`; the multi-version pgupgradetester uses libpq from its newest configured server version.
47+
The PostgreSQL images use Debian Bookworm, with versions selected in `versions.json`. Server, client, server-dev, debug, and libpq packages remain pinned to those versions. The matching libpq packages require PGDG's major-specific repository components in addition to `main`; the multi-version pgupgradetester uses libpq from its newest configured server version.
4848

4949
### exttester
5050

‎circleci/images/Makefile‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# config variable
22
DOCKER_REPO ?= ghcr.io/citusdata
33
SHA_SUFFIX := $(shell git rev-parse --short HEAD)
4+
ifeq ($(strip $(SHA_SUFFIX)),)
5+
$(error Failed to determine git short SHA)
6+
endif
47

58
# auto generated variables
69
ifdef RELEASE
@@ -9,17 +12,36 @@ else
912
TAG_SUFFIX := -dev-${SHA_SUFFIX}
1013
endif
1114

15+
VERSIONS_FILE := ../../versions.json
16+
1217
# all postgres versions we test against
13-
PG_VERSIONS=$(shell cat PG_VERSIONS|cut -c 6-|tr '\n' ' ' )
18+
PG_VERSIONS := $(shell jq -er '.postgres_ci | to_entries | sort_by(.key | tonumber) | map(.value | if (type == "string" and length > 0) then . else error("invalid postgres_ci version") end) | join(" ")' $(VERSIONS_FILE) || echo __JQ_ERR__)
19+
ifneq ($(filter __JQ_ERR__,$(PG_VERSIONS)),)
20+
$(error Failed to read postgres_ci from $(VERSIONS_FILE) (is jq installed?))
21+
endif
22+
ifeq ($(strip $(PG_VERSIONS)),)
23+
$(error Empty postgres_ci in $(VERSIONS_FILE))
24+
endif
1425

15-
PG_UPGRADE_TESTER_VERSION=$(shell echo ${PG_VERSIONS}|tr ' ' '-'|sed 's/~//g')
26+
PG_UPGRADE_TESTER_VERSION := $(shell echo ${PG_VERSIONS}|tr ' ' '-'|sed 's/~//g')
27+
28+
STYLE_CHECKER_TOOLS_VERSION := $(shell jq -er '.style_checker_tools_version | if (type == "string" and length > 0) then . else error("invalid style_checker_tools_version") end' $(VERSIONS_FILE) || echo __JQ_ERR__)
29+
ifneq ($(filter __JQ_ERR__,$(STYLE_CHECKER_TOOLS_VERSION)),)
30+
$(error Failed to read style_checker_tools_version from $(VERSIONS_FILE))
31+
endif
32+
33+
# Upgrade tests for the PG major versions listed in upgrade_test_pg
34+
CITUS_UPGRADE_PG_VERSIONS := $(shell jq -er '. as $$v | (.upgrade_test_pg // []) | map($$v.postgres_ci[.] // error("unknown upgrade_test_pg major: " + .)) | join(" ")' $(VERSIONS_FILE) || echo __JQ_ERR__)
35+
ifneq ($(filter __JQ_ERR__,$(CITUS_UPGRADE_PG_VERSIONS)),)
36+
$(error Failed to resolve upgrade_test_pg from $(VERSIONS_FILE))
37+
endif
1638

17-
STYLE_CHECKER_TOOLS_VERSION=0.8.18
39+
# Function to get Citus versions for a specific PG major version
40+
get_citus_versions = $(shell jq -r --arg m "$(1)" '(.upgrade_from[$$m] // []) | join(" ")' $(VERSIONS_FILE))
1841

19-
# we should add more majors/citus versions when we address https://github.com/citusdata/citus/issues/4807
20-
CITUS_UPGRADE_PG_VERSIONS=$(shell head -n1 PG_VERSIONS|cut -c 6-|tr '\n' ' ' )
21-
# 10.2.0 is the oldest version supporting PG14, whereas 11.3.0 is for upgrade_pg_dist_cleanup tests
22-
CITUS_UPGRADE_VERSIONS=v10.2.0 v11.3.0
42+
.PHONY: print-tag-suffix
43+
print-tag-suffix:
44+
@echo "${TAG_SUFFIX}"
2345

2446
# code below creates targets for all postgres versions in PG_VERSIONS
2547
define make-image-targets
@@ -100,7 +122,7 @@ build-citusupgradetester-$1:
100122
-f citusupgradetester/Dockerfile \
101123
--build-arg=PG_VERSION=$1 \
102124
--build-arg=PG_MAJOR=$2 \
103-
--build-arg=CITUS_VERSIONS="${CITUS_UPGRADE_VERSIONS}"\
125+
--build-arg=CITUS_VERSIONS="$(call get_citus_versions,$2)" \
104126
--tag=${DOCKER_REPO}/citusupgradetester:$3${TAG_SUFFIX}
105127

106128
build-all:: build-citusupgradetester-$1

‎circleci/images/PG_VERSIONS‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎versions.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"line": "release-12",
3+
"postgres_ci": {
4+
"14": "14.25",
5+
"15": "15.20",
6+
"16": "16.16"
7+
},
8+
"default_pg_major": "16",
9+
"upgrade_test_pg": ["14"],
10+
"upgrade_from": {
11+
"14": ["v10.2.0", "v11.3.0"]
12+
},
13+
"style_checker_tools_version": "0.8.18"
14+
}

0 commit comments

Comments
 (0)