Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #39 from mvdbeek/mulled_mount_test_files
Browse files Browse the repository at this point in the history
Add possibility to mount in test-files during conda testing
  • Loading branch information
bgruening committed Jan 3, 2017
2 parents 7b37ae3 + 1b59eea commit d1c1602
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
22 changes: 18 additions & 4 deletions galaxy/tools/deps/mulled/invfile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ for i = 1, #binds_table do
table.insert(bind_args, binds_table[i])
end

local test_bind_args = {}
local test_binds_table = VAR.TEST_BINDS:split(",")
for i = 1, #test_binds_table do
table.insert(test_bind_args, test_binds_table[i])
end

inv.task('build')
.using('continuumio/miniconda:latest')
.withHostConfig({binds = {"build:/data"}})
Expand All @@ -49,10 +55,18 @@ inv.task('build')
.inImage('bgruening/busybox-bash:0.1')
.as(repo)

inv.task('test')
.using(repo)
.withConfig({entrypoint = {'/bin/sh', '-c'}})
.run(VAR.TEST)
if VAR.TEST_BINDS == '' then
inv.task('test')
.using(repo)
.withConfig({entrypoint = {'/bin/sh', '-c'}})
.run(VAR.TEST)
else
inv.task('test')
.using(repo)
.withHostConfig({binds = test_bind_args})
.withConfig({entrypoint = {'/bin/sh', '-c'}})
.run(VAR.TEST)
end

inv.task('push')
.push(repo)
Expand Down
20 changes: 19 additions & 1 deletion galaxy/tools/deps/mulled/mulled_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
DEFAULT_CHANNELS = [DEFAULT_CHANNEL] + DEFAULT_EXTRA_CHANNELS
DEFAULT_REPOSITORY_TEMPLATE = "quay.io/${namespace}/${image}"
DEFAULT_BINDS = ["build/dist:/usr/local/"]
DEFAULT_WORKING_DIR = '/source/'
IS_OS_X = _platform == "darwin"
INVOLUCRO_VERSION = "1.1.2"

Expand Down Expand Up @@ -113,7 +114,7 @@ def conda_versions(pkg_name, file_name):
def mull_targets(
targets, involucro_context=None,
command="build", channels=DEFAULT_CHANNELS, namespace="mulled",
test='true', image_build=None, name_override=None,
test='true', test_files=None, image_build=None, name_override=None,
repository_template=DEFAULT_REPOSITORY_TEMPLATE, dry_run=False,
binds=DEFAULT_BINDS
):
Expand Down Expand Up @@ -144,6 +145,18 @@ def mull_targets(
'-set', "BINDS='%s'" % bind_str,
command,
]
if test_files:
test_bind = []
for test_file in test_files:
if ':' not in test_file:
if os.path.exists(test_file):
test_bind.append("%s:%s/%s" % (test_file, DEFAULT_WORKING_DIR, test_file))
else:
if os.path.exists(test_file.split(':')[0]):
test_bind.append(test_file)
if test_bind:
involucro_args.insert(6, '-set')
involucro_args.insert(7, "TEST_BINDS='%s'" % ",".join(test_bind))
print(" ".join(involucro_context.build_command(involucro_args)))
if not dry_run:
ensure_installed(involucro_context, True)
Expand Down Expand Up @@ -252,6 +265,9 @@ def args_to_mull_targets_kwds(args):
kwds["dry_run"] = args.dry_run
if hasattr(args, "test"):
kwds["test"] = args.test
if hasattr(args, "test_files"):
if args.test_files:
kwds["test_files"] = args.test_files.split(",")
if hasattr(args, "channel"):
channels = [args.channel]
if hasattr(args, "extra_channels"):
Expand All @@ -276,6 +292,8 @@ def main(argv=None):
parser.add_argument('targets', metavar="TARGETS", default=None, help="Build a single container with specific package(s).")
parser.add_argument('--repository-name', dest="repository_name", default=None, help="Name of mulled container (leave blank to auto-generate based on packages - recommended).")
parser.add_argument('--test', help='Provide a test command for the container.')
parser.add_argument('--test-files', help='Provide test-files that may be required to run the test command. Individual mounts are separated by comma.'
'The source:dest docker syntax is respected. If relative file paths are given, files will be mounted in /source/<relative_file_path>')
args = parser.parse_args()
targets = target_str_to_targets(args.targets)
sys.exit(mull_targets(targets, **args_to_mull_targets_kwds(args)))
Expand Down

0 comments on commit d1c1602

Please sign in to comment.