From 23d25bcb38c97863e65ce1d321a2b772b8fe5fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Schw=C3=A4gerl?= Date: Tue, 14 Jan 2025 11:10:15 +0100 Subject: [PATCH 1/2] chore: Re-Add 'latest' tag to sec-scanners-config (#2176) --- sec-scanners-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/sec-scanners-config.yaml b/sec-scanners-config.yaml index 6374f1e4b2..82f9f86893 100644 --- a/sec-scanners-config.yaml +++ b/sec-scanners-config.yaml @@ -4,6 +4,7 @@ checkmarxOne: checkmarx_preset: golang protecode: - europe-docker.pkg.dev/kyma-project/prod/lifecycle-manager:1.2.7 + - europe-docker.pkg.dev/kyma-project/prod/lifecycle-manager:latest whitesource: language: golang-mod exclude: From 701417fb77538acd39ac8d2dc19ed4c8d6684d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Schw=C3=A4gerl?= Date: Tue, 14 Jan 2025 13:06:26 +0100 Subject: [PATCH 2/2] chore: Introduce `versions.yaml` file (#2172) * chore: Introduce versions.yaml file * skip wait for image build for testing * comment out manual k8s version * remove maual k8s version * fix yq install * re-introduce manual dispatch k8s version * fix manual dispatch k8s version * use in golangci-lint; cosmetics * Revert "skip wait for image build for testing" This reverts commit 999d610f44b5dcb51f12fffae886ee3966dc9485. * use for check versions.sh * fix golangci-lint * update local test setup * fix golangci-lint * fix golangci-lint * fix golangci-lint * try to use working dir * align directory * align directory for go * prefix v --- .github/actions/get-configuration/action.yml | 27 ++++++++++++++----- .github/actions/install-k3d/action.yml | 1 - .github/actions/install-yq/action.yml | 18 +++++++++++++ .github/workflows/lint-golangci.yml | 26 +++++++++++++----- .vscode/extensions.json | 5 ++++ .vscode/tasks.json | 28 +++++++++++++++++--- Makefile | 8 +++--- docs/contributor/04-local-test-setup.md | 11 +------- scripts/tests/README.md | 8 +----- scripts/tests/version.sh | 10 +++---- versions.yaml | 12 +++++++++ 11 files changed, 109 insertions(+), 45 deletions(-) create mode 100644 .github/actions/install-yq/action.yml create mode 100644 .vscode/extensions.json create mode 100644 versions.yaml diff --git a/.github/actions/get-configuration/action.yml b/.github/actions/get-configuration/action.yml index 62bbeac5b5..8878803bc1 100644 --- a/.github/actions/get-configuration/action.yml +++ b/.github/actions/get-configuration/action.yml @@ -1,5 +1,5 @@ name: Get configuration -description: Defines configuration variables such as versions. Exposes globally needed environment variables. +description: Defines configuration variables such as versions read from the versions.yaml file. Exposes globally needed environment variables. outputs: k8s_version: description: The version of k8s to use. For example, 1.28.7. @@ -16,6 +16,9 @@ outputs: cert_manager_version: description: The version of cert-manager to deploy. For example, 1.13.3. value: ${{ steps.define-variables.outputs.cert_manager_version }} + golangci_lint_version: + description: The version of golangci-lint to use. For example, 1.60.3. + value: ${{ steps.define-variables.outputs.golangci_lint_version }} klm_version_tag: description: The version tag for the KLM image. For example, PR-123. value: ${{ steps.define-variables.outputs.klm_version_tag }} @@ -25,24 +28,34 @@ outputs: runs: using: composite steps: + - name: Install yq + uses: ./lifecycle-manager/.github/actions/install-yq + with: + yq_version: 4.45.1 - name: Define variables id: define-variables + working-directory: lifecycle-manager shell: bash run: | - echo "istio_version=1.20.3" >> $GITHUB_OUTPUT - echo "k3d_version=5.7.4" >> $GITHUB_OUTPUT - echo "modulectl_version=1.1.3" >> $GITHUB_OUTPUT - echo "cert_manager_version=1.15.0" >> $GITHUB_OUTPUT + echo "istio_version=$(yq e '.istio' versions.yaml)" >> $GITHUB_OUTPUT + echo "k3d_version=$(yq e '.k3d' versions.yaml)" >> $GITHUB_OUTPUT + echo "modulectl_version=$(yq e '.modulectl' versions.yaml)" >> $GITHUB_OUTPUT + echo "cert_manager_version=$(yq e '.certManager' versions.yaml)" >> $GITHUB_OUTPUT + echo "golangci_lint_version=$(yq e '.golangciLint' versions.yaml)" >> $GITHUB_OUTPUT if [[ -n "${{ github.event.pull_request.number }}" ]]; then echo "klm_version_tag=PR-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT echo "klm_image_repo=dev" >> $GITHUB_OUTPUT - echo "k8s_version=1.30.3" >> $GITHUB_OUTPUT + echo "k8s_version=$(yq e '.k8s' versions.yaml)" >> $GITHUB_OUTPUT else # Manually executed workflow should use the latest image of main branch echo "klm_version_tag=latest" >> $GITHUB_OUTPUT echo "klm_image_repo=prod" >> $GITHUB_OUTPUT - echo "k8s_version=${{ github.event.inputs.k8s_version || '1.30.3' }}" >> $GITHUB_OUTPUT + if [[ -n "${{ github.event.inputs.k8s_version }}" ]]; then + echo "k8s_version=${{ github.event.inputs.k8s_version }}" >> $GITHUB_OUTPUT + else + echo "k8s_version=$(yq e '.k8s' versions.yaml)" >> $GITHUB_OUTPUT + fi fi - name: Expose environment variables shell: bash diff --git a/.github/actions/install-k3d/action.yml b/.github/actions/install-k3d/action.yml index c2ae7f6a1d..a3970826c1 100644 --- a/.github/actions/install-k3d/action.yml +++ b/.github/actions/install-k3d/action.yml @@ -15,4 +15,3 @@ runs: chmod +x k3d-linux mv k3d-linux ./k3d/bin/k3d echo "$(pwd)/k3d/bin" >> $GITHUB_PATH - diff --git a/.github/actions/install-yq/action.yml b/.github/actions/install-yq/action.yml new file mode 100644 index 0000000000..79e7bac256 --- /dev/null +++ b/.github/actions/install-yq/action.yml @@ -0,0 +1,18 @@ +name: Install yq +description: Downloads yq and installs it locally. +inputs: + yq_version: + description: The version of yq to install. For example, 4.45.1. + required: true +runs: + using: composite + steps: + - name: Install yq + shell: bash + run: | + mkdir -p ./yq/bin + + wget https://github.com/mikefarah/yq/releases/${{ inputs.yq_version }}/download/yq_linux_amd64 -o ./yq/bin/yq &&\ + chmod +x ./yq/bin/yq + + echo "$(pwd)/yq/bin" >> $GITHUB_PATH diff --git a/.github/workflows/lint-golangci.yml b/.github/workflows/lint-golangci.yml index dd54813e8f..f617be6209 100644 --- a/.github/workflows/lint-golangci.yml +++ b/.github/workflows/lint-golangci.yml @@ -11,25 +11,37 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout lifecycle-manager + uses: actions/checkout@v4 + with: + path: lifecycle-manager + - uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version-file: './lifecycle-manager/go.mod' cache: false + + - name: Get configuration + uses: ./lifecycle-manager/.github/actions/get-configuration + id: configuration + - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.60.3 + version: v${{ steps.configuration.outputs.golangci_lint_version }} args: --verbose + working-directory: ./lifecycle-manager + - name: golangci-lint for api module uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.60.3 + version: v${{ steps.configuration.outputs.golangci_lint_version }} args: --verbose - working-directory: ./api + working-directory: ./lifecycle-manager/api + - name: golangci-lint for maintenancewindows module uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.60.3 + version: v${{ steps.configuration.outputs.golangci_lint_version }} args: --verbose - working-directory: ./maintenancewindows + working-directory: ./lifecycle-manager/maintenancewindows diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..606de73ade --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "augustocdias.tasks-shell-input" + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a34e46209c..dc13a6ff44 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -9,8 +9,8 @@ "command": "${cwd}/scripts/tests/create_test_clusters.sh", "dependsOn": ["Delete Test Clusters"], "args": [ - "--k8s-version", "1.30.3", - "--cert-manager-version", "1.13.3" + "--k8s-version", "${input:k8sVersion}", + "--cert-manager-version", "${input:certManagerVersion}" ] }, { @@ -23,8 +23,8 @@ "type": "shell", "command": "${cwd}/scripts/tests/create_test_clusters.sh", "args": [ - "--k8s-version", "1.30.3", - "--cert-manager-version", "1.13.3" + "--k8s-version", "${input:k8sVersion}", + "--cert-manager-version", "${input:certManagerVersion}" ] }, // re-run if encountering error that the watcher CRD is missing @@ -74,6 +74,26 @@ } ], "inputs": [ + { + "id": "k8sVersion", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "yq e '.k8s' ./versions.yaml", + "cwd": "${workspaceFolder}", + "useSingleResult": true + } + }, + { + "id": "certManagerVersion", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "yq e '.certManager' ./versions.yaml", + "cwd": "${workspaceFolder}", + "useSingleResult": true + } + }, { // not all of the options work OOTB, see deploy-lifecycle-manager-e2e action.yaml for specific patches "id": "e2eTestTarget", diff --git a/Makefile b/Makefile index 61a6a3cf27..9e654d39b8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ IMG := $(IMG_NAME):$(DOCKER_TAG) BUILD_VERSION := from_makefile # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.30.3 +ENVTEST_K8S_VERSION = $(shell yq e '.k8s' ./versions.yaml) # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -147,9 +147,9 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest GOLANG_CI_LINT = $(LOCALBIN)/golangci-lint ## Tool Versions -KUSTOMIZE_VERSION ?= v5.3.0 -CONTROLLER_TOOLS_VERSION ?= v0.14.0 -GOLANG_CI_LINT_VERSION ?= v1.60.3 +KUSTOMIZE_VERSION ?= v$(shell yq e '.kustomize' ./versions.yaml) +CONTROLLER_TOOLS_VERSION ?= v$(shell yq e '.controllerTools' ./versions.yaml) +GOLANG_CI_LINT_VERSION ?= v$(shell yq e '.golangciLint' ./versions.yaml) .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/docs/contributor/04-local-test-setup.md b/docs/contributor/04-local-test-setup.md index 4a269e1c61..3df96bcc2c 100644 --- a/docs/contributor/04-local-test-setup.md +++ b/docs/contributor/04-local-test-setup.md @@ -1,16 +1,7 @@ # Local Test Setup in the Control Plane Mode Using k3d > ### Supported Versions -> * Golang: `v1.22.5` -> * k3d: `v5.6.0` -> * k3s: `v1.27.4-k3s1 (default)` -> * kubectl: -> * Client Version: `v1.30.2` -> * Server Version: `v1.27.4+k3s1` -> * docker: -> * Client Version: `v26.1.4` -> * Server: `Docker Desktop v4.31.0` -> * Engine Version: `v26.1.4` +> For more information on the tooling versions expected in the project, see [`versions.yaml`](../../versions.yaml). ## Context diff --git a/scripts/tests/README.md b/scripts/tests/README.md index 44ed7a7345..275301c991 100644 --- a/scripts/tests/README.md +++ b/scripts/tests/README.md @@ -10,14 +10,8 @@ If the check detects outdated versions, it gives a warning and exits with succes * `2` - Invalid version found, for example, incorrect Semantic Versioning ### Current Versions -| CLI Tool | Version | -| --------- | ------- | -| `kubectl` | v1.31.3 | -| `go` | v1.23.3 | -| `k3d` | v5.6.0 | -| `docker` | v27.3.1 | -| `istioctl`| v1.24.1 | +The current tooling versions are defined in [`versions.yaml`](../../versions.yaml). ## Create Test Clusters: `create_test_cluster.sh` The script creates two test clusters using `k3d`: diff --git a/scripts/tests/version.sh b/scripts/tests/version.sh index e19c61ee1e..94e20333d5 100755 --- a/scripts/tests/version.sh +++ b/scripts/tests/version.sh @@ -5,11 +5,11 @@ SEM_VER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" # Set default values for variables -KUBECTL_VERSION_DEFAULT="1.31.3" -GO_VERSION_DEFAULT="1.23.3" -K3D_VERSION_DEFAULT="5.6.0" -DOCKER_VERSION_DEFAULT="27.3.1" -ISTIOCTL_VERSION_DEFAULT="1.24.1" +KUBECTL_VERSION_DEFAULT=$(yq e '.kubectl' versions.yaml) +GO_VERSION_DEFAULT=$(yq e '.go' versions.yaml) +K3D_VERSION_DEFAULT=$(yq e '.k3d' versions.yaml) +DOCKER_VERSION_DEFAULT=$(yq e '.docker' versions.yaml) +ISTIOCTL_VERSION_DEFAULT=$(yq e '.istio' versions.yaml) versioning_error=false # Check if required tools are installed diff --git a/versions.yaml b/versions.yaml new file mode 100644 index 0000000000..73b46c8fe0 --- /dev/null +++ b/versions.yaml @@ -0,0 +1,12 @@ +# defines the versions of the tools used in the project +istio: "1.24.1" +k3d: "5.7.4" +modulectl: "1.1.3" +certManager: "1.15.0" +k8s: "1.30.3" +kustomize: "5.3.0" +controllerTools: "0.14.0" +golangciLint: "1.60.3" +kubectl: "1.31.3" +go: "1.23.4" +docker: "27.4.0"