From f69d65feb93814bf3caafa17a01bbb306e317d62 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 9 Oct 2022 13:28:40 +0200 Subject: [PATCH] ci: refactor conda tests, from 11 to 6 (~20 min saved) --- tests/conda/binder-dir/Dockerfile | 2 -- tests/conda/binder-dir/environment.yml | 3 --- tests/conda/default-env/postBuild | 5 ----- tests/conda/default-env/verify.py | 13 ------------- tests/conda/py-postbuild/README.rst | 6 ++++++ .../{simple => py-postbuild}/environment.yml | 0 tests/conda/py-postbuild/postBuild | 2 ++ .../conda/{default-env => py-postbuild}/verify | 0 tests/conda/{simple => py-postbuild}/verify.py | 4 ++++ tests/conda/py2/README.rst | 4 ++++ tests/conda/{simple-py2 => py2}/environment.yml | 0 tests/conda/{simple-py2 => py2}/verify | 0 tests/conda/py310-requirements-file/README.rst | 17 +++++++++++++++++ .../environment.yml | 1 + .../requirements.txt | 0 .../verify | 2 +- tests/conda/py310/environment.yml | 2 -- tests/conda/py310/verify | 4 ---- .../.binder}/environment.yml | 0 tests/conda/py35-binder-dir/Dockerfile | 2 ++ tests/conda/py35-binder-dir/README.rst | 9 +++++++++ tests/conda/py35-binder-dir/environment.yml | 4 ++++ .../{binder-dir => py35-binder-dir}/verify | 0 tests/conda/py37/environment.yml | 2 -- tests/conda/py37/verify | 4 ---- tests/conda/r/README.rst | 5 +++++ .../conda/{r-unspecified => r}/environment.yml | 2 +- tests/conda/{r-unspecified => r}/verify | 9 ++++++--- tests/conda/r3.6-extra-args/README.rst | 7 +++++++ .../{r3.6 => r3.6-extra-args}/environment.yml | 2 +- .../extra-args.yaml | 0 tests/conda/{r3.6 => r3.6-extra-args}/verify | 7 ++++++- .../verify => r3.6-extra-args/verify.py} | 3 --- tests/conda/r4.2/environment.yml | 3 --- tests/conda/r4.2/verify | 7 ------- tests/conda/repo-path/README.rst | 8 -------- tests/conda/repo-path/environment.yml | 2 -- tests/conda/requirements/README.rst | 13 ------------- tests/conda/simple-py2/README.rst | 10 ---------- tests/conda/simple/README.rst | 7 ------- tests/conda/simple/verify | 2 -- 41 files changed, 76 insertions(+), 97 deletions(-) delete mode 100644 tests/conda/binder-dir/Dockerfile delete mode 100644 tests/conda/binder-dir/environment.yml delete mode 100644 tests/conda/default-env/postBuild delete mode 100755 tests/conda/default-env/verify.py create mode 100644 tests/conda/py-postbuild/README.rst rename tests/conda/{simple => py-postbuild}/environment.yml (100%) create mode 100644 tests/conda/py-postbuild/postBuild rename tests/conda/{default-env => py-postbuild}/verify (100%) rename tests/conda/{simple => py-postbuild}/verify.py (88%) create mode 100644 tests/conda/py2/README.rst rename tests/conda/{simple-py2 => py2}/environment.yml (100%) rename tests/conda/{simple-py2 => py2}/verify (100%) create mode 100644 tests/conda/py310-requirements-file/README.rst rename tests/conda/{requirements => py310-requirements-file}/environment.yml (75%) rename tests/conda/{requirements => py310-requirements-file}/requirements.txt (100%) rename tests/conda/{requirements => py310-requirements-file}/verify (78%) delete mode 100644 tests/conda/py310/environment.yml delete mode 100755 tests/conda/py310/verify rename tests/conda/{binder-dir/binder => py35-binder-dir/.binder}/environment.yml (100%) create mode 100644 tests/conda/py35-binder-dir/Dockerfile create mode 100644 tests/conda/py35-binder-dir/README.rst create mode 100644 tests/conda/py35-binder-dir/environment.yml rename tests/conda/{binder-dir => py35-binder-dir}/verify (100%) delete mode 100644 tests/conda/py37/environment.yml delete mode 100755 tests/conda/py37/verify create mode 100644 tests/conda/r/README.rst rename tests/conda/{r-unspecified => r}/environment.yml (64%) rename tests/conda/{r-unspecified => r}/verify (66%) create mode 100644 tests/conda/r3.6-extra-args/README.rst rename tests/conda/{r3.6 => r3.6-extra-args}/environment.yml (65%) rename tests/conda/{repo-path => r3.6-extra-args}/extra-args.yaml (100%) rename tests/conda/{r3.6 => r3.6-extra-args}/verify (84%) rename tests/conda/{repo-path/verify => r3.6-extra-args/verify.py} (86%) mode change 100755 => 100644 delete mode 100644 tests/conda/r4.2/environment.yml delete mode 100755 tests/conda/r4.2/verify delete mode 100644 tests/conda/repo-path/README.rst delete mode 100644 tests/conda/repo-path/environment.yml delete mode 100644 tests/conda/requirements/README.rst delete mode 100644 tests/conda/simple-py2/README.rst delete mode 100644 tests/conda/simple/README.rst delete mode 100755 tests/conda/simple/verify diff --git a/tests/conda/binder-dir/Dockerfile b/tests/conda/binder-dir/Dockerfile deleted file mode 100644 index a742a181..00000000 --- a/tests/conda/binder-dir/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM doesntmatter -# this file should be ignored because there's a binder dir diff --git a/tests/conda/binder-dir/environment.yml b/tests/conda/binder-dir/environment.yml deleted file mode 100644 index e0dd2271..00000000 --- a/tests/conda/binder-dir/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: - - thiswontwork - invalid diff --git a/tests/conda/default-env/postBuild b/tests/conda/default-env/postBuild deleted file mode 100644 index 980d00a0..00000000 --- a/tests/conda/default-env/postBuild +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# install pytest with conda in the default env (should be $KERNEL_PYTHON_PREFIX) -conda install -yq pytest -# install there with pip (should be the same) -pip install there diff --git a/tests/conda/default-env/verify.py b/tests/conda/default-env/verify.py deleted file mode 100755 index ef35812e..00000000 --- a/tests/conda/default-env/verify.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -import os -import sys - - -def test_sys_prefix(): - # verify that pytest was installed in the notebook env - assert sys.prefix == os.environ["KERNEL_PYTHON_PREFIX"] - - -def test_there(): - # verify that there was installed in the notebook env - import there diff --git a/tests/conda/py-postbuild/README.rst b/tests/conda/py-postbuild/README.rst new file mode 100644 index 00000000..a0a82bb0 --- /dev/null +++ b/tests/conda/py-postbuild/README.rst @@ -0,0 +1,6 @@ +Default Python, and an postBuild file +------------------------------------- + +We test the default Python version set by repo2docker as used when an +environment.yml file is provided without a ``python`` dependency, and the use of +a ``postBuild`` file. diff --git a/tests/conda/simple/environment.yml b/tests/conda/py-postbuild/environment.yml similarity index 100% rename from tests/conda/simple/environment.yml rename to tests/conda/py-postbuild/environment.yml diff --git a/tests/conda/py-postbuild/postBuild b/tests/conda/py-postbuild/postBuild new file mode 100644 index 00000000..0d1a4334 --- /dev/null +++ b/tests/conda/py-postbuild/postBuild @@ -0,0 +1,2 @@ +#!/bin/bash +pip install there diff --git a/tests/conda/default-env/verify b/tests/conda/py-postbuild/verify similarity index 100% rename from tests/conda/default-env/verify rename to tests/conda/py-postbuild/verify diff --git a/tests/conda/simple/verify.py b/tests/conda/py-postbuild/verify.py similarity index 88% rename from tests/conda/simple/verify.py rename to tests/conda/py-postbuild/verify.py index bc6381c0..dc80f471 100755 --- a/tests/conda/simple/verify.py +++ b/tests/conda/py-postbuild/verify.py @@ -11,6 +11,10 @@ def test_numpy(): import numpy +def test_there(): + import there + + def test_conda_activated(): assert os.environ.get("CONDA_PREFIX") == os.environ["NB_PYTHON_PREFIX"], dict( os.environ diff --git a/tests/conda/py2/README.rst b/tests/conda/py2/README.rst new file mode 100644 index 00000000..d0459de9 --- /dev/null +++ b/tests/conda/py2/README.rst @@ -0,0 +1,4 @@ +Python 2 +-------- + +Test setup of a Python 2 environment. diff --git a/tests/conda/simple-py2/environment.yml b/tests/conda/py2/environment.yml similarity index 100% rename from tests/conda/simple-py2/environment.yml rename to tests/conda/py2/environment.yml diff --git a/tests/conda/simple-py2/verify b/tests/conda/py2/verify similarity index 100% rename from tests/conda/simple-py2/verify rename to tests/conda/py2/verify diff --git a/tests/conda/py310-requirements-file/README.rst b/tests/conda/py310-requirements-file/README.rst new file mode 100644 index 00000000..fc5b564b --- /dev/null +++ b/tests/conda/py310-requirements-file/README.rst @@ -0,0 +1,17 @@ +Python 3.10 (latest), and an ignored requirements file +------------------------------------------------------ + +The reasons for testing 3.10 specifically is that it is the latest version of +Python 3 supported by repo2docker's conda buildpack. See +``repo2docker/buildpacks/conda`` for details. + +An ``environment.yml`` file takes precedence over ``requirements.txt``. +To install Python packages into a conda environment with pip, use the +``pip`` key in ``environment.yml``: + +.. sourcecode:: yaml + + dependencies: + - numpy + - pip: + - tornado diff --git a/tests/conda/requirements/environment.yml b/tests/conda/py310-requirements-file/environment.yml similarity index 75% rename from tests/conda/requirements/environment.yml rename to tests/conda/py310-requirements-file/environment.yml index fa9404c5..810a05d0 100644 --- a/tests/conda/requirements/environment.yml +++ b/tests/conda/py310-requirements-file/environment.yml @@ -1,4 +1,5 @@ dependencies: + - python=3.10 - numpy - pip: - simplejson diff --git a/tests/conda/requirements/requirements.txt b/tests/conda/py310-requirements-file/requirements.txt similarity index 100% rename from tests/conda/requirements/requirements.txt rename to tests/conda/py310-requirements-file/requirements.txt diff --git a/tests/conda/requirements/verify b/tests/conda/py310-requirements-file/verify similarity index 78% rename from tests/conda/requirements/verify rename to tests/conda/py310-requirements-file/verify index c4767a00..62273550 100755 --- a/tests/conda/requirements/verify +++ b/tests/conda/py310-requirements-file/verify @@ -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 diff --git a/tests/conda/py310/environment.yml b/tests/conda/py310/environment.yml deleted file mode 100644 index f035843c..00000000 --- a/tests/conda/py310/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - python=3.10 diff --git a/tests/conda/py310/verify b/tests/conda/py310/verify deleted file mode 100755 index 37169446..00000000 --- a/tests/conda/py310/verify +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -import sys - -assert sys.version_info[:2] == (3, 10), sys.version diff --git a/tests/conda/binder-dir/binder/environment.yml b/tests/conda/py35-binder-dir/.binder/environment.yml similarity index 100% rename from tests/conda/binder-dir/binder/environment.yml rename to tests/conda/py35-binder-dir/.binder/environment.yml diff --git a/tests/conda/py35-binder-dir/Dockerfile b/tests/conda/py35-binder-dir/Dockerfile new file mode 100644 index 00000000..25508195 --- /dev/null +++ b/tests/conda/py35-binder-dir/Dockerfile @@ -0,0 +1,2 @@ +# This file should be ignored because there's a dedicated binder folder +FROM doesntmatter diff --git a/tests/conda/py35-binder-dir/README.rst b/tests/conda/py35-binder-dir/README.rst new file mode 100644 index 00000000..1df45db3 --- /dev/null +++ b/tests/conda/py35-binder-dir/README.rst @@ -0,0 +1,9 @@ +Python 3.5, and a dedicated binder folder +----------------------------------------- + +Test setup of Python 3.5 and the use of a dedicated binder folder that should +make files in the root directory be ignored. + +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. diff --git a/tests/conda/py35-binder-dir/environment.yml b/tests/conda/py35-binder-dir/environment.yml new file mode 100644 index 00000000..b23ebd20 --- /dev/null +++ b/tests/conda/py35-binder-dir/environment.yml @@ -0,0 +1,4 @@ +# This file should be ignored as we have a dedicated binder folder. +dependencies: + - thiswontwork + invalid diff --git a/tests/conda/binder-dir/verify b/tests/conda/py35-binder-dir/verify similarity index 100% rename from tests/conda/binder-dir/verify rename to tests/conda/py35-binder-dir/verify diff --git a/tests/conda/py37/environment.yml b/tests/conda/py37/environment.yml deleted file mode 100644 index a26454f4..00000000 --- a/tests/conda/py37/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - python=3.7 diff --git a/tests/conda/py37/verify b/tests/conda/py37/verify deleted file mode 100755 index fe2bff50..00000000 --- a/tests/conda/py37/verify +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -import sys - -assert sys.version_info[:2] == (3, 7), sys.version diff --git a/tests/conda/r/README.rst b/tests/conda/r/README.rst new file mode 100644 index 00000000..63f1e68f --- /dev/null +++ b/tests/conda/r/README.rst @@ -0,0 +1,5 @@ +Default R +--------- + +We test the default R version set by repo2docker as used when r-base is +specified without a version in an environment.yml file. diff --git a/tests/conda/r-unspecified/environment.yml b/tests/conda/r/environment.yml similarity index 64% rename from tests/conda/r-unspecified/environment.yml rename to tests/conda/r/environment.yml index 246f3556..786ea0e2 100644 --- a/tests/conda/r-unspecified/environment.yml +++ b/tests/conda/r/environment.yml @@ -1,3 +1,3 @@ dependencies: - r-base - - r-ggplot2 + - r-digest diff --git a/tests/conda/r-unspecified/verify b/tests/conda/r/verify similarity index 66% rename from tests/conda/r-unspecified/verify rename to tests/conda/r/verify index 9e45f377..9fdacac4 100755 --- a/tests/conda/r-unspecified/verify +++ b/tests/conda/r/verify @@ -2,6 +2,9 @@ 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)' diff --git a/tests/conda/r3.6-extra-args/README.rst b/tests/conda/r3.6-extra-args/README.rst new file mode 100644 index 00000000..cb3e1f85 --- /dev/null +++ b/tests/conda/r3.6-extra-args/README.rst @@ -0,0 +1,7 @@ +R 3.6, and an extra-args.yaml file +---------------------------------- + +We want to support custom paths where repositories can be copied to, instead of +${HOME}. The `extra-args.yaml` file in each dir can contain a list of arguments +that are passed to repo2docker during the test. We copy this repo to /srv/repo +instead of ${HOME} diff --git a/tests/conda/r3.6/environment.yml b/tests/conda/r3.6-extra-args/environment.yml similarity index 65% rename from tests/conda/r3.6/environment.yml rename to tests/conda/r3.6-extra-args/environment.yml index c1d2a2be..e9b34a48 100644 --- a/tests/conda/r3.6/environment.yml +++ b/tests/conda/r3.6-extra-args/environment.yml @@ -1,3 +1,3 @@ dependencies: - r-base=3.6 - - r-testthat + - r-digest diff --git a/tests/conda/repo-path/extra-args.yaml b/tests/conda/r3.6-extra-args/extra-args.yaml similarity index 100% rename from tests/conda/repo-path/extra-args.yaml rename to tests/conda/r3.6-extra-args/extra-args.yaml diff --git a/tests/conda/r3.6/verify b/tests/conda/r3.6-extra-args/verify similarity index 84% rename from tests/conda/r3.6/verify rename to tests/conda/r3.6-extra-args/verify index 63a7165f..084694a2 100755 --- a/tests/conda/r3.6/verify +++ b/tests/conda/r3.6-extra-args/verify @@ -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')" + +R -e "library('digest')" + # Fail if 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 diff --git a/tests/conda/repo-path/verify b/tests/conda/r3.6-extra-args/verify.py old mode 100755 new mode 100644 similarity index 86% rename from tests/conda/repo-path/verify rename to tests/conda/r3.6-extra-args/verify.py index 93f6fed6..9bfddeb1 --- a/tests/conda/repo-path/verify +++ b/tests/conda/r3.6-extra-args/verify.py @@ -15,6 +15,3 @@ assert os.path.abspath(__file__) == "/srv/repo/verify" # 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 diff --git a/tests/conda/r4.2/environment.yml b/tests/conda/r4.2/environment.yml deleted file mode 100644 index c8e255f9..00000000 --- a/tests/conda/r4.2/environment.yml +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: - - r-base=4.2 - - r-ggplot2 diff --git a/tests/conda/r4.2/verify b/tests/conda/r4.2/verify deleted file mode 100755 index 07e1a4e2..00000000 --- a/tests/conda/r4.2/verify +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -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 4.2 -R -e 'if (!(version$major == "4" && as.double(version$minor) >= 2 && as.double(version$minor) < 3)) quit("yes", 1)' \ No newline at end of file diff --git a/tests/conda/repo-path/README.rst b/tests/conda/repo-path/README.rst deleted file mode 100644 index 1092ee6d..00000000 --- a/tests/conda/repo-path/README.rst +++ /dev/null @@ -1,8 +0,0 @@ -Python - Custom Repository Location ------------------------------------ - -We want to support custom paths where repositories can be -copied to, instead of ${HOME}. The `extra-args.yaml` file in -each dir can contain a list of arguments that are passed -to repo2docker during the test. We copy this repo to -/srv/repo instead of ${HOME} \ No newline at end of file diff --git a/tests/conda/repo-path/environment.yml b/tests/conda/repo-path/environment.yml deleted file mode 100644 index 6a91d667..00000000 --- a/tests/conda/repo-path/environment.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - numpy diff --git a/tests/conda/requirements/README.rst b/tests/conda/requirements/README.rst deleted file mode 100644 index 7fb93d74..00000000 --- a/tests/conda/requirements/README.rst +++ /dev/null @@ -1,13 +0,0 @@ -Conda - Mixed Requirements --------------------------- - -An ``environment.yml`` file takes precedence over ``requirements.txt``. -To install Python packages into a conda environment with pip, use the -``pip`` key in ``environment.yml``: - -.. sourcecode:: yaml - - dependencies: - - numpy - - pip: - - tornado diff --git a/tests/conda/simple-py2/README.rst b/tests/conda/simple-py2/README.rst deleted file mode 100644 index 7e44b004..00000000 --- a/tests/conda/simple-py2/README.rst +++ /dev/null @@ -1,10 +0,0 @@ -Conda Environment and Python 2 ------------------------------- - -``environment.yml`` is the standard method for defining environments with the -Anaconda (conda) distribution. Conda environment files may allow for more -complex builds and dependencies than are possible with a single -``requirements.txt`` file. - -This example shows how to define a Python 2 environment with Anaconda. You can -define any version of Python that Anaconda supports. diff --git a/tests/conda/simple/README.rst b/tests/conda/simple/README.rst deleted file mode 100644 index 9758affb..00000000 --- a/tests/conda/simple/README.rst +++ /dev/null @@ -1,7 +0,0 @@ -Conda Environment ------------------ - -``environment.yml`` is the standard method for defining environments with the -Anaconda (conda) distribution. Conda environment files may allow for more -complex builds and dependencies than are possible with a single -``requirements.txt`` file. diff --git a/tests/conda/simple/verify b/tests/conda/simple/verify deleted file mode 100755 index 058dbed0..00000000 --- a/tests/conda/simple/verify +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -pytest -v ./verify.py