Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .ibm/pipelines/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ NAME_SPACE_SANITY_PLUGINS_CHECK="showcase-sanity-plugins" # Sanity check namespa

# Operator configuration
OPERATOR_MANAGER='rhdh-operator'
CHART_MAJOR_VERSION="1.9"
GITHUB_APP_APP_ID=$(cat /tmp/secrets/GITHUB_APP_3_APP_ID)
GITHUB_APP_CLIENT_ID=$(cat /tmp/secrets/GITHUB_APP_3_CLIENT_ID)
GITHUB_APP_PRIVATE_KEY=$(cat /tmp/secrets/GITHUB_APP_3_PRIVATE_KEY)
Expand Down
9 changes: 8 additions & 1 deletion .ibm/pipelines/jobs/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ handle_ocp_helm_upgrade() {
export QUAY_REPO_BASE="${QUAY_REPO_BASE:-rhdh/rhdh-hub-rhel9}"

# Dynamically determine the previous release version and chart version
previous_release_version=$(common::get_previous_release_version "$CHART_MAJOR_VERSION")
local current_release_version
current_release_version=$(helm::get_chart_major_version)
if [[ -z "$current_release_version" ]]; then
log::error "Failed to determine current release version. Exiting."
save_overall_result 1
exit 1
fi
previous_release_version=$(common::get_previous_release_version "$current_release_version")
if [[ -z "$previous_release_version" ]]; then
log::error "Failed to determine latest release version. Exiting."
save_overall_result 1
Expand Down
58 changes: 51 additions & 7 deletions .ibm/pipelines/lib/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ helm::merge_values() {
helm::get_previous_release_values() {
local value_file_type=${1:-"showcase"}

local current_release_version
current_release_version=$(helm::get_chart_major_version)
if [[ -z "$current_release_version" ]]; then
return 1
fi

# Get the previous release version
local previous_release_version
previous_release_version=$(common::get_previous_release_version "$CHART_MAJOR_VERSION")
previous_release_version=$(common::get_previous_release_version "$current_release_version")

if [[ -z "$previous_release_version" ]]; then
log::error "Failed to determine previous release version."
Expand Down Expand Up @@ -113,17 +119,55 @@ helm::get_previous_release_values() {
# Chart Operations
# ==============================================================================

# Get the latest chart version for a given major version
# Get the chart major.minor version based on RELEASE_BRANCH_NAME or an optional override.
# Uses RELEASE_BRANCH_NAME: 'main' -> highest major.minor from Quay; 'release-x.y' -> extract x.y.
# Args:
# $1 - chart_major_version: The major version to search for (e.g., "1.4")
# $1 - (optional) version_override: Specific version to use (e.g., "1.8" for upgrade base)
# Returns:
# Prints the major.minor version (e.g., "1.9")
helm::get_chart_major_version() {
local version_override=${1:-}

if [[ -n "$version_override" ]]; then
echo "$version_override"
return 0
fi

if [[ -z "${RELEASE_BRANCH_NAME:-}" ]]; then
log::error "RELEASE_BRANCH_NAME is not set"
return 1
fi

if [[ "$RELEASE_BRANCH_NAME" == "main" ]]; then
local chart_major_version
chart_major_version=$(curl -sSX GET "https://quay.io/api/v1/repository/rhdh/chart/tag/?onlyActiveTags=true&limit=100" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might fail the job on the release branch if we plan to backport it. There’s a chance that the next release CV won’t appear in the first 100 batches of the API request. For the next tag, it should work fine since it gets built frequently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This curl will be exercised only on the main branch, and I think that it's very unlikely, that the next (right now 1.10.) wouldn't show up in the first 100.
If we're on the release-x.y branch, it will just cut the x.y from the branch name and search for the tag using a filter the tags that contains x.y.

-H "Content-Type: application/json" \
| jq -r '.tags[].name' \
| grep -oE '^[0-9]+\.[0-9]+' \
| sort -t. -k1,1n -k2,2n \
| uniq | tail -1)
if [[ -z "$chart_major_version" ]]; then
log::error "Failed to determine highest chart version from tags"
return 1
fi
echo "$chart_major_version"
elif echo "$RELEASE_BRANCH_NAME" | grep -qE '^release-[0-9]+\.[0-9]+$'; then
echo "$RELEASE_BRANCH_NAME" | grep -oE '[0-9]+\.[0-9]+'
else
log::error "Invalid RELEASE_BRANCH_NAME: $RELEASE_BRANCH_NAME (expected 'main' or 'release-x.y')"
return 1
fi
}

# Get the latest chart version based on RELEASE_BRANCH_NAME or an optional version override.
# Args:
# $1 - (optional) version_override: Specific version to use (e.g., "1.8" for upgrade base)
# Returns:
# Prints the chart version (e.g., "1.4-123-CI")
helm::get_chart_version() {
local chart_major_version=$1

local chart_major_version
chart_major_version=$(helm::get_chart_major_version "${1:-}")
if [[ -z "$chart_major_version" ]]; then
log::error "Missing chart major version parameter"
log::info "Usage: helm::get_chart_version <major_version>"
return 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ main() {
log::info "Log file: ${LOGFILE}"
log::info "JOB_NAME : $JOB_NAME"

CHART_VERSION=$(helm::get_chart_version "$CHART_MAJOR_VERSION")
CHART_VERSION=$(helm::get_chart_version)
export CHART_VERSION

case "$JOB_NAME" in
Expand Down
Loading