Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
99f16beb
Commit
99f16beb
authored
5 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[ci] Implements support for specific build-config and recipe-append files (closes bob/bob.conda#71)
parent
7fe864ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!78
Implements support for specific build-config and recipe-append files
Pipeline
#32277
passed
5 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/devtools/ci.py
+76
-0
76 additions, 0 deletions
bob/devtools/ci.py
bob/devtools/scripts/ci.py
+27
-56
27 additions, 56 deletions
bob/devtools/scripts/ci.py
with
103 additions
and
56 deletions
bob/devtools/ci.py
+
76
−
0
View file @
99f16beb
...
...
@@ -119,3 +119,79 @@ def uniq(seq, idfun=None):
seen
[
marker
]
=
1
result
.
append
(
item
)
return
result
def
select_build_file
(
basename
,
paths
,
branch
):
'''
Selects the file to use for a build
This method will return the name of the most adequate build-accessory file
(conda_build_config.yaml, recipe_append.yaml) for a given build, in this
order of priority:
1. The first file found is returned
2. We first search for a *specific* file if ``branch`` is set
3. If that file does not exist, returns the unbranded filename if that exists
in one of the paths
4. If no candidates exists, returns ``None``
The candidate filename is built using
``os.path.splitext(os.path.basename(basename))[0]``.
Args:
basename: Name of the file to use for the search
paths (list): A list of paths leading to the location of the variants file
to use. Priority is given to paths that come first
branch (str): Optional key to be set when searching for the variants file
to use. This is typically the git-branch name of the current branch of
the repo being built.
Returns:
str: A string containing the full, resolved path of the file to use.
Returns ``None``, if no candidate is found
'''
import
os
basename
,
extension
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
basename
))
if
branch
:
specific_basename
=
'
%s-%s
'
%
(
basename
,
branch
)
for
path
in
paths
:
path
=
os
.
path
.
realpath
(
path
)
candidate
=
os
.
path
.
join
(
path
,
'
%s%s
'
%
(
specific_basename
,
extension
))
if
os
.
path
.
exists
(
candidate
):
return
candidate
for
path
in
paths
:
path
=
os
.
path
.
realpath
(
path
)
candidate
=
os
.
path
.
join
(
path
,
'
%s%s
'
%
(
basename
,
extension
))
if
os
.
path
.
exists
(
candidate
):
return
candidate
def
select_conda_build_config
(
paths
,
branch
):
'''
Selects the default conda_build_config.yaml.
See :py:func:`select_build_file` for implementation details. If no build
config file is found by :py:func:`select_build_file`, then returns the
default ``conda_build_config.yaml`` shipped with this package.
'''
from
.constants
import
CONDA_BUILD_CONFIG
as
default
return
select_build_file
(
default
,
paths
,
branch
)
or
default
def
select_conda_recipe_append
(
paths
,
branch
):
'''
Selects the default recipe_append.yaml.
See :py:func:`select_build_file` for implementation details. If no recipe
append file is found by :py:func:`select_build_file`, then returns the
default ``recipe_append.yaml`` shipped with this package.
'''
from
.constants
import
CONDA_RECIPE_APPEND
as
default
return
select_build_file
(
default
,
paths
,
branch
)
or
default
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/ci.py
+
27
−
56
View file @
99f16beb
...
...
@@ -11,10 +11,10 @@ import pkg_resources
from
click_plugins
import
with_plugins
from
.
import
bdt
from
..constants
import
SERVER
,
CONDA_BUILD_CONFIG
,
CONDA_RECIPE_APPEND
,
\
WEBDAV_PATHS
,
BASE_CONDARC
from
..constants
import
SERVER
,
WEBDAV_PATHS
,
BASE_CONDARC
from
..deploy
import
deploy_conda_package
,
deploy_documentation
from
..ci
import
read_packages
,
comment_cleanup
,
uniq
from
..ci
import
read_packages
,
comment_cleanup
,
uniq
,
\
select_conda_build_config
,
select_conda_recipe_append
from
..log
import
verbosity_option
,
get_logger
,
echo_normal
logger
=
get_logger
(
__name__
)
...
...
@@ -329,14 +329,9 @@ def base_build(order, group, python, dry_run):
logger
.
info
(
'
Ignoring directory
"
%s
"
- no meta.yaml found
'
%
recipe
)
continue
# Use custom variants file if available on recipe-dir
variants_file
=
CONDA_BUILD_CONFIG
_candidate
=
os
.
path
.
join
(
recipe
,
'
conda_build_config.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
variants_file
=
_candidate
logger
.
warn
(
'
Using local conda_build_config.yaml from recipe-dir (%s)
'
\
'
instead of default variants file (%s)
'
,
variants_file
,
CONDA_BUILD_CONFIG
)
variants_file
=
select_conda_build_config
(
paths
=
[
recipe
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build configuration file: %s
'
,
variants_file
)
_build
(
bootstrap
=
bootstrap
,
...
...
@@ -380,21 +375,13 @@ def test(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir
=
os
.
path
.
join
(
os
.
path
.
realpath
(
os
.
curdir
),
'
conda
'
)
variants_file
=
CONDA_BUILD_CONFIG
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
conda_build_config.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
variants_file
=
_candidate
logger
.
warn
(
'
Using local conda_build_config.yaml from recipe-dir (%s)
'
\
'
instead of default variants file (%s)
'
,
variants_file
,
CONDA_BUILD_CONFIG
)
append_file
=
CONDA_RECIPE_APPEND
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
append_file.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
append_file
=
_candidate
logger
.
warn
(
'
Using local recipe_append.yaml from recipe-dir (%s)
'
\
'
instead of default append file (%s)
'
,
append_file
,
CONDA_RECIPE_APPEND
)
variants_file
=
select_conda_build_config
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build configuration file: %s
'
,
variants_file
)
append_file
=
select_conda_recipe_append
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build recipe-append file: %s
'
,
append_file
)
from
.test
import
test
ctx
.
invoke
(
test
,
...
...
@@ -442,21 +429,13 @@ def build(ctx, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir
=
os
.
path
.
join
(
os
.
path
.
realpath
(
os
.
curdir
),
'
conda
'
)
variants_file
=
CONDA_BUILD_CONFIG
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
conda_build_config.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
variants_file
=
_candidate
logger
.
warn
(
'
Using local conda_build_config.yaml from recipe-dir (%s)
'
\
'
instead of default variants file (%s)
'
,
variants_file
,
CONDA_BUILD_CONFIG
)
append_file
=
CONDA_RECIPE_APPEND
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
append_file.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
append_file
=
_candidate
logger
.
warn
(
'
Using local recipe_append.yaml from recipe-dir (%s)
'
\
'
instead of default append file (%s)
'
,
append_file
,
CONDA_RECIPE_APPEND
)
variants_file
=
select_conda_build_config
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build configuration file: %s
'
,
variants_file
)
append_file
=
select_conda_recipe_append
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build recipe-append file: %s
'
,
append_file
)
from
.build
import
build
ctx
.
invoke
(
build
,
...
...
@@ -573,21 +552,13 @@ def nightlies(ctx, order, dry_run):
# Use custom variants and append files if available on recipe-dir
recipe_dir
=
os
.
path
.
join
(
clone_to
,
'
conda
'
)
variants_file
=
CONDA_BUILD_CONFIG
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
conda_build_config.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
variants_file
=
_candidate
logger
.
warn
(
'
Using local conda_build_config.yaml from recipe-dir (%s)
'
\
'
instead of default variants file (%s)
'
,
variants_file
,
CONDA_BUILD_CONFIG
)
append_file
=
CONDA_RECIPE_APPEND
_candidate
=
os
.
path
.
join
(
recipe_dir
,
'
append_file.yaml
'
)
if
os
.
path
.
exists
(
_candidate
):
append_file
=
_candidate
logger
.
warn
(
'
Using local recipe_append.yaml from recipe-dir (%s)
'
\
'
instead of default append file (%s)
'
,
append_file
,
CONDA_RECIPE_APPEND
)
variants_file
=
select_conda_build_config
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build configuration file: %s
'
,
variants_file
)
append_file
=
select_conda_recipe_append
(
paths
=
[
recipe_dir
,
os
.
curdir
],
branch
=
os
.
environ
.
get
(
'
CI_COMMIT_REF_NAME
'
))
logger
.
info
(
'
Conda build recipe-append file: %s
'
,
append_file
)
ctx
.
invoke
(
build
,
recipe_dir
=
[
recipe_dir
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment