Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): Correct k3s version used for e2e testing #172

Merged
merged 10 commits into from
Feb 14, 2025
9 changes: 8 additions & 1 deletion .github/workflows/hl-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:

env:
CLUSTER_NAME : e2e-ci-helm-locker
K3S_VERSION : v1.27.9-k3s1
YQ_VERSION: v4.25.1

jobs:
build:
Expand All @@ -45,6 +45,13 @@ jobs:
- uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
- name: Set K3S Min/Max Versions
run: bash ./scripts/k3s-version >> $GITHUB_ENV
- name: Set K3S_VERSION
run: echo "K3S_VERSION=$K3S_MIN_VERSION_TAG" >> $GITHUB_ENV
- name: build
run: BUILD_TARGET=helm-locker make build
- name : Install k3d
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/hpo-e2e-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ jobs:
arch:
- x64
- arm64
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.27.9-k3s1' }}
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
env:
K3S_VERSION: ${{ matrix.k3s_version }}
Expand All @@ -60,14 +57,18 @@ jobs:
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
- name: Set K3S Min/Max Versions
run: bash ./scripts/k3s-version >> $GITHUB_ENV
- name: Set K3S_VERSION
run: echo "K3S_VERSION=${{ inputs.k3s_version || env.K3S_MIN_VERSION_TAG }}" >> $GITHUB_ENV
- name: Perform pre-e2e image build
run: |
BUILD_TARGET=helm-project-operator REPO=${REPO} TAG=${TAG} ./scripts/build;
BUILD_TARGET=helm-project-operator REPO=${REPO} TAG=${TAG} ./scripts/package;
- name : Install k3d
run : ./.github/workflows/e2e/scripts/install-k3d.sh
- name : Setup k3d cluster
run : K3S_VERSION=${{ env.K3S_VERSION }} ./.github/workflows/e2e/scripts/setup-cluster.sh
run : ./.github/workflows/e2e/scripts/setup-cluster.sh
- name: Import Images Into k3d
run: |
k3d image import ${REPO}/helm-project-operator:${TAG} -c "$CLUSTER_NAME";
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/prom-fed-e2e-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
arch:
- x64
- arm64
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.28.14-k3s1' }}
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
-
Expand All @@ -77,6 +74,10 @@ jobs:
source ./scripts/version
echo TAG=$TAG >> $GITHUB_ENV
echo IMAGE=$IMAGE >> $GITHUB_ENV
- name: Set K3S Min/Max Versions
run: bash ./scripts/k3s-version >> $GITHUB_ENV
- name: Set K3S_VERSION
run: echo "K3S_VERSION=${{ inputs.k3s_version || env.K3S_MIN_VERSION_TAG }}" >> $GITHUB_ENV
-
name: Perform pre-e2e image build
run: |
Expand All @@ -87,7 +88,7 @@ jobs:
run : ./.github/workflows/e2e/scripts/install-k3d.sh
-
name : Setup k3d cluster
run : K3S_VERSION=${{ matrix.k3s_version }} ./.github/workflows/e2e/scripts/setup-cluster.sh
run : ./.github/workflows/e2e/scripts/setup-cluster.sh
-
name: Import Images Into k3d
run: |
Expand Down
4 changes: 3 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
rancherProjectMonitoringVersion: 0.3.4
rancherProjectMonitoringVersion: 0.3.4
k3sTestingMaxVersion: v1.32.1+k3s1
k3sTestingMinVersion: v1.30.9+k3s1
2 changes: 2 additions & 0 deletions pkg/buildconfig/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions scripts/k3s-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash


SCRIPT_PATH="$(realpath ${BASH_SOURCE[0]})"
PROJECT_ROOT="$(dirname $(dirname $SCRIPT_PATH))"
BUILD_YAML="$PROJECT_ROOT/build.yaml"

export K3S_MAX_VERSION=$(yq '.k3sTestingMaxVersion' $BUILD_YAML)
export K3S_MIN_VERSION=$(yq '.k3sTestingMinVersion' $BUILD_YAML)

function print_version_debug() {
echo "K3S_MAX_VERSION=$K3S_MAX_VERSION"
echo "K3S_MAX_VERSION_TAG=${K3S_MAX_VERSION/+/-}"
echo "K3S_MIN_VERSION=$K3S_MIN_VERSION"
echo "K3S_MIN_VERSION_TAG=${K3S_MIN_VERSION/+/-}"
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then print_version_debug "$1"; fi
22 changes: 13 additions & 9 deletions scripts/local-e2e
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

DONT_CLEAN=false
DONT_CLEAN=${DONT_CLEAN:-false}

header() {
local text="$1"
Expand All @@ -22,22 +22,23 @@ cleanupTest() {
}

onExit() {
if [[ "$?" -eq 0 ]]; then
if [[ "$?" -eq 0 ]] || [ "$DONT_CLEAN" == true ]; then
exit 0
fi

cleanupTest
}
trap onExit EXIT

source $(dirname $0)/version
source "$(dirname "$0")/version"
source "$(dirname "$0")/k3s-version"

cd $(dirname $0)/..
cd "$(dirname "$0")/.."

# Setup CI specific Vars
export CLUSTER_NAME='e2e-ci-prometheus-federator'
export E2E_CI=true
export K3S_VERSION=${K3S_VERSION:-v1.28.14-k3s1}
export K3S_VERSION=${K3S_VERSION:-$K3S_MIN_VERSION_TAG}

if k3d cluster list $CLUSTER_NAME 2> /dev/null; then
echo "The test cluster '$CLUSTER_NAME' already exists for some reason"
Expand Down Expand Up @@ -128,6 +129,13 @@ header "Validate Project Prometheus Alerts"
header "Validate Project Alertmanager"
./.github/workflows/e2e/scripts/validate-project-alertmanager.sh;

### ALL LOGIC ABOVE THIS
if [ "$DONT_CLEAN" == true ]; then
header "Local e2e testing was a SUCCESS"
header "Exiting early, to leave cluster for testing"
exit;
fi

# Delete Project Prometheus Stack
header "Delete Project Prometheus Stack"
./.github/workflows/e2e/scripts/delete-projecthelmchart.sh;
Expand All @@ -137,8 +145,4 @@ header "Uninstall Prometheus Federator"
./.github/workflows/e2e/scripts/uninstall-federator.sh;

header "Local e2e testing was a SUCCESS"
### ALL LOGIC ABOVE THIS
if [ "$DONT_CLEAN" = true ]; then
exit;
fi
cleanupTest