Skip to content

Commit

Permalink
Make compatibility tests run on releases branch and make them run on …
Browse files Browse the repository at this point in the history
…all previous patch versions (#1074)
  • Loading branch information
adityabharadwaj198 authored Dec 18, 2024
1 parent 0daa36b commit 59178e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 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 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 59178e3

Please sign in to comment.