diff --git a/nightlies/trigger_pipelines.py b/nightlies/trigger_pipelines.py index d2439da94b8129c981e1f6c7c2c6bf786d3b9137..7bf3dff7858adec29f33edc4d0aa748ac6c7a624 100755 --- a/nightlies/trigger_pipelines.py +++ b/nightlies/trigger_pipelines.py @@ -91,13 +91,16 @@ class Gitlab(object): pipeline = subprocess.check_output(cmd) return json.loads(pipeline.decode()) - def create_merge_request(self, project_id, source_branch, target_branch, title, - assignee_id='', description='', target_project_id='', - labels='', milestone_id='', remove_source_branch=''): + def create_merge_request(self, project_id, source_branch, target_branch, + title, assignee_id='', description='', + target_project_id='', labels='', milestone_id='', + remove_source_branch=''): url = "projects/{}/merge_requests?" - url += "&".join(['source_branch={}', 'target_branch={}', 'title={}']) - url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}', - 'labels={}', 'milestone_id={}', 'remove_source_branch={}']) + url += "&".join( + ['source_branch={}', 'target_branch={}', 'title={}']) + url += "&".join( + ['assignee_id={}', 'description={}', 'target_project_id={}', + 'labels={}', 'milestone_id={}', 'remove_source_branch={}']) url = url.format(project_id, source_branch, target_branch, title, assignee_id, description, target_project_id, labels, milestone_id, remove_source_branch) @@ -107,6 +110,14 @@ class Gitlab(object): pipeline = subprocess.check_output(cmd) return json.loads(pipeline.decode()) + def get_tags(self, project_id): + cmd = ["curl", "--header", + "PRIVATE-TOKEN: {}".format(self.token), + self.base_url + "projects/{}/repository/tags".format( + project_id)] + pipeline = subprocess.check_output(cmd) + return json.loads(pipeline.decode()) + def main(packages_list): gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN')) @@ -128,6 +139,43 @@ def main(packages_list): return +def generate_bob_changelog(): + def get_changelog(pkg, tag): + changelog = '' + if tag['release'] is None: + return changelog + changelog += '{} {}\n'.format(pkg, tag['name']) + changelog += '{}\n'.format(tag['release']['description']) + return changelog + + gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN')) + changelog = '' + for package in ['bob.extension', 'bob.blitz', 'bob.core', 'bob.io.base', + 'bob.sp', 'bob.ap', 'bob.math', 'bob.measure', + 'bob.db.base', 'bob.io.audio', 'bob.io.image', + 'bob.io.video', 'bob.io.matlab', 'bob.ip.base', + 'bob.ip.color', 'bob.ip.draw', 'bob.ip.gabor', + 'bob.learn.activation', 'bob.learn.libsvm', + 'bob.learn.linear', 'bob.learn.mlp', 'bob.learn.em', + 'bob.learn.boosting', 'bob.db.iris', 'bob.db.wine', + 'bob.db.mnist', 'bob.db.atnt', 'bob.ip.facedetect', + 'bob.ip.optflow.hornschunck', 'bob.ip.optflow.liu', + 'bob.ip.flandmark', ]: + pid = PACKAGES_ID.get(package) + if pid is None: + pid = gitlab.get_project(package)['id'] + print('Getting tag info for {}'.format(package)) + tags = gitlab.get_tags(pid) + tags = sorted(tags, key=lambda x: x['commit']['authored_date']) + # if some packages have seen two releases since the last version of + # bob: + # if package in ('bob.io.video', 'bob.ip.gabor'): + # changelog += get_changelog(package, tags[-2]) + changelog += get_changelog(package, tags[-1]) + + print(changelog) + + if __name__ == '__main__': arguments = docopt(__doc__.format(sys.argv[0]), version='Nightlies 0.0.1') print(arguments)