Commit 466bb5ec authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF,ENH: Replacing build_conda_package.sh with build_conda_package.py.

Option to pre-build other packages before build - will be used by
trigger-downstream job.
parent ed0bf7e7
......@@ -87,9 +87,14 @@ update-conda-recipe:
# package is built from the git ref specified in the
# recipe meta.yaml file.
#
# These variables are forwarded to the deploy-conda-package job and
# check-downstream-packages jobs, which are both potentially run
# after this job.
# - PREBUILD: Passed to this job via the
# trigger-check-downstream-packages job, to trigger a
# build of the upstream package within the downstream build
# jobs.
#
# With the exception of PREBUILD, these variables are forwarded to the
# deploy-conda-package job and check-downstream-packages jobs, which are
# both potentially run after this job.
build-conda-package:
stage: fsl-ci-build
image: continuumio/miniconda3
......@@ -109,10 +114,11 @@ build-conda-package:
STAGING: ""
DEPLOY: "true"
PROJECT_REF: ""
PREBUILD: ""
script:
- bash /ci_rules/scripts/build_conda_package.sh
./conda_build "$PROJECT_REF" "$STAGING"
- bash /ci_rules/scripts/build_conda_package.py
./conda_build "$PROJECT_REF" "$STAGING" "$PREBUILD"
# We propagate the variables on
# to jobs in the deploy stage.
......@@ -128,6 +134,32 @@ build-conda-package:
dotenv: build.env
# Check downstream packages. This job is run on
# changes to any branch of a recipe repository,
# after the build-conda-package job. It triggers
# a test build of all packages which have a direct
# dependency on the package.
trigger-check-downstream-packages:
stage: fsl-ci-deploy
image: continuumio/miniconda3
allow_failure: true
tags:
- docker
# This job is run on branches
# of a recipe repository
rules:
- if: '$FSLCONDA_RECIPE != null &&
$CI_COMMIT_TAG == null &&
$CI_PIPELINE_SOURCE != "merge_request_event"'
dependencies:
- build-conda-package
script:
- bash /ci_rules/scripts/trigger_check_downstream_packages.py
# Deploy a built conda package to a locally-accessible
# conda channel directory. This job is run when commits
# are added to the master branch of a recipe repository,
......
#!/usr/bin/env python
#
# Build a conda package from a FSL recipe repository.
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
# This script must be passed the following aargments:
#
# - Output directory to store built conda package
#
# - Name of the git ref (e.g. tag, branch) to build the
# recipe from. If empty, ref specified in the recipe
# meta.yaml file is used.
#
# - An empty or non-empty value to indicate which
# FSL conda channel URL to download dependencies from.
# If empty, the FSLCONDA_PRODUCTION_CHANNEL_URL is
# used, otherwise the FSLCONDA_STAGING_CHANNEL_URL is
# used.
#
# - All other arguments
#
# (See rules/fsl-ci-conda-rules.yml)
import os
import sys
from fsl_ci_utils import sprun
def pre_build_recipe(url, ref, dest_dir):
pass
def main():
env = dict(os.environ)
output_dir = sys.argv[1]
project_ref = sys.argv[2]
staging = sys.argv[3]
prebuild = sys.argv[4].split()
prebuild = [p.split(';') for p in prebuild]
local_channel = './local_channel'
if staging == '':
channel_url = env['FSLCONDA_PRODUCTION_CHANNEL_URL']
else:
channel_url = env['FSLCONDA_STAGING_CHANNEL_URL']
if project_ref == '':
env.pop('FSLCONDA_REVISION')
else:
env['FSLCONDA_REVISION'] = project_ref
os.mkdir(local_channel)
for url, ref in prebuild:
pre_build_recipe(url, ref, local_channel)
print('************************************')
print(f'Building conda recipe for: {env["CI_PROJECT_NAME"]}')
print(f'Recipe URL: {env["CI_PROJECT_URL"]}')
print(f'Pre-built packages: {prebuild}')
print( 'Revision (empty means to build release')
print(f' specified in meta.yaml): {project_ref}')
print(f'FSL conda channel URL: {channel_url}')
print('************************************')
sprun(f'conda index {local_channel}')
sprun('conda install -y -c conda-forge conda-build')
sprun('conda build '
'-c conda-forge '
'-c defaults '
f'-c {local_channel} '
f'-c {channel_url} '
f'--output-folder={output_dir}'
'./', env=env)
if __name__ == '__main__':
main()
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