8000 A support of Python v3.8 by dmitry-lipetsk · Pull Request #238 · postgrespro/testgres · GitHub
[go: up one dir, main page]

Skip to content

A support of Python v3.8 #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[CI] Test with python 3.8, 3.9, 3.10 and 3.11 [std2-all][alpine]
We will run all the tests to get a full information about compatibility.

Some new tests may fail.

---
TODO: may be it is better to compile/install required python version explicitly instead using pyenv.
  • Loading branch information
dmitry-lipetsk committed Apr 8, 2025
commit 208c5e39b5ca597ec1fba5a69e26e710a42e5aeb
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ notifications:
on_failure: always

env:
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.8 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.9 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.10 PG_VERSION=17
- TEST_PLATFORM=std2-all PYTHON_VERSION=3.11 PG_VERSION=17
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=16
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=15
- TEST_PLATFORM=std PYTHON_VERSION=3 PG_VERSION=14
Expand Down
93 changes: 93 additions & 0 deletions Dockerfile--std2-all.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
ARG PG_VERSION
ARG PYTHON_VERSION

# --------------------------------------------- base1
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 py-virtualenv

# For pyenv
RUN apk add build-base gcc-doc
RUN apk add patch
RUN apk add git
RUN apk add xz-dev
RUN apk add zip
RUN apk add zlib-dev
RUN apk add libffi-dev
RUN apk add readline-dev
RUN apk add openssl openssl-dev
RUN apk add sqlite-dev
RUN apk add bzip2-dev

# --------------------------------------------- base3_with_python-3.8
FROM base2_with_python-3 as base3_with_python-3.8
ENV PYTHON_VERSION=3.8

# --------------------------------------------- base3_with_python-3.9
FROM base2_with_python-3 as base3_with_python-3.9
ENV PYTHON_VERSION=3.9

# --------------------------------------------- base3_with_python-3.10
FROM base2_with_python-3 as base3_with_python-3.10
ENV PYTHON_VERSION=3.10

# --------------------------------------------- base3_with_python-3.11
FROM base2_with_python-3 as base3_with_python-3.11
ENV PYTHON_VERSION=3.11

# --------------------------------------------- final
FROM base3_with_python-${PYTHON_VERSION} as final

#RUN apk add --no-cache mc

# Full version of "ps" command
RUN apk add --no-cache procps

RUN apk add --no-cache openssh
RUN apk add --no-cache sudo

ENV LANG=C.UTF-8

RUN addgroup -S sudo
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

# THIS CMD IS NEEDED TO CONNECT THROUGH SSH WITHOUT PASSWORD
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}

# 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; \
echo HELLO FROM ENTRYPOINT; \
echo HOME DIR IS [`realpath ~/`]; \
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N ''; \
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys; \
chmod 600 ~/.ssh/authorized_keys; \
ls -la ~/.ssh/; \
sudo /usr/sbin/sshd; \
ssh-keyscan -H localhost >> ~/.ssh/known_hosts; \
ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts; \
export PATH=\"~/.pyenv/bin:$PATH\"; \
TEST_FILTER=\"\" bash run_tests2.sh;"
68 changes: 68 additions & 0 deletions run_tests2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

# Copyright (c) 2017-2025 Postgres Professional

set -eux

eval "$(pyenv init -)"
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 coverage flake8 psutil Sphinx pytest pytest-xdist psycopg2 six psutil

# install testgres' dependencies
export PYTHONPATH=$(pwd)
# $PIP install .

# test code quality
flake8 .


# remove existing coverage file
export COVERAGE_FILE=.coverage
rm -f $COVERAGE_FILE


# 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}"


# show coverage
coverage report

# build documentation
cd docs
make html
cd ..

# attempt to fix codecov
set +eux

# send coverage stats to Codecov
bash <(curl -s https://codecov.io/bash)
0