Skip to content

Commit 84b3b6c

Browse files
ci: reduce unit-test Kubernetes matrix on pull requests (cloudnative-pg#10886)
On pull requests, run unit tests only against the lowest and highest supported Kubernetes versions instead of the full 7-version matrix. This reduces per-PR runner usage significantly while keeping full coverage on main, release branches, and scheduled runs. Closes cloudnative-pg#10860 Signed-off-by: kavirakesh14 <kavirakesh007@gmail.com> Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com> (cherry picked from commit 5f5986a)
1 parent b83af2b commit 84b3b6c

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,28 @@ jobs:
260260
- name: Get k8s versions for unit test
261261
id: get-k8s-versions
262262
shell: bash
263+
env:
264+
EVENT_NAME: ${{ github.event_name }}
263265
run: |
264-
k8s_versions=$(jq -c '
265-
.unit_test.max as $max |
266-
.unit_test.min as $min |
267-
$min | [ while(. <= $max;
268-
. | split(".") | .[1] |= (.|tonumber|.+1|tostring) | join(".")
269-
)
270-
] |
271-
.[] |= .+".x"
272-
' < .github/k8s_versions_scope.json)
266+
if [[ "${EVENT_NAME}" == "pull_request" ]]; then
267+
# On pull requests, only test against the lowest and highest supported
268+
# versions to bracket the support window, keeping CI fast.
269+
k8s_versions=$(jq -c '
270+
[.unit_test.min + ".x", .unit_test.max + ".x"]
271+
' < .github/k8s_versions_scope.json)
272+
else
273+
# On pushes to main/release branches and scheduled runs, run the full
274+
# matrix so cross-version regressions are caught before a release.
275+
k8s_versions=$(jq -c '
276+
.unit_test.max as $max |
277+
.unit_test.min as $min |
278+
$min | [ while(. <= $max;
279+
. | split(".") | .[1] |= (.|tonumber|.+1|tostring) | join(".")
280+
)
281+
] |
282+
.[] |= .+".x"
283+
' < .github/k8s_versions_scope.json)
284+
fi
273285
echo "k8s_versions=${k8s_versions}" >> $GITHUB_OUTPUT
274286
275287
latest_k8s_version=$(jq -r '.|last' <<< $k8s_versions)

0 commit comments

Comments
 (0)