Skip to content

Commit

Permalink
chore(RHINENG-5889) Upgrade python to 3.9 (#1577)
Browse files Browse the repository at this point in the history
* Upgrade python to 3.10

* Downgrade to python 3.9

* Change python3.9 to python3 in unit_test.sh

* Change python3 to python3.8 in unit_test.sh

* back to 3.9

* Run pre-commit using plain 'python3'

* Try running pre-commit in container

* Try using '--user'

* Try mounting pre-commit cache and installing 'git' in test image

* Correct Dockerfile change

* Set workspace as git safe dir

* Set HOME and PRE_COMMIT_HOME

* Use only HOME, not PRE_COMMIT_HOME

* Make sure command exactly matches

* Remove '-i' from docker run

* Run podman with -u root

* Run podman with non-root user

---------

Co-authored-by: Brandon Squizzato <[email protected]>
  • Loading branch information
kruai and bsquizz authored Dec 11, 2023
1 parent 34f1efa commit 92f5a15
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 332 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.8
python: python3.9
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
Expand Down
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ RUN FULL_RHEL=$(microdnf repolist --enabled | grep rhel-8) ; \
ENV APP_ROOT=/opt/app-root/src
WORKDIR $APP_ROOT

RUN microdnf module enable postgresql:13 python38:3.8 && \
RUN microdnf module enable postgresql:13 python39:3.9 && \
microdnf upgrade -y && \
microdnf install --setopt=tsflags=nodocs -y postgresql python38 rsync tar procps-ng make snappy && \
microdnf install --setopt=tsflags=nodocs -y postgresql python39 rsync tar procps-ng make snappy && \
rpm -qa | sort > packages-before-devel-install.txt && \
microdnf install --setopt=tsflags=nodocs -y libpq-devel python38-devel gcc && \
microdnf install --setopt=tsflags=nodocs -y libpq-devel python39-devel gcc && \
rpm -qa | sort > packages-after-devel-install.txt

COPY . .
Expand All @@ -32,8 +32,12 @@ RUN python3 -m pip install --upgrade pip setuptools wheel && \
python3 -m pip install pipenv && \
pipenv install --system --dev

# allows unit tests to run successfully within the container if image is built in "test" environment
RUN if [ "$TEST_IMAGE" = "true" ]; then chgrp -R 0 $APP_ROOT && chmod -R g=u $APP_ROOT; fi
# allows pre-commit and unit tests to run successfully within the container if image is built in "test" environment
RUN if [ "$TEST_IMAGE" = "true" ]; then \
microdnf install --setopt=tsflags=nodocs -y git && \
chgrp -R 0 $APP_ROOT && \
chmod -R g=u $APP_ROOT ; \
fi

# remove devel packages that were only necessary for psycopg2 to compile
RUN microdnf remove -y $( comm -13 packages-before-devel-install.txt packages-after-devel-install.txt ) && \
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ marshmallow = "~=3.20.1"
ujson = "==5.8.0"
watchtower = ">=0.6.0,<4.0.0"
boto3 = "~=1.28"
confluent-kafka="~=1.9.2"
confluent-kafka="~=2.0.2"
prometheus-flask-exporter = "~=0.22.3"
python-dateutil = "~=2.8.1"
prance = "==0.21.8"
Expand All @@ -50,4 +50,4 @@ pre-commit = "~=3.3.3"
sqlalchemy-utils = "==0.41.1"

[requires]
python_version = "3.8"
python_version = "3.9"
Loading

0 comments on commit 92f5a15

Please sign in to comment.