Skip to content

Commit

Permalink
Merge pull request #18 from rocs-org/feature/add-unixodbc-to-python-t…
Browse files Browse the repository at this point in the history
…est-image

Remove toolbox image.
  • Loading branch information
jakobkolb authored Oct 17, 2023
2 parents 8d6dc3b + cba3fce commit 63156fc
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
image: ['datascience-notebook', 'python-test-environment', 'smee-proxy', 'jenkins-inbound-agent', 'toolbox']
image: ['datascience-notebook', 'python-test-environment', 'smee-proxy', 'jenkins-inbound-agent']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
image: ['datascience-notebook', 'python-test-environment', 'smee-proxy', 'jenkins-inbound-agent', 'toolbox']
image: ['datascience-notebook', 'python-test-environment', 'smee-proxy', 'jenkins-inbound-agent']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
40 changes: 21 additions & 19 deletions datascience-notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
FROM jupyter/datascience-notebook

RUN conda install nb_conda_kernels nb_conda

# install jupyterlab git extension
RUN pip install --upgrade jupyterlab-git

# instal poetry

ENV POETRY_HOME=/etc/poetry

# echo current user

USER root

RUN curl -sSL https://install.python-poetry.org | python3 -
# add poetry to path
ENV PATH="${POETRY_HOME}/bin:${PATH}"

FROM jupyter/datascience-notebook

RUN conda update -n base conda && conda install jupyter

RUN conda install nb_conda_kernels nb_conda

# install jupyterlab git extension
RUN pip install --upgrade jupyterlab-git

# instal poetry

ENV POETRY_HOME=/etc/poetry

# echo current user

USER root

RUN curl -sSL https://install.python-poetry.org | python3 -
# add poetry to path
ENV PATH="${POETRY_HOME}/bin:${PATH}"

USER jovyan
112 changes: 59 additions & 53 deletions python-test-environment/python-dockerfile_test.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
import pytest
import subprocess


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_jupyter(container):
assert container.status == "created"
assert container.run("poetry --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_jupyter_git(container):
assert container.status == "created"
assert container.run("make --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_container_has_poetry(container):
assert container.status == "created"
assert container.run("poetry --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_can_use_poetry_in_container(container, tmp_path):
d = tmp_path / "pyproject.toml"
d.parent.rmdir()
d.parent.mkdir()
d.touch()
d.write_text(PYPROJECT_CONTENT)
# create valid pyproject.toml in container
assert container.status == "created"
subprocess.run(["docker", "cp", str(d), f"{container.id}:/home/testuser/pyproject.toml"])
print(container.run("ls -la").output)
assert container.run("poetry install").exit_code == 0


PYPROJECT_CONTENT = """
[tool.poetry]
name = "jovyan"
version = "0.1.0"
description = ""
authors = ["jakob"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
ramda = "^0.7.6"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
"""
import pytest
import subprocess


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_jupyter(container):
assert container.status == "created"
assert container.run("poetry --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_jupyter_git(container):
assert container.status == "created"
assert container.run("make --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_container_has_poetry(container):
assert container.status == "created"
assert container.run("poetry --version").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_can_use_poetry_in_container(container, tmp_path):
d = tmp_path / "pyproject.toml"
d.parent.rmdir()
d.parent.mkdir()
d.touch()
d.write_text(PYPROJECT_CONTENT)
# create valid pyproject.toml in container
assert container.status == "created"
subprocess.run(["docker", "cp", str(d), f"{container.id}:/home/testuser/pyproject.toml"])
print(container.run("ls -la").output)
assert container.run("poetry install").exit_code == 0


@pytest.mark.parametrize("container", ["python-test-environment"], indirect=["container"])
def test_can_pyodbc_in_container(container):
assert container.status == "created"
assert container.run("echo 'import pyodbc' | python").exit_code == 0


PYPROJECT_CONTENT = """
[tool.poetry]
name = "jovyan"
version = "0.1.0"
description = ""
authors = ["jakob"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
ramda = "^0.7.6"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
"""

0 comments on commit 63156fc

Please sign in to comment.