Skip to content

Commit

Permalink
chore: Introduce versions.yaml file (#2172)
Browse files Browse the repository at this point in the history
* 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 999d610.

* 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
  • Loading branch information
c-pius authored Jan 14, 2025
1 parent 23d25bc commit 701417f
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 45 deletions.
27 changes: 20 additions & 7 deletions .github/actions/get-configuration/action.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 }}
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/actions/install-k3d/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ runs:
chmod +x k3d-linux
mv k3d-linux ./k3d/bin/k3d
echo "$(pwd)/k3d/bin" >> $GITHUB_PATH
18 changes: 18 additions & 0 deletions .github/actions/install-yq/action.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 19 additions & 7 deletions .github/workflows/lint-golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
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/[email protected]
with:
version: v1.60.3
version: v${{ steps.configuration.outputs.golangci_lint_version }}
args: --verbose
working-directory: ./maintenancewindows
working-directory: ./lifecycle-manager/maintenancewindows
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"augustocdias.tasks-shell-input"
]
}
28 changes: 24 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
]
},
{
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 1 addition & 10 deletions docs/contributor/04-local-test-setup.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 1 addition & 7 deletions scripts/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
10 changes: 5 additions & 5 deletions scripts/tests/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 701417f

Please sign in to comment.