diff --git a/Dockerfile--altlinux_10.tmpl b/Dockerfile--altlinux_10.tmpl index e82c9398..6b7ad40c 100644 --- a/Dockerfile--altlinux_10.tmpl +++ b/Dockerfile--altlinux_10.tmpl @@ -3,7 +3,6 @@ ARG PYTHON_VERSION # --------------------------------------------- base1 FROM alt:p10 as base1 -ARG PG_VERSION RUN apt-get update RUN apt-get install -y sudo curl ca-certificates @@ -66,7 +65,7 @@ RUN apt-get install -y python3 RUN apt-get install -y python3-dev RUN apt-get install -y python3-modules-sqlite3 -ENV PYTHON_VERSION=3 +ENV PYTHON_BINARY=python3 # --------------------------------------------- final FROM base2_with_python-${PYTHON_VERSION} as final @@ -76,9 +75,8 @@ RUN adduser test -G wheel # It enables execution of "sudo service ssh start" without password RUN sh -c "echo \"WHEEL_USERS ALL=(ALL:ALL) NOPASSWD: ALL\"" >> /etc/sudoers -ADD . /pg/testgres +ADD --chown=test:test . /pg/testgres WORKDIR /pg/testgres -RUN chown -R test /pg/testgres ENV LANG=C.UTF-8 diff --git a/Dockerfile--altlinux_11.tmpl b/Dockerfile--altlinux_11.tmpl index cf549926..e56db9c4 100644 --- a/Dockerfile--altlinux_11.tmpl +++ b/Dockerfile--altlinux_11.tmpl @@ -3,7 +3,6 @@ ARG PYTHON_VERSION # --------------------------------------------- base1 FROM alt:p11 as base1 -ARG PG_VERSION RUN apt-get update RUN apt-get install -y sudo curl ca-certificates @@ -69,7 +68,7 @@ RUN apt-get install -y python3 RUN apt-get install -y python3-dev RUN apt-get install -y python3-modules-sqlite3 -ENV PYTHON_VERSION=3 +ENV PYTHON_BINARY=python3 # --------------------------------------------- final FROM base2_with_python-${PYTHON_VERSION} as final @@ -79,9 +78,8 @@ RUN adduser test -G wheel # It enables execution of "sudo service ssh start" without password RUN sh -c "echo \"WHEEL_USERS ALL=(ALL:ALL) NOPASSWD: ALL\"" >> /etc/sudoers -ADD . /pg/testgres +ADD --chown=test:test . /pg/testgres WORKDIR /pg/testgres -RUN chown -R test /pg/testgres ENV LANG=C.UTF-8 diff --git a/Dockerfile--std-all.tmpl b/Dockerfile--std-all.tmpl index 7ebb6194..170f53f9 100644 --- a/Dockerfile--std-all.tmpl +++ b/Dockerfile--std-all.tmpl @@ -7,7 +7,7 @@ FROM postgres:${PG_VERSION}-alpine as base1 # --------------------------------------------- base2_with_python-3 FROM base1 as base2_with_python-3 RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers -ENV PYTHON_VERSION=3 +ENV PYTHON_BINARY=python3 # --------------------------------------------- final FROM base2_with_python-${PYTHON_VERSION} as final @@ -29,9 +29,8 @@ RUN adduser postgres sudo EXPOSE 22 RUN ssh-keygen -A -ADD . /pg/testgres +ADD --chown=postgres:postgres . /pg/testgres WORKDIR /pg/testgres -RUN chown -R postgres:postgres /pg # It allows to use sudo without password RUN sh -c "echo \"postgres ALL=(ALL:ALL) NOPASSWD:ALL\"">>/etc/sudoers diff --git a/Dockerfile--std.tmpl b/Dockerfile--std.tmpl index 76e004f0..f1ba65df 100644 --- a/Dockerfile--std.tmpl +++ b/Dockerfile--std.tmpl @@ -7,7 +7,7 @@ FROM postgres:${PG_VERSION}-alpine as base1 # --------------------------------------------- base2_with_python-3 FROM base1 as base2_with_python-3 RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers -ENV PYTHON_VERSION=3 +ENV PYTHON_BINARY=python3 # --------------------------------------------- final FROM base2_with_python-${PYTHON_VERSION} as final @@ -16,9 +16,8 @@ RUN apk add --no-cache git ENV LANG=C.UTF-8 -ADD . /pg/testgres +ADD --chown=postgres:postgres . /pg/testgres WORKDIR /pg/testgres -RUN chown -R postgres:postgres /pg USER postgres ENTRYPOINT bash run_tests.sh diff --git a/Dockerfile--std2-all.tmpl b/Dockerfile--std2-all.tmpl index 195f0665..0a695240 100644 --- a/Dockerfile--std2-all.tmpl +++ b/Dockerfile--std2-all.tmpl @@ -6,6 +6,7 @@ FROM postgres:${PG_VERSION}-alpine as base1 # --------------------------------------------- base2_with_python-3 FROM base1 as base2_with_python-3 +ENV PYTHON_BINARY=python3 RUN apk add --no-cache curl python3 python3-dev build-base musl-dev linux-headers # For pyenv @@ -75,10 +76,6 @@ RUN adduser postgres sudo EXPOSE 22 RUN ssh-keygen -A -ADD . /pg/testgres -WORKDIR /pg/testgres -RUN chown -R postgres:postgres /pg - # It allows to use sudo without password RUN sh -c "echo \"postgres ALL=(ALL:ALL) NOPASSWD:ALL\"">>/etc/sudoers @@ -88,14 +85,15 @@ RUN sh -c "echo "postgres:*" | chpasswd -e" USER postgres RUN curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash - RUN ~/.pyenv/bin/pyenv install ${PYTHON_VERSION} +ADD --chown=postgres:postgres . /pg/testgres +WORKDIR /pg/testgres + # THIS CMD IS NEEDED TO CONNECT THROUGH SSH WITHOUT PASSWORD RUN chmod 700 ~/ RUN mkdir -p ~/.ssh -#RUN chmod 700 ~/.ssh ENTRYPOINT sh -c " \ set -eux; \ diff --git a/Dockerfile--ubuntu_24_04.tmpl b/Dockerfile--ubuntu_24_04.tmpl index ca26afea..f3846036 100644 --- a/Dockerfile--ubuntu_24_04.tmpl +++ b/Dockerfile--ubuntu_24_04.tmpl @@ -42,16 +42,15 @@ RUN sh -c "echo postgres ALL=NOPASSWD:/usr/sbin/service ssh start" >> /etc/sudoe # --------------------------------------------- base2_with_python-3 FROM base1 as base2_with_python-3 RUN apt install -y python3 python3-dev python3-venv libpq-dev build-essential -ENV PYTHON_VERSION=3 +ENV PYTHON_BINARY=python3 # --------------------------------------------- final FROM base2_with_python-${PYTHON_VERSION} as final RUN apt install -y git -ADD . /pg/testgres +ADD --chown=postgres:postgres . /pg/testgres WORKDIR /pg/testgres -RUN chown -R postgres /pg ENV LANG=C.UTF-8 diff --git a/run_tests.sh b/run_tests.sh index f4a978c6..04c4b2ae 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -13,7 +13,7 @@ command -v pg_config # prepare python environment VENV_PATH="/tmp/testgres_venv" rm -rf $VENV_PATH -python${PYTHON_VERSION} -m venv "${VENV_PATH}" +${PYTHON_BINARY} -m venv "${VENV_PATH}" export VIRTUAL_ENV_DISABLE_PROMPT=1 source "${VENV_PATH}/bin/activate" pip install -r tests/requirements.txt diff --git a/run_tests2.sh b/run_tests2.sh index 4cb4cb4f..82b1b983 100755 --- a/run_tests2.sh +++ b/run_tests2.sh @@ -8,66 +8,4 @@ eval "$(pyenv virtualenv-init -)" pyenv virtualenv --force ${PYTHON_VERSION} cur pyenv activate cur -if [ -z ${TEST_FILTER+x} ]; \ -then export TEST_FILTER="TestTestgresLocal or (TestTestgresCommon and (not remote))"; \ -fi - -# fail early -echo check that pg_config is in PATH -command -v pg_config - -# prepare python environment -VENV_PATH="/tmp/testgres_venv" -rm -rf $VENV_PATH -python -m venv "${VENV_PATH}" -export VIRTUAL_ENV_DISABLE_PROMPT=1 -source "${VENV_PATH}/bin/activate" -pip install -r tests/requirements.txt - -# test code quality -pip install flake8 flake8-pyproject -flake8 . -pip uninstall -y flake8 flake8-pyproject - -# remove existing coverage file -export COVERAGE_FILE=.coverage -rm -f $COVERAGE_FILE - -pip install coverage - -# run tests (PATH) -time coverage run -a -m pytest -l -v -n 4 -k "${TEST_FILTER}" - -# run tests (PG_BIN) -PG_BIN=$(pg_config --bindir) \ -time coverage run -a -m pytest -l -v -n 4 -k "${TEST_FILTER}" - -# run tests (PG_CONFIG) -PG_CONFIG=$(pg_config --bindir)/pg_config \ -time coverage run -a -m pytest -l -v -n 4 -k "${TEST_FILTER}" - -# test pg8000 -pip uninstall -y psycopg2 -pip install pg8000 -PG_CONFIG=$(pg_config --bindir)/pg_config \ -time coverage run -a -m pytest -l -v -n 4 -k "${TEST_FILTER}" - -# show coverage -coverage report - -pip uninstall -y coverage - -# build documentation -pip install Sphinx - -cd docs -make html -cd .. - -pip uninstall -y Sphinx - -# attempt to fix codecov -set +eux - -# send coverage stats to Codecov -bash <(curl -s https://codecov.io/bash) +./run_tests.sh