Skip to content
Snippets Groups Projects
Commit 2b83523b authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'alt-nightlies' into 'master'

Add an alternative command to nightlies

See merge request !190
parents a1305e06 c16097d8
No related branches found
No related tags found
1 merge request!190Add an alternative command to nightlies
Pipeline #45408 passed
import click
from ..log import verbosity_option
from . import bdt
@click.command(
epilog="""
Examples:
1. Runs an alternate to nightly builds following a list of packages in a file:
$ bdt gitlab alt-nightlies -vv order.txt
2. Provide a list of key value pairs of arguments to be used as variables in the CI
$ bdt gitlab alt-nightlies -vv order.txt NOSE_EVAL_ATTR "not slow"
"""
)
@click.argument(
"order",
required=True,
type=click.Path(file_okay=True, dir_okay=False, exists=True),
nargs=1,
)
@click.argument(
"variables", nargs=-1,
)
@verbosity_option()
@bdt.raise_on_error
def alt_nightlies(order, variables):
"""Alternative nightlies.
This command should be run locally and not in Gitlab CI.
It will trigger a pipeline for each package in the order file
"""
if not variables:
variables = []
final_variables = []
for i, v in enumerate(variables):
if i % 2 == 1:
continue
final_variables.append({"key": v, "value": variables[i + 1]})
import time
from ..ci import read_packages
from ..log import get_logger
from ..release import get_gitlab_instance
logger = get_logger(__name__)
gl = get_gitlab_instance()
packages = read_packages(order)
for n, (package, branch) in enumerate(packages):
# trigger a pipeline for package and branch
project = gl.projects.get(package)
logger.info(
f"Creating a pipeline for {package} branch {branch} with variables {final_variables}"
)
pipeline = project.pipelines.create(
{"ref": branch, "variables": final_variables}
)
# wait for it to finish
while pipeline.status in ("pending", "running"):
time.sleep(3)
pipeline.refresh()
continue
if pipeline.status == "success":
continue
raise RuntimeError(f"Pipeline {pipeline.web_url} {pipeline.status}")
......@@ -243,6 +243,9 @@ def build(
continue
rendered_recipe = get_parsed_recipe(metadata)
logger.debug("Printing rendered recipe")
logger.debug("\n" + yaml.dump(rendered_recipe))
logger.debug("Finished printing rendered recipe")
path = get_output_path(metadata, conda_config)[0]
# gets the next build number
......
......@@ -109,6 +109,7 @@ test:
- bdt gitlab badges --help
- bdt sphinx --help
- bdt sphinx migrate-autodoc-flags --help
- bdt gitlab alt-nightlies --help
- sphinx-build -aEW ${PREFIX}/share/doc/{{ name }}/doc sphinx
{% if not os.path.exists('sphinx') %}
- if [ -n "${CI_PROJECT_DIR}" ]; then mv sphinx "${CI_PROJECT_DIR}/"; fi
......
......@@ -68,6 +68,7 @@ setup(
"get-pipelines = bob.devtools.scripts.pipelines:get_pipelines",
"graph = bob.devtools.scripts.graph:graph",
"update-bob = bob.devtools.scripts.update_bob:update_bob",
"alt-nightlies = bob.devtools.scripts.alternative_nightlies:alt_nightlies",
],
"bdt.ci.cli": [
"base-build = bob.devtools.scripts.ci:base_build",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment