Skip to content

Commit

Permalink
(releases/2.14) Make compatibility tests run on releases branch and m…
Browse files Browse the repository at this point in the history
…ake them run on all previous patch versions (#1076)
  • Loading branch information
adityabharadwaj198 authored Dec 24, 2024
1 parent 0e45ef0 commit bb41f16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- mainline
- releases/*
paths-ignore:
- '**.md'
workflow_dispatch:
Expand All @@ -19,7 +20,7 @@ on:

# Setting MAX_VERSIONS_TO_TEST, this can be a configurable value or if no input is provided, it can be a default value.
env:
MAX_VERSIONS_TO_TEST: ${{ github.event.inputs.max_versions_to_test || 3 }}
MAX_VERSIONS_TO_TEST: ${{ github.event.inputs.max_versions_to_test || 5 }}

jobs:
check-if-image-exists:
Expand Down
19 changes: 11 additions & 8 deletions tests/backwards_compatibility_tests/scripts/generate_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import subprocess
import sys

def generate_versions(to_version: str, num_versions: int = 3) -> list:
def generate_versions(to_version: str, num_minor_versions_to_test: int = 3) -> list:
"""
Generate a list of previous versions based on the target version.
This function generates a list of previous versions for a given target version.
It includes the previous patch version of the same minor version if applicable,
and the latest patch versions for preceding minor versions.
It includes all the previous patch versions of the same minor version if applicable,
and the latest patch versions for preceding minor versions of up to num_minor_versions_to_test.
Args:
to_version (str): The target version to generate previous versions for.
num_versions (int): The number of previous versions to generate. Defaults to 3.
num_minor_versions_to_test (int): The number of previous minor versions to generate. Defaults to 3.
Returns:
list: A list of previous versions as strings.
Expand All @@ -24,13 +24,16 @@ def generate_versions(to_version: str, num_versions: int = 3) -> list:

# If this is a patch release, add the previous patch version of the same minor version
if target_version.patch > 0:
prev_patch_version = f"{target_version.major}.{target_version.minor}.{target_version.patch - 1}"
versions.append(prev_patch_version)
versions.extend(
f"{target_version.major}.{target_version.minor}.{i}"
for i in range(target_version.patch - 1, -1, -1)
)

# Gather the latest patch version for each preceding minor version
minor = target_version.minor - 1
while len(versions) < num_versions and minor >= 0:
# Get all tags for the given minor version, sort, and pick the latest patch
for _ in range(num_minor_versions_to_test):
if minor < 0:
break
tags = subprocess.check_output(
["git", "tag", "--list", f"{target_version.major}.{minor}.*"],
text=True
Expand Down

0 comments on commit bb41f16

Please sign in to comment.