From 70c89507393f64efe4349e5cea8bec9793547384 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Thu, 30 Nov 2023 12:13:33 -0500 Subject: [PATCH] chore: normalizes and improves readability for container files (#83) * chore: updates integration directory to workflows under tests Integration is not very precise for the types of tests. Updates to workflows to reflect that this should test each model path. Signed-off-by: Jennifer Power * chore: removes some extra comments in the Containerfile and moves poetry envs Some of the comments are explained by the code so removes to make this more readable. The poetry environment variables should not be in the base because poetry is not installed in the final image. Signed-off-by: Jennifer Power --------- Signed-off-by: Jennifer Power --- Dockerfile | 41 ++++++++----------- tests/{integration => workflows}/__init__.py | 2 +- .../test_rules_transform_workflow.py | 0 3 files changed, 17 insertions(+), 26 deletions(-) rename tests/{integration => workflows}/__init__.py (90%) rename tests/{integration => workflows}/test_rules_transform_workflow.py (100%) diff --git a/Dockerfile b/Dockerfile index 7be91b59..df866614 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,35 +3,18 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as python-base ENV PYTHONUNBUFFERED=1 \ - # prevents python creating .pyc files PYTHONDONTWRITEBYTECODE=1 \ - \ - # pip PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DEFAULT_TIMEOUT=100 \ - \ - # poetry - # https://python-poetry.org/docs/configuration/#using-environment-variables - POETRY_VERSION=1.5.1 \ - # make poetry install to this location - POETRY_HOME="/opt/poetry" \ - # make poetry create the virtual environment in the project's root - # it gets named `.venv` - POETRY_VIRTUALENVS_IN_PROJECT=true \ - # do not ask any interactive question - POETRY_NO_INTERACTION=1 \ - \ - # paths - # this is where our requirements + virtual environment will live + # Paths for the virtual environment and working directory PYSETUP_PATH="/trestle-bot" \ VENV_PATH="/trestle-bot/.venv" LABEL maintainer="Red Hat Product Security" \ summary="Trestle Bot" - -# prepend poetry and venv to path -ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" +# Ensure we use the virtualenv +ENV PATH="$VENV_PATH/bin:$PATH" RUN microdnf update -y \ && microdnf install -y python3.9 git \ @@ -40,28 +23,36 @@ RUN microdnf update -y \ FROM python-base as dependencies -# install poetry - respects $POETRY_VERSION & $POETRY_HOME +ARG POETRY_VERSION=1.5.1 + +# https://python-poetry.org/docs/configuration/#using-environment-variables +ENV POETRY_HOME="/opt/poetry" \ + POETRY_VIRTUALENVS_IN_PROJECT=true \ + POETRY_NO_INTERACTION=1 + +ENV PATH="$POETRY_HOME/bin:$PATH" + +# install poetry - respects $POETRY_HOME RUN python3.9 -m pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir poetry=="$POETRY_VERSION" -# Cache runtime deps WORKDIR "/build" COPY . "/build" # Install runtime deps and install the project in non-editable mode. -RUN python -m venv $VENV_PATH && \ +RUN python3.9 -m venv $VENV_PATH && \ . $VENV_PATH/bin/activate && \ poetry install --without tests,dev --no-root && \ poetry build -f wheel -n && \ pip install --no-cache-dir --no-deps dist/*.whl && \ rm -rf dist *.egg-info -# final image + FROM python-base as final COPY --from=dependencies $PYSETUP_PATH $PYSETUP_PATH -# Add wrappers for entrypoints that provide support the actions +# Add wrappers for entrypoints that provide support for the actions COPY ./actions/autosync/auto-sync-entrypoint.sh / COPY ./actions/rules-transform/rules-transform-entrypoint.sh / COPY ./actions/create-cd/create-cd-entrypoint.sh / diff --git a/tests/integration/__init__.py b/tests/workflows/__init__.py similarity index 90% rename from tests/integration/__init__.py rename to tests/workflows/__init__.py index 35ab7fef..37bacefe 100644 --- a/tests/integration/__init__.py +++ b/tests/workflows/__init__.py @@ -13,4 +13,4 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Integration tests between different types of tasks classes.""" +"""Tests that validate workflow outcomes by model type.""" diff --git a/tests/integration/test_rules_transform_workflow.py b/tests/workflows/test_rules_transform_workflow.py similarity index 100% rename from tests/integration/test_rules_transform_workflow.py rename to tests/workflows/test_rules_transform_workflow.py