mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
NodeVersion: Fix comparision in CI
When tests CI on occur the version number has the following shape "1a86e50-modded". We will always assume this is the latest version to make the version checks pass
This commit is contained in:
parent
ea4ff32616
commit
03e7a03a09
2 changed files with 21 additions and 0 deletions
|
@ -6,6 +6,9 @@ import re
|
|||
from typing import List, Optional, Protocol, runtime_checkable, Union
|
||||
|
||||
|
||||
_MODDED_PATTERN = "[0-9a-f]+-modded"
|
||||
|
||||
|
||||
@total_ordering
|
||||
@dataclass
|
||||
class NodeVersion:
|
||||
|
@ -51,6 +54,11 @@ class NodeVersion:
|
|||
other = NodeVersion(other)
|
||||
if not isinstance(other, NodeVersion):
|
||||
return False
|
||||
|
||||
if self.strict_equal(other):
|
||||
return True
|
||||
elif re.match(_MODDED_PATTERN, self.version):
|
||||
return False
|
||||
else:
|
||||
self_parts = [p.num for p in self.to_parts()]
|
||||
other_parts = [p.num for p in other.to_parts()]
|
||||
|
@ -68,6 +76,13 @@ class NodeVersion:
|
|||
other = NodeVersion(other)
|
||||
if not isinstance(other, NodeVersion):
|
||||
return NotImplemented
|
||||
|
||||
# If we are in CI the version will by a hex ending on modded
|
||||
# We will assume it is the latest version
|
||||
if re.match(_MODDED_PATTERN, self.version):
|
||||
return False
|
||||
elif re.match(_MODDED_PATTERN, other.version):
|
||||
return True
|
||||
else:
|
||||
self_parts = [p.num for p in self.to_parts()]
|
||||
other_parts = [p.num for p in other.to_parts()]
|
||||
|
|
|
@ -83,3 +83,9 @@ def test_compare_spec_from_string():
|
|||
|
||||
assert not list_spec.matches("v24.02rc1")
|
||||
assert not list_spec.matches("v23.11")
|
||||
|
||||
|
||||
def test_ci_modded_version_is_always_latest():
|
||||
v1 = NodeVersion("1a86e50-modded")
|
||||
|
||||
assert v1 > NodeVersion("v24.02")
|
||||
|
|
Loading…
Add table
Reference in a new issue