Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Dockerfile--altlinux_10.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 2 additions & 4 deletions Dockerfile--altlinux_11.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions Dockerfile--std-all.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile--std.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 4 additions & 6 deletions Dockerfile--std2-all.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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; \
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile--ubuntu_24_04.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 1 addition & 63 deletions run_tests2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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