Skip to content

Commit

Permalink
ci: Filter supported versions of GKE.
Browse files Browse the repository at this point in the history
Whenever GKE stopped supporting a particular version of GKE, we had to
manually remove it from all stable branches. Now instead of that, we
will dynamically check if it's supported and only then run the test.

Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
  • Loading branch information
marseel authored and aanm committed May 22, 2024
1 parent cd7fe0c commit dd947b3
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 5 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/conformance-externalworkloads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
yq -o=json ${work_dir}/k8s-versions.yaml | jq . > "${destination_directory}/gke.json"
- name: Generate Matrix
id: set-matrix
run: |
cd /tmp/generated/gke
Expand All @@ -116,7 +115,44 @@ jobs:
echo "Generated matrix:"
cat /tmp/matrix.json
echo "matrix=$(jq -c . < /tmp/matrix.json)" >> $GITHUB_OUTPUT
- name: Set up gcloud credentials
id: 'auth'
uses: google-github-actions/auth@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
with:
workload_identity_provider: ${{ secrets.GCP_PR_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_PR_SA }}
create_credentials_file: true
export_environment_variables: true

- name: Set up gcloud CLI
uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
version: "405.0.0"

- name: Filter Matrix
id: set-matrix
run: |
cp /tmp/matrix.json /tmp/result.json
jq -c '.include[]' /tmp/matrix.json | while read i; do
VERSION=$(echo $i | jq -r '.version')
ZONE=$(echo $i | jq -r '.zone')
gcloud --quiet container get-server-config \
--flatten="channels" --filter="channels.channel=REGULAR" \
--format="yaml(channels.validVersions)" --zone $ZONE > /tmp/output
if grep -q -F $VERSION /tmp/output; then
echo "Version $VERSION is valid for zone $ZONE"
else
echo "Removing version $VERSION as it's not valid for zone $ZONE"
jq 'del(.include[] | select(.version == "'$VERSION'"))' /tmp/result.json > /tmp/result.json.tmp
mv /tmp/result.json.tmp /tmp/result.json
fi
done
echo "Filtered matrix:"
cat /tmp/result.json
echo "matrix=$(jq -c . < /tmp/result.json)" >> $GITHUB_OUTPUT
installation-and-connectivity:
name: Installation and Connectivity Test
Expand Down
42 changes: 39 additions & 3 deletions .github/workflows/conformance-gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ jobs:
new_filename="${filename%.yaml}.json"
yq -o=json "${file}" | jq . > "${destination_directory}/${new_filename}"
done
# Merge 2 files into one
jq -s "add" ${destination_directory}/*.json > "${destination_directory}/gke.json"
- name: Generate Matrix
id: set-matrix
run: |
cd /tmp/generated/gke
Expand All @@ -121,7 +120,44 @@ jobs:
echo "Generated matrix:"
cat /tmp/matrix.json
echo "matrix=$(jq -c . < /tmp/matrix.json)" >> $GITHUB_OUTPUT
- name: Set up gcloud credentials
id: 'auth'
uses: google-github-actions/auth@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
with:
workload_identity_provider: ${{ secrets.GCP_PR_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_PR_SA }}
create_credentials_file: true
export_environment_variables: true

- name: Set up gcloud CLI
uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
version: "405.0.0"

- name: Filter Matrix
id: set-matrix
run: |
cp /tmp/matrix.json /tmp/result.json
jq -c '.k8s[]' /tmp/matrix.json | while read i; do
VERSION=$(echo $i | jq -r '.version')
ZONE=$(echo $i | jq -r '.zone')
gcloud --quiet container get-server-config \
--flatten="channels" --filter="channels.channel=REGULAR" \
--format="yaml(channels.validVersions)" --zone $ZONE > /tmp/output
if grep -q -F $VERSION /tmp/output; then
echo "Version $VERSION is valid for zone $ZONE"
else
echo "Removing version $VERSION as it's not valid for zone $ZONE"
jq 'del(.k8s[] | select(.version == "'$VERSION'"))' /tmp/result.json > /tmp/result.json.tmp
mv /tmp/result.json.tmp /tmp/result.json
fi
done
echo "Filtered matrix:"
cat /tmp/result.json
echo "matrix=$(jq -c . < /tmp/result.json)" >> $GITHUB_OUTPUT
installation-and-connectivity:
name: Installation and Connectivity Test
Expand Down

0 comments on commit dd947b3

Please sign in to comment.