Skip to content

Commit fb12357

Browse files
authored
Merge pull request #629 from bioconda/build-container-if-conda-dependent
build_recipes: enable container tests for conda-dependent recipes
2 parents 2b8a1b6 + 4e17bc1 commit fb12357

File tree

8 files changed

+72
-56
lines changed

8 files changed

+72
-56
lines changed

.circleci/config.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ variables:
4141
run:
4242
name: Build the updated docker container
4343
command: |
44-
docker build -t bioconda-utils-build-env:latest ./
45-
docker history bioconda-utils-build-env:latest
46-
docker run --rm -t bioconda-utils-build-env:latest sh -lec 'type -t conda && conda info -a && conda list'
44+
docker build -t bioconda/bioconda-utils-build-env:latest ./
45+
docker history bioconda/bioconda-utils-build-env:latest
46+
docker run --rm -t bioconda/bioconda-utils-build-env:latest sh -lec 'type -t conda && conda info -a && conda list'
47+
docker build -t bioconda/bioconda-utils-test-env:latest -f ./Dockerfile.test ./
4748
autobump_run: &autobump_run
4849
name: Check recipes for new upstream releases
4950
command: |
@@ -77,7 +78,7 @@ variables:
7778
name: Testing
7879
command: |
7980
if git diff --name-only origin/master...$CIRCLE_SHA1 | grep -vE ^docs; then
80-
py.test --durations=0 test/ -v --tb=native -m "${PY_TEST_MARKER}"
81+
py.test --durations=0 test/ -v --log-level=DEBUG --tb=native -m "${PY_TEST_MARKER}"
8182
else
8283
echo "Skipping pytest - only docs modified"
8384
fi
@@ -110,7 +111,7 @@ jobs:
110111
name: Testing
111112
command: |
112113
if git diff --name-only origin/master...$CIRCLE_SHA1 | grep -vE ^docs; then
113-
py.test --durations=0 test/ -v -k "not docker" --tb=native
114+
py.test --durations=0 test/ -v --log-level=DEBUG -k "not docker" --tb=native
114115
else
115116
echo "Skipping pytest - only docs modified"
116117
fi

.github/workflows/GithubActionTests.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919
python setup.py install
2020
- name: Build docker container
2121
run: |
22-
docker build -t bioconda-utils-build-env:latest ./
23-
docker history bioconda-utils-build-env:latest
24-
docker run --rm -t bioconda-utils-build-env:latest sh -lec 'type -t conda && conda info -a && conda list'
22+
docker build -t bioconda/bioconda-utils-build-env:latest ./
23+
docker history bioconda/bioconda-utils-build-env:latest
24+
docker run --rm -t bioconda/bioconda-utils-build-env:latest sh -lec 'type -t conda && conda info -a && conda list'
25+
docker build -t bioconda/bioconda-utils-test-env:latest -f ./Dockerfile.test ./
2526
- name: Run tests '${{ matrix.py_test_marker }}'
2627
run: |
2728
if git diff --name-only origin/master...HEAD | grep -vE ^docs; then
28-
py.test --durations=0 test/ -v --tb=native -m '${{ matrix.py_test_marker }}'
29+
py.test --durations=0 test/ -v --log-level=DEBUG --tb=native -m '${{ matrix.py_test_marker }}'
2930
else
3031
echo "Skipping pytest - only docs modified"
3132
fi
@@ -42,7 +43,7 @@ jobs:
4243
- name: Run tests
4344
run: |
4445
if git diff --name-only origin/master...HEAD | grep -vE ^docs; then
45-
py.test --durations=0 test/ -v -k "not docker" --tb=native
46+
py.test --durations=0 test/ -v --log-level=DEBUG -k "not docker" --tb=native
4647
else
4748
echo "Skipping pytest - only docs modified"
4849
fi

Dockerfile.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM bioconda/bioconda-utils-build-env
2+
# Retrieve index and set TTL to make it last over the duration of the test.
3+
RUN \
4+
conda search bioconda-utils > /dev/null && \
5+
conda config --set local_repodata_ttl 3600

bioconda_utils/bioconductor_skeleton.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def bioconductor_versions():
137137
"""
138138
url = "https://bioconductor.org/config.yaml"
139139
response = requests.get(url)
140-
bioc_config = yaml.load(response.text)
140+
bioc_config = yaml.safe_load(response.text)
141141
versions = list(bioc_config["r_ver_for_bioc_ver"].keys())
142142
# Handle semantic version sorting like 3.10 and 3.9
143143
versions = sorted(versions, key=lambda v: list(map(int, v.split('.'))), reverse=True)
@@ -174,7 +174,7 @@ def bioconductor_tarball_url(package, pkg_version, bioc_version):
174174
Bioconductor release version
175175
"""
176176
return (
177-
'http://bioconductor.org/packages/{bioc_version}'
177+
'https://bioconductor.org/packages/{bioc_version}'
178178
'/bioc/src/contrib/{package}_{pkg_version}.tar.gz'.format(**locals())
179179
)
180180

@@ -195,7 +195,7 @@ def bioconductor_annotation_data_url(package, pkg_version, bioc_version):
195195
Bioconductor release version
196196
"""
197197
return (
198-
'http://bioconductor.org/packages/{bioc_version}'
198+
'https://bioconductor.org/packages/{bioc_version}'
199199
'/data/annotation/src/contrib/{package}_{pkg_version}.tar.gz'.format(**locals())
200200
)
201201

@@ -216,7 +216,7 @@ def bioconductor_experiment_data_url(package, pkg_version, bioc_version):
216216
Bioconductor release version
217217
"""
218218
return (
219-
'http://bioconductor.org/packages/{bioc_version}'
219+
'https://bioconductor.org/packages/{bioc_version}'
220220
'/data/experiment/src/contrib/{package}_{pkg_version}.tar.gz'.format(**locals())
221221
)
222222

@@ -376,7 +376,7 @@ def __init__(self, package, bioc_version=None, pkg_version=None, packages=None):
376376
scraped data.
377377
>>> x = BioCProjectPage('DESeq2')
378378
>>> x.tarball_url
379-
'http://bioconductor.org/packages/release/bioc/src/contrib/DESeq2_1.8.2.tar.gz'
379+
'https://bioconductor.org/packages/release/bioc/src/contrib/DESeq2_1.8.2.tar.gz'
380380
"""
381381
self.base_url = base_url
382382
self.package = package

bioconda_utils/build.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ def conda_build_purge() -> None:
4646
utils.get_free_space())
4747

4848

49-
def has_conda_in_build(recipe):
50-
"""Checks if recipe has conda or conda build in deps"""
51-
deps = utils.get_deps(recipe, build=True)
52-
deps.update(utils.get_deps(recipe, build=False))
53-
return any(pkg in deps for pkg in ('conda', 'conda-build'))
54-
55-
5649
def build(recipe: str, pkg_paths: List[str] = None,
5750
testonly: bool = False, mulled_test: bool = True,
5851
channels: List[str] = None,
@@ -342,19 +335,10 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
342335
logger.info("Nothing to be done for recipe %s", recipe)
343336
continue
344337

345-
# If a recipe depends on conda, it means it must be installed in
346-
# the root env, which is not compatible with mulled-build tests. In
347-
# that case, we temporarily disable the mulled-build tests for the
348-
# recipe.
349-
keep_mulled_test = not has_conda_in_build(recipe)
350-
if mulled_test and not keep_mulled_test:
351-
logger.info('TEST SKIP: skipping mulled-build test for %s because it '
352-
'depends on conda or conda-build', recipe)
353-
354338
res = build(recipe=recipe,
355339
pkg_paths=pkg_paths,
356340
testonly=testonly,
357-
mulled_test=mulled_test and keep_mulled_test,
341+
mulled_test=mulled_test,
358342
channels=config['channels'],
359343
docker_builder=docker_builder,
360344
linter=linter)
@@ -370,7 +354,7 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
370354
for pkg in pkg_paths:
371355
if not upload.anaconda_upload(pkg, label=label):
372356
failed_uploads.append(pkg)
373-
if mulled_upload_target and keep_mulled_test:
357+
if mulled_upload_target:
374358
for img in res.mulled_images:
375359
upload.mulled_upload(img, mulled_upload_target)
376360

bioconda_utils/cran_skeleton.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@
2424
# Raw strings needed to support the awkward backslashes needed when adding the
2525
# command to yaml
2626
gpl2_short = r" license_family: GPL2"
27-
gpl2_long = (
28-
" license_family: GPL2\n license_file: '{{ environ[\"PREFIX\"] }}"
29-
"\/lib\/R\/share\/licenses\/GPL-2' # [unix]\n "
30-
"license_file: '{{ environ[\"PREFIX\"] }}"
31-
"\\\R\\\share\\\licenses\\\GPL-2' # [win]"
32-
)
27+
gpl2_long = r"""
28+
license_family: GPL2
29+
license_file: '{{ environ["PREFIX"] }}/lib/R/share/licenses/GPL-2' # [unix]
30+
license_file: '{{ environ["PREFIX"] }}\\R\\share\\licenses\\GPL-2' # [win]
31+
""".strip('\n')
3332

3433
gpl3_short = r" license_family: GPL3"
35-
gpl3_long = (
36-
" license_family: GPL3\n license_file: '{{ environ[\"PREFIX\"] }}"
37-
"\/lib\/R\/share\/licenses\/GPL-3' # [unix]\n "
38-
"license_file: '{{ environ[\"PREFIX\"] }}"
39-
"\\\R\\\share\\\licenses\\\GPL-3' # [win]"
40-
)
34+
gpl3_long = r"""
35+
license_family: GPL3
36+
license_file: '{{ environ["PREFIX"] }}/lib/R/share/licenses/GPL-3' # [unix]
37+
license_file: '{{ environ["PREFIX"] }}\\R\\share\\licenses\\GPL-3' # [win]
38+
""".strip('\n')
39+
4140
win32_string = 'number: 0\n skip: true # [win32]'
4241

4342

bioconda_utils/docker_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _build_image(self):
359359
except sp.CalledProcessError:
360360
logger.error('DOCKER FAILED: Error checking docker version.')
361361
raise
362-
p = re.compile("\d+\.\d+\.\d+") # three groups of at least on digit separated by dots
362+
p = re.compile(r"\d+\.\d+\.\d+") # three groups of at least on digit separated by dots
363363
version_string = re.search(p, s).group(0)
364364
if LooseVersion(version_string) >= LooseVersion("1.13.0"):
365365
cmd = [

test/test_utils.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# docker, once without). On OSX, only the non-docker runs.
3535

3636
# Docker ref for build container
37-
DOCKER_BASE_IMAGE = "bioconda/bioconda-utils-build-env:latest"
37+
DOCKER_BASE_IMAGE = "bioconda/bioconda-utils-test-env:latest"
3838

3939
SKIP_DOCKER_TESTS = sys.platform.startswith('darwin')
4040
SKIP_NOT_OSX = not sys.platform.startswith('darwin')
@@ -303,26 +303,47 @@ def test_get_deps():
303303
assert list(utils.get_deps(r.recipe_dirs['three'], build=False)) == ['two']
304304

305305

306-
def test_conda_as_dep(config_fixture):
306+
@pytest.mark.long_running_1
307+
@pytest.mark.parametrize('mulled_test', PARAMS, ids=IDS)
308+
def test_conda_as_dep(config_fixture, mulled_test):
309+
docker_builder = None
310+
if mulled_test:
311+
docker_builder = docker_utils.RecipeBuilder(
312+
use_host_conda_bld=True,
313+
docker_base_image=DOCKER_BASE_IMAGE,
314+
)
307315
r = Recipes(
308316
"""
309317
one:
310318
meta.yaml: |
311319
package:
312-
name: one
320+
name: bioconda_utils_test_conda_as_dep
313321
version: 0.1
314322
requirements:
323+
host:
324+
- conda
315325
run:
316326
- conda
327+
test:
328+
commands:
329+
- test -e "${PREFIX}/bin/conda"
317330
""", from_string=True)
318331
r.write_recipes()
319-
build_result = build.build_recipes(r.basedir, config_fixture,
320-
r.recipe_dirnames,
321-
testonly=False,
322-
force=False,
323-
mulled_test=True)
332+
build_result = build.build_recipes(
333+
r.basedir, config_fixture,
334+
r.recipe_dirnames,
335+
testonly=False,
336+
force=False,
337+
docker_builder=docker_builder,
338+
mulled_test=mulled_test,
339+
)
324340
assert build_result
325341

342+
for k, v in r.recipe_dirs.items():
343+
for i in utils.built_package_paths(v):
344+
assert os.path.exists(i)
345+
ensure_missing(i)
346+
326347
# TODO replace the filter tests with tests for utils.get_package_paths()
327348
# def test_filter_recipes_no_skipping():
328349
# """
@@ -581,7 +602,7 @@ def test_sandboxed():
581602

582603
def test_env_sandboxing():
583604
r = Recipes(
584-
"""
605+
r"""
585606
one:
586607
meta.yaml: |
587608
package:
@@ -596,7 +617,7 @@ def test_env_sandboxing():
596617
echo "\$GITHUB_TOKEN has leaked into the build environment!"
597618
exit 1
598619
fi
599-
""", from_string=True)
620+
""", from_string=True)
600621
r.write_recipes()
601622
pkg_paths = utils.built_package_paths(r.recipe_dirs['one'])
602623

@@ -749,6 +770,11 @@ def test_build_container_no_default_gcc(tmpdir):
749770
)
750771
assert build_result.success
751772

773+
for k, v in r.recipe_dirs.items():
774+
for i in utils.built_package_paths(v):
775+
assert os.path.exists(i)
776+
ensure_missing(i)
777+
752778

753779
# FIXME: This test fails erraticaly. Both in built_package_paths
754780
# and in build_recipes, the generated name can be either

0 commit comments

Comments
 (0)