Skip to content

Commit 8bbeb6e

Browse files
committed
auto-detect
1 parent 96015ff commit 8bbeb6e

File tree

1 file changed

+46
-26
lines changed

1 file changed

+46
-26
lines changed

.github/workflows/test-package-installation.yml

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,76 @@ on:
55
branches:
66
- all-citus-test-installation-workflow
77
workflow_dispatch:
8-
inputs:
9-
pg_major_version:
10-
description: "PostgreSQL major version (e.g., 18)"
11-
required: true
12-
type: string
13-
citus_major_minor_version:
14-
description: "Citus major.minor version (e.g., 14.0)"
15-
required: true
16-
type: string
178

189
env:
19-
# Branch whose build-package.yml defines the canonical platform list
10+
# Branch whose build-package.yml and postgres-matrix.yml are the source of truth
2011
SOURCE_BRANCH: "all-citus"
21-
PG_MAJOR_VERSION: ${{ inputs.pg_major_version || '18' }}
22-
CITUS_MAJOR_MINOR_VERSION: ${{ inputs.citus_major_minor_version || '14.0' }}
2312

2413
jobs:
25-
discover_platforms:
26-
name: Discover supported platforms
14+
discover:
15+
name: Discover platforms & versions
2716
runs-on: ubuntu-latest
2817
outputs:
29-
matrix: ${{ steps.extract.outputs.matrix }}
18+
matrix: ${{ steps.build_matrix.outputs.matrix }}
19+
citus_version: ${{ steps.resolve_versions.outputs.citus_version }}
3020
steps:
3121
- name: Checkout repository
3222
uses: actions/checkout@v4
3323

34-
- name: Extract platform list from build-package.yml
35-
id: extract
24+
- name: Fetch source branch
25+
run: git fetch origin "${SOURCE_BRANCH}" --depth=1
26+
27+
- name: Extract platform list
28+
id: extract_platforms
3629
run: |
37-
# Fetch only the all-citus branch (shallow) to read its build-package.yml
38-
git fetch origin "${SOURCE_BRANCH}" --depth=1
3930
git show "origin/${SOURCE_BRANCH}:.github/workflows/build-package.yml" \
4031
> /tmp/build-package.yml
4132
42-
# Pull the platform array and compact it into a single-line JSON string
4333
platforms=$(
4434
yq -o=json '.jobs.build_package.strategy.matrix.platform' /tmp/build-package.yml \
4535
| jq -c '.'
4636
)
4737
4838
echo "Discovered platforms: ${platforms}"
49-
echo "matrix={\"platform\": ${platforms}}" >> "$GITHUB_OUTPUT"
39+
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"
40+
41+
- name: Resolve Citus & PG versions from postgres-matrix.yml
42+
id: resolve_versions
43+
run: |
44+
git show "origin/${SOURCE_BRANCH}:postgres-matrix.yml" > /tmp/postgres-matrix.yml
45+
46+
# Latest entry = last element in version_matrix
47+
citus_version=$(yq '.version_matrix[-1] | keys | .[0]' /tmp/postgres-matrix.yml)
48+
49+
pg_versions=$(
50+
yq -o=json \
51+
".version_matrix[-1].\"${citus_version}\".postgres_versions" \
52+
/tmp/postgres-matrix.yml \
53+
| jq -c '[.[] | tostring]'
54+
)
55+
56+
echo "Latest Citus version: ${citus_version}"
57+
echo "Supported PG versions: ${pg_versions}"
58+
echo "citus_version=${citus_version}" >> "$GITHUB_OUTPUT"
59+
echo "pg_versions=${pg_versions}" >> "$GITHUB_OUTPUT"
60+
61+
- name: Build matrix
62+
id: build_matrix
63+
run: |
64+
matrix=$(jq -cn \
65+
--argjson platforms '${{ steps.extract_platforms.outputs.platforms }}' \
66+
--argjson pg_versions '${{ steps.resolve_versions.outputs.pg_versions }}' \
67+
'{"platform": $platforms, "pg_version": $pg_versions}')
68+
echo "Matrix: ${matrix}"
69+
echo "matrix=${matrix}" >> "$GITHUB_OUTPUT"
5070
5171
test_package:
52-
name: "Test ${{ matrix.platform }}"
53-
needs: discover_platforms
72+
name: "Test ${{ matrix.platform }} / PG ${{ matrix.pg_version }}"
73+
needs: discover
5474
runs-on: ubuntu-latest
5575
strategy:
5676
fail-fast: false
57-
matrix: ${{ fromJson(needs.discover_platforms.outputs.matrix) }}
77+
matrix: ${{ fromJson(needs.discover.outputs.matrix) }}
5878
steps:
5979
- name: Checkout repository
6080
uses: actions/checkout@v4
@@ -68,5 +88,5 @@ jobs:
6888
run: |
6989
python3 test_package_installation/run_test.py \
7090
"${{ matrix.platform }}" \
71-
"${PG_MAJOR_VERSION}" \
72-
"${CITUS_MAJOR_MINOR_VERSION}"
91+
"${{ matrix.pg_version }}" \
92+
"${{ needs.discover.outputs.citus_version }}"

0 commit comments

Comments
 (0)