Skip to content

Commit

Permalink
Merge pull request #1188 from consideRatio/pr/ci-speedup
Browse files Browse the repository at this point in the history
ci: refactor julia/r/conda tests - now ~25 min instead of ~50 min
  • Loading branch information
yuvipanda authored Oct 18, 2022
2 parents d7be04e + 1e4bc50 commit 380f817
Show file tree
Hide file tree
Showing 104 changed files with 284 additions and 361 deletions.
7 changes: 4 additions & 3 deletions docs/source/config_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ To install your repository like an R package, you may include a
``DESCRIPTION`` file. repo2docker installs the package and dependencies
from the ``DESCRIPTION`` by running ``devtools::install_local(getwd())``.

You also need to have a ``runtime.txt`` file that is formatted as
``r-<YYYY>-<MM>-<DD>``, where YYYY-MM-DD is a snapshot of MRAN that will be
used for your R installation.
You can also have have a ``runtime.txt`` file that is formatted as
``r-<YYYY>-<MM>-<DD>``, where YYYY-MM-DD is a snapshot of CRAN that will be used
for your R installation. If ``runtime.txt`` isn't provided in this case, a
recent date will be used.


.. _postBuild:
Expand Down
10 changes: 10 additions & 0 deletions repo2docker/buildpacks/julia/julia_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ def julia_version(self):
compat = project_toml["compat"]["julia"]
except:
# Default version which needs to be manually updated with new major.minor releases
#
# NOTE: Updates to the default version should go hand in hand with
# updates to tests/julia/project/verify where is intent to
# test the version.
#
# FIXME: When compat = "1.6" is set below and passed to
# find_semver_match, we get 1.8.2 as of 2022-10-09. We should
# clarify the desired behavior and have a unit test of
# find_semver_match to validate it.
#
compat = "1.6"

match = find_semver_match(compat, self.all_julias)
Expand Down
2 changes: 1 addition & 1 deletion repo2docker/buildpacks/r.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def r_version(self):
#
# NOTE: When updating this version, also update
# - tests/unit/test_r.py -> test_version_specification
# - tests/r/simple/verify
# - tests/r/r-rspm-apt/verify
#
r_version = version_map["4.2"]

Expand Down
63 changes: 63 additions & 0 deletions tests/conda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Overview of tests for the conda buildpack

## Tested configuration files

