From 5d57c392766377b4e31a46294f8471a632f697ab Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Tue, 21 May 2024 21:03:23 +0100 Subject: [PATCH] tests: Shift pip install to run_jenkins_tests Otherwise it's run as root rather than whatever user is being used inside the container. --- tests/python-baseline.Dockerfile | 4 +--- tests/python-latest.Dockerfile | 3 --- tests/run_jenkins_tests.sh | 10 +++++++--- tests/ubuntu-baseline.Dockerfile | 3 --- tests/ubuntu-latest.Dockerfile | 3 --- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tests/python-baseline.Dockerfile b/tests/python-baseline.Dockerfile index c02fc887e..25cf33ffe 100644 --- a/tests/python-baseline.Dockerfile +++ b/tests/python-baseline.Dockerfile @@ -1,8 +1,6 @@ FROM python:3.8.0 -LABEL maintainer="Alexander.Richardson@cl.cam.ac.uk" -COPY requirements.txt /tmp/requirements.txt -RUN pip install -r /tmp/requirements.txt && rm -f /tmp/requirements.txt +LABEL maintainer="Alexander.Richardson@cl.cam.ac.uk" # setting Git username and email for workaround of # https://github.com/jenkinsci/docker/issues/519 diff --git a/tests/python-latest.Dockerfile b/tests/python-latest.Dockerfile index c76e223d1..e25d4c10f 100644 --- a/tests/python-latest.Dockerfile +++ b/tests/python-latest.Dockerfile @@ -2,9 +2,6 @@ FROM python:latest LABEL maintainer="Alexander.Richardson@cl.cam.ac.uk" -COPY requirements.txt /tmp/requirements.txt -RUN pip install -r /tmp/requirements.txt && rm -f /tmp/requirements.txt - # setting Git username and email for workaround of # https://github.com/jenkinsci/docker/issues/519 ENV GIT_COMMITTER_NAME cheribuild diff --git a/tests/run_jenkins_tests.sh b/tests/run_jenkins_tests.sh index aacee707e..1f189a2fb 100755 --- a/tests/run_jenkins_tests.sh +++ b/tests/run_jenkins_tests.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -pytest_binary="python3 -m pytest" - - case $1 in baseline|latest|ubuntu-baseline|ubuntu-latest) test_prefix=$1 @@ -30,6 +27,13 @@ else cd "$_srcdir" fi +if ! python3 -m pip install --user -r requirements.txt; then + echo "FATAL: could not install requirements" + exit 1 +fi + +pytest_binary="python3 -m pytest" + # Run unit tests rm -f "../$test_prefix-results.xml" $pytest_binary -v --junit-xml "../$test_prefix-results.xml" tests || echo "Some tests failed" diff --git a/tests/ubuntu-baseline.Dockerfile b/tests/ubuntu-baseline.Dockerfile index 517255cf7..912fe6439 100644 --- a/tests/ubuntu-baseline.Dockerfile +++ b/tests/ubuntu-baseline.Dockerfile @@ -7,6 +7,3 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ git \ python3-minimal python3-pip python3-setuptools - -COPY requirements.txt /tmp/requirements.txt -RUN pip3 install --user -r /tmp/requirements.txt && rm -f /tmp/requirements.txt diff --git a/tests/ubuntu-latest.Dockerfile b/tests/ubuntu-latest.Dockerfile index 6f1d019bc..49e3dfb39 100644 --- a/tests/ubuntu-latest.Dockerfile +++ b/tests/ubuntu-latest.Dockerfile @@ -7,6 +7,3 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ git \ python3-minimal python3-pip python3-setuptools - -COPY requirements.txt /tmp/requirements.txt -RUN pip3 install --user -r /tmp/requirements.txt && rm -f /tmp/requirements.txt