Skip to content

Commit

Permalink
CI: automate k8s version matrix values
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsn723 committed Jun 23, 2024
1 parent 130c07e commit 02aa0af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ jobs:
go-version: ${{ env.go-version }}
- name: Test
run: make test
get-k8s-versions:
runs-on: ubuntu-latest
outputs:
k8s-versions: ${{ steps.get-k8s-version.outputs.versions }}
steps:
- id: get-k8s-version
working-directory: e2e
run: |
echo "versions=$(make get-k8s-versions)" >> $GITHUB_OUTPUT
e2e:
name: End-to-End Tests
needs: get-k8s-versions
strategy:
matrix:
k8s-version: ['1.27.2', '1.28.0', '1.29.0']
k8s-version: ${{ fromJson(needs.get-k8s-versions.outputs.k8s-versions) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 14 additions & 2 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROJECT_NAME = dkim-manager
CERT_MANAGER_VERSION = 1.6.1
KIND_VERSION = 0.16.0
KUBERNETES_VERSION = 1.23.1
KIND_VERSION = 0.23.0
KUBERNETES_VERSION = $(shell curl -L -s https://dl.k8s.io/release/stable.txt)

BINDIR = $(dir $(shell pwd))/bin/
HELM = $(BINDIR)/helm
Expand Down Expand Up @@ -59,3 +59,15 @@ $(KUBECTL):
mkdir -p ../bin
curl -sfL -o $@ https://dl.k8s.io/release/v$(KUBERNETES_VERSION)/bin/linux/amd64/kubectl
chmod a+x $@

.PHONY: get-k8s-versions
get-k8s-versions:
@LATEST_VERSION=$$(curl -L -s https://dl.k8s.io/release/stable.txt) && \
KIND_TAGS=$$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/kindest/node/tags?page_size=1024' | jq -r '.results[] | .name' | grep -Po '\d+\.\d+\.\d+$$' | sort -u) && \
LATEST_VERSION_MAJOR=$$(echo $${LATEST_VERSION} | grep -Po '(?<=v)\d+\.\d+') && \
LATEST_KIND_TAG=$$(printf "%s\n" $${KIND_TAGS} | grep "$${LATEST_VERSION_MAJOR}" | sort -u | tail -n 1) && \
PREVIOUS_VERSION_MAJOR=$$(echo $${LATEST_VERSION_MAJOR} | awk -F. -v OFS=. '{$$NF -= 1; print}') && \
PREVIOUS_KIND_TAG=$$(printf "%s\n" $${KIND_TAGS} | grep "$${PREVIOUS_VERSION_MAJOR}" | sort -u | tail -n 1) && \
PREVIOUS2_VERSION_MAJOR=$$(echo $${PREVIOUS_VERSION_MAJOR} | awk -F. -v OFS=. '{$$NF -= 1; print}') && \
PREVIOUS2_KIND_TAG=$$(printf "%s\n" $${KIND_TAGS} | grep "$${PREVIOUS2_VERSION_MAJOR}" | sort -u | tail -n 1) && \
echo "['$${PREVIOUS2_KIND_TAG}', '$${PREVIOUS_KIND_TAG}', '$${LATEST_KIND_TAG}']"

0 comments on commit 02aa0af

Please sign in to comment.