- [`.binder/`](https://repo2docker.readthedocs.io/en/latest/usage.html#where-to-put-configuration-files)
- [`requirements.txt`](https://repo2docker.readthedocs.io/en/latest/config_files.html#requirements-txt-install-a-python-environment)
- [`postBuild](https://repo2docker.readthedocs.io/en/latest/config_files.html#postbuild-run-code-after-installing-the-environment)

## Tested repo2docker command line flags

- [`--target-repo-dir`](https://repo2docker.readthedocs.io/en/latest/usage.html#cmdoption-jupyter-repo2docker-target-repo-dir)

### py2

- Test setup of a Python 2 environment by declaring `python=2` in
`environment.yml`.

### py35-binder-dir

- Test setup of a Python 3.5 environment by declaring `python=3.5` in
`environment.yml`.

The reasons for testing 3.5 specifically is that it is the oldest version of
Python 3 supported by repo2docker's conda buildpack. See
`repo2docker/buildpacks/conda` for details.

- Test use of a `.binder` directory.

### py310-requirements-file

- Test setup of a Python 3.10 environment by declaring `python=3.10` in
`environment.yml`.

The reasons for testing 3.10 specifically is that it is the newest version of
Python 3 supported by repo2docker's conda buildpack. See
`repo2docker/buildpacks/conda` for details.

- Test use of a `requirements.txt` file, where an `environment.yml` file should
take precedence and the `requirements.txt` should be ignored.

### py-r-postbuild-file

- Test setup of the default Python environment by omitting `python` from
`environment.yml` file.

- Test setup of the default R environment by specifying `r-base` in
`environment.yml`.

- Test use of a `postBuild` file.

### r3.6-target-repo-dir-flag

- Test setup of a R 3.6 environment by specifying `r-base=3.6` in
`environment.yml`.

- Test use of repo2docker with the `--target-repo-dir` flag.

`--target-repo-dir` is meant to support custom paths where repositories can be
copied to besides `${HOME}`.

This test makes use of the `test-extra-args.yaml` file to influence additional
arguments passed to `repo2docker` during the test. In this test, specify
`--target-repo-dir=/srv/repo`.
2 changes: 0 additions & 2 deletions tests/conda/binder-dir/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions tests/conda/binder-dir/environment.yml

This file was deleted.

6 changes: 0 additions & 6 deletions tests/conda/channel-dep/environment.yml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/channel-dep/verify

This file was deleted.

5 changes: 0 additions & 5 deletions tests/conda/default-env/postBuild

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/default-env/verify

This file was deleted.

13 changes: 0 additions & 13 deletions tests/conda/default-env/verify.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dependencies:
- numpy
- pytest
- r-base
- r-digest
2 changes: 2 additions & 0 deletions tests/conda/py-r-postbuild-file/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
pip install there
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

jupyter serverextension list 2>&1 | grep jupyter_server_proxy
jupyter nbextension list 2>&1 | grep jupyter_server_proxy
R -e "library('ggplot2')"
# Fail if version is not at least 4.1
R -e 'if (!(version$major == "4" && as.double(version$minor) >= 1)) quit("yes", 1)'

R -e "library('digest')"

# Fail if version is not at least 4.2
R --version
R -e 'if (!(version$major == "4" && as.double(version$minor) >= 2)) quit("yes", 1)'

pytest --verbose --color=yes ./verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@


def test_sys_version():
"""The default python version should be 3.7"""
assert sys.version_info[:2] == (3, 7)


def test_numpy():
import numpy
def test_there():
"""there is to be installed via postBuild"""
import there


def test_conda_activated():
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions tests/conda/py310-requirements-file/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- python=3.10
- numpy
- pip
- pip:
- simplejson
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import sys

assert sys.version_info[:2] == (3, 7), sys.version
assert sys.version_info[:2] == (3, 10), sys.version

import numpy

Expand Down
2 changes: 2 additions & 0 deletions tests/conda/py35-binder-dir/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file should be ignored because there's a dedicated binder folder
FROM doesntmatter
4 changes: 4 additions & 0 deletions tests/conda/py35-binder-dir/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file should be ignored as we have a dedicated binder folder.
dependencies:
- thiswontwork
invalid
File renamed without changes.
2 changes: 0 additions & 2 deletions tests/conda/py37/environment.yml

This file was deleted.

4 changes: 0 additions & 4 deletions tests/conda/py37/verify

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/py38/environment.yml

This file was deleted.

4 changes: 0 additions & 4 deletions tests/conda/py38/verify

This file was deleted.

3 changes: 0 additions & 3 deletions tests/conda/r-unspecified/environment.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies:
- r-base=3.6
- r-testthat
- r-digest
4 changes: 4 additions & 0 deletions tests/conda/r3.6-target-repo-dir-flag/test-extra-args.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is respected by repo2docker's test suite, but not repo2docker
# itself. It is used solely to help us test repo2docker's command line flags.
#
- --target-repo-dir=/srv/repo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

jupyter serverextension list 2>&1 | grep jupyter_server_proxy
jupyter nbextension list 2>&1 | grep jupyter_server_proxy
R -e "library('testthat')"
# Fail if version is not 3.6

R -e "library('digest')"

# Fail if R version is not 3.6
R --version
R -e 'if (!(version$major == "3" && as.double(version$minor) >= 6 && as.double(version$minor) < 7)) quit("yes", 1)'

./verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
assert sys.executable.startswith("/srv/conda/"), sys.executable

# Repo should be in /srv/repo
assert os.path.exists("/srv/repo/verify")
assert os.path.abspath(__file__) == "/srv/repo/verify"
assert os.path.exists("/srv/repo/verify.py")
assert os.path.abspath(__file__) == "/srv/repo/verify.py"

# Repo should be writable
assert os.access("/srv/repo", os.W_OK)

# We should be able to import the package in environment.yml
import numpy
3 changes: 0 additions & 3 deletions tests/conda/r4.0/environment.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tests/conda/r4.0/verify

This file was deleted.

3 changes: 0 additions & 3 deletions tests/conda/r4.1/environment.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tests/conda/r4.1/verify

This file was deleted.

8 changes: 0 additions & 8 deletions tests/conda/repo-path/README.rst

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/repo-path/environment.yml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/repo-path/extra-args.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions tests/conda/requirements/README.rst

This file was deleted.

4 changes: 0 additions & 4 deletions tests/conda/requirements/environment.yml

This file was deleted.

10 changes: 0 additions & 10 deletions tests/conda/simple-py2/README.rst

This file was deleted.

7 changes: 0 additions & 7 deletions tests/conda/simple/README.rst

This file was deleted.

2 changes: 0 additions & 2 deletions tests/conda/simple/verify

This file was deleted.

2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def collect(self):
args = ["--appendix", 'RUN echo "appendix" > /tmp/appendix']
# If there's an extra-args.yaml file in a test dir, assume it contains
# a yaml list with extra arguments to be passed to repo2docker
extra_args_path = os.path.join(self.fspath.dirname, "extra-args.yaml")
extra_args_path = os.path.join(self.fspath.dirname, "test-extra-args.yaml")
if os.path.exists(extra_args_path):
with open(extra_args_path) as f:
extra_args = yaml.safe_load(f)
Expand Down
38 changes: 38 additions & 0 deletions tests/julia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Overview of tests for the julia buildpack

## Tested configuration files

- [`Project.toml`](https://repo2docker.readthedocs.io/en/latest/config_files.html#project-toml-install-a-julia-environment)
- [`REQUIRE`](https://repo2docker.readthedocs.io/en/latest/config_files.html#require-install-a-julia-environment-legacy)
- [`requirements.txt`](https://repo2docker.readthedocs.io/en/latest/config_files.html#requirements-txt-install-a-python-environment)

## Test folders

### project

- Tests use of a `Project.toml` file for Julia, using the repo2docker default
version of Julia as specified in `julia_project.py`.

### project-1.0.2

- Tests use of a `Project.toml` file for Julia, using a version of Julia
specified via `julia = "=1.0.2"` in `Project.toml`'s `[compat]` section.

### require

- Tests use of a `REQUIRE` file for Julia, using the repo2docker default version
of Julia as specified in `julia_require.py`. Note that this is default version
is currently 0.6.4!

- Starting with Julia v0.7 and up, the package manager has changed, so this
tests that the Julia version below that can be installed correctly as well.

### require-1-requirements-file

- Tests use of a `REQUIRE` file for Julia, using a major version version
specification. Note that this major version specification is currently
resolving to a pinned minor and patch version as declared in
`julia_require.py`.

- Test use of a `requirements.txt` file, where it is expected to be respected
alongside the `REQUIRE` file.
Loading

0 comments on commit 380f817

Please sign in to comment.