Page MenuHomePhorge

D259.1767170217.diff
No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None

D259.1767170217.diff

diff --git a/lilybuild/lilybuild/ci_steps.py b/lilybuild/lilybuild/ci_steps.py
--- a/lilybuild/lilybuild/ci_steps.py
+++ b/lilybuild/lilybuild/ci_steps.py
@@ -376,6 +376,52 @@
return ret
+class LatestMixin:
+ latest_build_dir_pattern = '%(kw:st)s/repos/%(prop:lilybuild_repo_id)s/latest'
+ latest_good_build_dir_pattern = '%(kw:st)s/repos/%(prop:lilybuild_repo_id)s/latest-good'
+ latest_name_pattern = '%(kw:st)s/repos/%(prop:lilybuild_repo_id)s/latest/%(kw:name)s'
+ latest_good_name_pattern = '%(kw:st)s/repos/%(prop:lilybuild_repo_id)s/latest-good/%(kw:name)s'
+
+class EnsureLatestDirs(steps.MasterShellCommand, LatestMixin):
+ def __init__(self, lbc, storage_dir, **kwargs):
+ self.lbc = lbc
+ self.storage_dir = storage_dir
+ command = util.Transform(
+ fill_list,
+ 'mkdir',
+ '-pv',
+ util.Interpolate(self.latest_build_dir_pattern, st=self.storage_dir),
+ util.Interpolate(self.latest_good_build_dir_pattern, st=self.storage_dir))
+ super().__init__(
+ name='Ensure latest dirs',
+ command=command,
+ logEnviron=False,
+ doStepIf=on_always,
+ **kwargs
+ )
+
+class MarkLatest(steps.MasterShellCommand, LatestMixin):
+ def __init__(self, lbc, storage_dir, buildid, ref_name, is_good, **kwargs):
+ self.lbc = lbc
+ self.storage_dir = storage_dir
+
+ name_pattern = self.latest_good_name_pattern if is_good else self.latest_name_pattern
+
+ command = util.Transform(
+ fill_list,
+ 'ln',
+ '-sfvn',
+ util.Interpolate('../builds/%(kw:buildid)s', buildid=buildid),
+ util.Interpolate(name_pattern, st=self.storage_dir, name=ref_name),
+ )
+ super().__init__(
+ name='Mark build as latest-good' if is_good else 'Mark build as latest',
+ command=command,
+ logEnviron=False,
+ doStepIf=on_success if is_good else on_always,
+ **kwargs
+ )
+
class AnalyzeCIFileCommand(buildstep.ShellMixin, steps.BuildStep):
ci_def_file = '.gitlab-ci.yml'
build_target_prop_name = 'harbormaster_build_target_phid'
@@ -463,6 +509,9 @@
return (ref, ref_type)
+ def get_cur_repo_config(self):
+ return self.lbc.repos[self.getProperty('lilybuild_repo_id')]
+
@defer.inlineCallbacks
def get_pipeline_ci_vars(self):
url = yield self.build.getUrl()
@@ -500,4 +549,26 @@
# create a ShellCommand for each stage and add them to the build
self.build.addStepsAfterCurrentStep(self.get_steps(self.observer.getStdout()))
+ latest_branch_map = self.get_cur_repo_config()['artifact_latest_branch_map']
+ ref, _ref_type = self.get_ref_and_type()
+ if ref in latest_branch_map:
+ latest_name = latest_branch_map[ref]
+ self.build.addStepsAfterLastStep([
+ EnsureLatestDirs(lbc=self.lbc, storage_dir=self.storage_dir),
+ MarkLatest(
+ lbc=self.lbc,
+ storage_dir=self.storage_dir,
+ buildid=self.build.buildid,
+ ref_name=latest_name,
+ is_good=True,
+ ),
+ MarkLatest(
+ lbc=self.lbc,
+ storage_dir=self.storage_dir,
+ buildid=self.build.buildid,
+ ref_name=latest_name,
+ is_good=False,
+ ),
+ ])
+
return result
diff --git a/lilybuild/lilybuild/config.py b/lilybuild/lilybuild/config.py
--- a/lilybuild/lilybuild/config.py
+++ b/lilybuild/lilybuild/config.py
@@ -155,6 +155,7 @@
variables_getter=None,
artifact_compressed_limit=None,
artifact_uncompressed_limit=None,
+ artifact_latest_branch_map=None,
):
if not alternative_urls:
alternative_urls = []
@@ -169,6 +170,7 @@
'variables_getter': variables_getter or (lambda _build: {}),
'artifact_compressed_limit': artifact_compressed_limit or self.artifact_compressed_limit,
'artifact_uncompressed_limit': artifact_uncompressed_limit or self.artifact_uncompressed_limit,
+ 'artifact_latest_branch_map': artifact_latest_branch_map or {},
}
self.record_url(repo_id, repo_url)
for u in alternative_urls:

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 31, 12:36 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
883239
Default Alt Text
D259.1767170217.diff (4 KB)

Event Timeline