Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F24780561
D259.1767160635.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D259.1767160635.diff
View Options
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,53 @@
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__(
+ self,
+ 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
+
+ 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__(
+ self,
+ 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 +510,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 +550,24 @@
# 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.addStepsAfterCurrentStep(EnsureLatestDirs(lbc=self.lbc, storage_dir=self.storage_dir)
+ self.build.addStepsAfterCurrentStep(MarkLatest(
+ lbc=self.lbc,
+ storage_dir=self.storage_dir,
+ buildid=self.build.buildid,
+ ref_name=latest_name,
+ is_good=True,
+ ))
+ self.build.addStepsAfterCurrentStep(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
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 30, 9:57 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
882653
Default Alt Text
D259.1767160635.diff (4 KB)
Attached To
Mode
D259: Mark artifacts latest on configured branches
Attached
Detach File
Event Timeline
Log In to Comment