Commit a5352654 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Update recipe script can be called programmatically

parent 9e3b466d
......@@ -206,45 +206,59 @@ def checkout_and_rerender_recipe(recipe,
sprun(f'git push origin {branch}')
def main():
def main(server=None,
token=None,
project_path=None,
project_name=None,
project_ver=None):
"""Re-generates the conda recipe(s) associated with a FSL project. In
normal execution, all of the arguments are read from the environment.
:arg server: GitLab server url
:arg token: GitLab API access token
:arg project_path: GitLab project path
:arg project_name: Project name
:arg project_ver: New project tag
"""
if server is None: server = os.environ['CI_SERVER_URL']
if token is None: token = os.environ['FSL_CI_API_TOKEN']
if project_path is None: project_path = os.environ['CI_PROJECT_PATH']
if project_name is None: project_name = os.environ['CI_PROJECT_NAME']
if project_ver is None: project_ver = os.environ['CI_COMMIT_REF_NAME']
server = os.environ['CI_SERVER_URL']
token = os.environ['FSL_CI_API_TOKEN']
projpath = os.environ['CI_PROJECT_PATH']
projname = os.environ['CI_PROJECT_NAME']
projver = os.environ['CI_COMMIT_REF_NAME']
skip = os.environ.get('FSLCONDA_SKIP_RECIPE_UPDATE', None)
skip = os.environ.get('FSLCONDA_SKIP_RECIPE_UPDATE', None)
mrmsg = tw.dedent(f"""
This merge request was triggered by a new tag being added to
the {projpath} project.
the {project_path} project.
Accepting this merge request will cause the conda recipe for
{projpath} to be updated to version {projver}.
{project_path} to be updated to version {project_ver}.
If all goes well, a new conda package will built for
{projpath} ({projver}), and will be uploaded to
{project_path} ({project_ver}), and will be uploaded to
the FSL production conda channel.
(MR automatically generated by fsl-ci-rules running on the
{projpath} repository).
{project_path} repository).
""").strip()
recipes = get_recipe_urls(projname, server)
recipes = get_recipe_urls(project_name, server)
if skip is not None:
print('FSLCONDA_SKIP_RECIPE_UPDATE is set - aborting recipe update.')
sys.exit(0)
if not is_valid_project_version(projver):
print(f'{projver} is not a valid FSL version - aborting!')
if not is_valid_project_version(project_ver):
print(f'{project_ver} is not a valid FSL version - aborting!')
sys.exit(1)
for recipe in recipes:
recipe['id'] = lookup_project_id(recipe['path'], server, token)
branch = gen_branch_name(f'rel/{projver}',
branch = gen_branch_name(f'rel/{project_ver}',
recipe['path'],
server,
token)
......@@ -257,8 +271,8 @@ def main():
checkout_and_rerender_recipe(recipe,
branch,
projpath,
projver,
project_path,
project_ver,
server,
token)
......
......@@ -22,7 +22,7 @@ requirements:
- fsl-base >={{ fslbaseversion }}
{%- if dependencies -%}
{%- for dep, depver in dependencies %}
- {{ dep }} >={{ depver }}
- {{ dep }} {{ depver }}
{%- endfor -%}
{%- endif %}
build:
......
......@@ -13,7 +13,7 @@ requirements:
{%- if dependencies %}
run:
{%- for dep, depver in dependencies %}
- {{ dep }} >={{ depver }}
- {{ dep }} {{ depver }}
{%- endfor -%}
{%- endif %}
build:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment