Skip to content

Commit

Permalink
upgrade to 3.12 (#483)
Browse files Browse the repository at this point in the history
* Copy changes from ba7e2b7

Chaging the base image (already updated to python 3.12)

* upgrade packages until the project builds and tests run

* fix tests and make them pass

* improve pytest-cov performance

* update pytest and its plugins
  • Loading branch information
giovanni-guidini authored May 10, 2024
1 parent 052c306 commit 5aa4b11
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 89 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ check-for-migration-conflicts:
python manage.py check_for_migration_conflicts

test:
python -m pytest --cov=./ --junitxml=junit.xml
COVERAGE_CORE=sysmon python -m pytest --cov=./ --junitxml=junit.xml

test.unit:
python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml

test.integration:
python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml

lint:
make lint.install
Expand Down
4 changes: 2 additions & 2 deletions api/internal/tests/views/test_repo_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def test_retrieve_returns_latest_commit_data(self, mocked_get_permissions):
response.data["latest_commit"]["report"]["totals"]
== expected_commit_payload["report"]["totals"]
)
self.assertEquals(
self.assertEqual(
response.data["latest_commit"]["report"]["files"],
[
{
Expand Down Expand Up @@ -1181,7 +1181,7 @@ def side_effect(path, *args, **kwargs):
response.data["latest_commit"]["report"]["totals"]
== expected_commit_payload["report"]["totals"]
)
self.assertEquals(
self.assertEqual(
response.data["latest_commit"]["report"]["files"],
[
{
Expand Down
6 changes: 0 additions & 6 deletions codecov/settings_prod.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import os

import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.httpx import HttpxIntegration
from sentry_sdk.integrations.redis import RedisIntegration

from .settings_base import *

DEBUG = False
Expand Down
6 changes: 3 additions & 3 deletions codecov_auth/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_prev_and_new_values_in_log_entry(self, mocked_super_log_change):
message = []
message.append({"changed": {"fields": ["staff"]}})
self.owner_admin.log_change(MagicMock, owner, message)
assert mocked_super_log_change.called_once()
mocked_super_log_change.assert_called_once()
assert message == [
{"changed": {"fields": ["staff"]}},
{"staff": "prev value: True, new value: False"},
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_org_token_refresh_request_calls_service_to_refresh_token(
"_continue": ["Save and continue editing"],
}
response = self.client.post(request_url, data=fake_data)
assert mock_refresh.called_with(str(org_token.id))
mock_refresh.assert_called_with(str(org_token.id))

@patch(
"codecov_auth.services.org_level_token_service.OrgLevelTokenService.refresh_token"
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_org_token_request_doesnt_call_service_to_refresh_token(self, mock_refre
"_continue": ["Save and continue editing"],
}
response = self.client.post(request_url, data=fake_data)
assert mock_refresh.not_called()
mock_refresh.assert_not_called()

def test_start_trial_ui_display(self):
owner = OwnerFactory()
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_prev_and_new_values_in_log_entry(self, mocked_super_log_change):
message = []
message.append({"changed": {"fields": ["using_integration"]}})
self.repo_admin.log_change(MagicMock, repo, message)
assert mocked_super_log_change.called_once()
mocked_super_log_change.assert_called_once()
assert message == [
{"changed": {"fields": ["using_integration"]}},
{"using_integration": "prev value: True, new value: False"},
Expand Down
2 changes: 1 addition & 1 deletion dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _start_gunicorn() {
if [[ "$STATSD_HOST" ]]; then
suffix="--statsd-host ${STATSD_HOST}:${STATSD_PORT}"
fi
if [[ "$RUN_ENV" == "ENTERPRISE" ]] || [[ "$RUN_ENV" == "enterprise" ]] || [[ "$RUN_ENV" == "DEV" ]]; then
if [ "$RUN_ENV" == "ENTERPRISE" ] || [ "$RUN_ENV" == "DEV" ]; then
python manage.py migrate
python manage.py migrate --database "timeseries" timeseries
python manage.py pgpartition --yes --skip-delete
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ services:
environment:
- RUN_ENV=DEV
- SETUP__TIMESERIES__ENABLED=${TIMESERIES_ENABLED-true}
# Improves pytest-cov performance in python 3.12
# https://github.com/nedbat/coveragepy/issues/1665#issuecomment-1937075835
- COVERAGE_CORE=sysmon
env_file:
- .testenv
postgres:
Expand Down
14 changes: 7 additions & 7 deletions docker/Dockerfile-proxy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.3
FROM python:3.9.18-slim-bookworm
FROM python:3.12-slim-bookworm

ENV FRP_VERSION=v0.51.3

Expand All @@ -8,12 +8,12 @@ RUN apt-get update
RUN apt-get install -y curl

RUN addgroup -S frp \
&& adduser -D -S -h /var/frp -s /sbin/nologin -G frp frp \
&& curl -fSL https://github.com/fatedier/frp/releases/download/${FRP_VERSION}/frp_${FRP_VERSION:1}_linux_amd64.tar.gz -o frp.tar.gz \
&& tar -zxv -f frp.tar.gz \
&& rm -rf frp.tar.gz \
&& mv frp_*_linux_amd64 /frp \
&& chown -R frp:frp /frp
&& adduser -D -S -h /var/frp -s /sbin/nologin -G frp frp \
&& curl -fSL https://github.com/fatedier/frp/releases/download/${FRP_VERSION}/frp_${FRP_VERSION:1}_linux_amd64.tar.gz -o frp.tar.gz \
&& tar -zxv -f frp.tar.gz \
&& rm -rf frp.tar.gz \
&& mv frp_*_linux_amd64 /frp \
&& chown -R frp:frp /frp

COPY --chown=frp:frp docker/frpc-entrypoint.sh /frp/entrypoint.sh
RUN chmod 755 /frp/entrypoint.sh
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.requirements
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# syntax=docker/dockerfile:1.4
ARG PYTHON_IMAGE=python:3.9.18-slim-bookworm
ARG PYTHON_IMAGE=python:3.12-slim-bookworm

# BUILD STAGE - Download dependencies from GitHub that require SSH access
FROM $PYTHON_IMAGE as build


# Pinning a specific nightly version so that builds don't suddenly break if a
# "this feature is now stabilized" warning is promoted to an error or something.
# We would like to keep up with nightly if we can.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_delete_component_measurements(self, execute_mock):

assert data == {"deleteComponentMeasurements": None}

assert execute_mock.called_once_with(
execute_mock.assert_called_once_with(
owner_username="test-owner",
repo_name="test-repo",
component_id="test-component",
Expand Down
2 changes: 1 addition & 1 deletion graphql_api/tests/mutation/test_delete_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_delete_flag(self, execute_mock):

assert data == {"deleteFlag": None}

assert execute_mock.called_once_with(
execute_mock.assert_called_once_with(
owner_username="test-owner",
repo_name="test-repo",
flag_name="test-flag",
Expand Down
7 changes: 4 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aiodataloader
ariadne
ariadne_django
celery[redis]
celery>=5.3.6
cerberus
ddtrace
Django
Expand All @@ -26,8 +26,8 @@ gunicorn>=22.0.0
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz
idna>=3.7
minio
opentelemetry-instrumentation-django>=0.41b0
opentelemetry-sdk>=1.20.0
opentelemetry-instrumentation-django>=0.45b0
opentelemetry-sdk>=1.24.0
opentracing
pre-commit
psycopg2
Expand All @@ -45,6 +45,7 @@ redis
regex
requests
sentry-sdk>=1.40.0
sentry-sdk[celery]
setproctitle
simplejson
stripe
Expand Down
Loading

0 comments on commit 5aa4b11

Please sign in to comment.