Run builder when source is changed.

This commit is contained in:
Nikhil Badyal
2024-04-28 17:40:23 +05:30
committed by Nikhil Badyal
parent 5895e8ca60
commit d276696689
4 changed files with 28 additions and 4 deletions
+13 -1
View File
@@ -10,7 +10,7 @@ from environs import Env
from src.app import APP
from src.manager.release_manager import ReleaseManager
from src.utils import branch_name, updates_file, updates_file_url
from src.utils import app_dump_key, branch_name, updates_file, updates_file_url
class GitHubManager(ReleaseManager):
@@ -34,3 +34,15 @@ class GitHubManager(ReleaseManager):
if data.get(app.app_name):
return str(data[app.app_name][resource_name])
return "0"
def get_last_version_source(self: Self, app: APP, resource_name: str) -> str:
"""Get last patched version."""
if os.getenv("DRY_RUN", default=None):
with Path(updates_file).open() as url:
data = json.load(url)
else:
with urllib.request.urlopen(self.update_file_url) as url:
data = json.load(url)
if data.get(app.app_name):
return str(data[app.app_name][app_dump_key][resource_name])
return "0"
+4 -1
View File
@@ -15,8 +15,11 @@ class ReleaseManager(object):
"""Get last patched version."""
raise NotImplementedError
def should_trigger_build(self: Self, old_version: str, new_version: str) -> bool:
def should_trigger_build(self: Self, old_version: str, old_source: str, new_version: str, new_source: str) -> bool:
"""Function to check if we should trigger a build."""
if old_source != new_source:
logger.info(f"Trigger build because old source {old_source}, is different from new source {new_source}")
return True
logger.info(f"New version {new_version}, Old version {old_version}")
try:
return Version(new_version) > Version(old_version) # type: ignore[no-any-return]
+3
View File
@@ -59,6 +59,9 @@ implement_method = "Please implement the method"
status_code_200 = 200
resource_folder = "apks"
branch_name = "changelogs"
app_dump_key = "app_dump"
patches_dl_key = "patches_dl"
integrations_dl_key = "integrations_dl"
def update_changelog(name: str, response: dict[str, str]) -> None: