Skip to content

Commit 48f8e76

Browse files
authored
fix nightly build helper methods (#1144)
2 parents d2faca5 + 2f0287d commit 48f8e76

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

.github/workflows/utils/nightly_build_helper.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _load_schedule(self):
3131
schedule.setdefault("active_nightly_builds", [])
3232
schedule.setdefault("patch_base_versions", [])
3333
schedule.setdefault("minor_base_versions", [])
34+
schedule.setdefault("major_base_versions", [])
3435
return schedule_var, schedule
3536
except Exception as e:
3637
print(f"Error loading schedule from GitHub: {e}")
@@ -72,10 +73,11 @@ def remove_version(self, version):
7273

7374
if version_obj.patch == 0: # Handling minor version
7475
# Remove previous minor version from minor_base_versions
75-
self.current_schedule["minor_base_versions"] = [
76-
v for v in self.current_schedule["minor_base_versions"]
77-
if not v.startswith(f"{version_obj.major}.{version_obj.minor-1}")
78-
]
76+
if version_obj.minor > 0:
77+
self.current_schedule["minor_base_versions"] = [
78+
v for v in self.current_schedule["minor_base_versions"]
79+
if not v.startswith(f"{version_obj.major}.{version_obj.minor-1}")
80+
]
7981
else: # Handling patch version
8082
prev_version = str(version_obj.replace(patch=version_obj.patch - 1))
8183
if prev_version in self.current_schedule["patch_base_versions"]:
@@ -99,11 +101,12 @@ def add_next_versions(self, version):
99101
self.current_schedule["active_nightly_builds"].extend(next_versions)
100102
self.current_schedule["patch_base_versions"].append(version)
101103
self.current_schedule["minor_base_versions"].append(version)
102-
prev_version = str(version_obj.replace(minor=version_obj.minor - 1))
103-
# If 2.2.0 is released, and 2.1.0 was the base for 3.0.0, now set 2.2.0 as base
104-
if prev_version in self.current_schedule["major_base_versions"]:
105-
self.current_schedule["major_base_versions"].remove(prev_version)
106-
self.current_schedule["major_base_versions"].append(version)
104+
if version_obj.minor > 0:
105+
prev_version = str(version_obj.replace(minor=version_obj.minor - 1))
106+
# If 2.2.0 is released, and 2.1.0 was the base for 3.0.0, now set 2.2.0 as base
107+
if prev_version in self.current_schedule["major_base_versions"]:
108+
self.current_schedule["major_base_versions"].remove(prev_version)
109+
self.current_schedule["major_base_versions"].append(version)
107110
else: # Handling patch version
108111
self.current_schedule["active_nightly_builds"].extend(next_versions)
109112
self.current_schedule["patch_base_versions"].append(version)

test/test_nightly_build_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"active_nightly_builds": ["2.6.2", "2.7.0", "3.0.2", "3.1.1", "3.2.0"],
1212
"patch_base_versions": ["2.6.1", "3.0.1", "3.1.0"],
1313
"minor_base_versions": ["2.6.1", "3.1.0"],
14+
"major_base_versions": [],
1415
}
1516

1617

0 commit comments

Comments
 (0)