Skip to content
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

MPP-3487: Update to Python 3.11.10, prepare for Python 3.12, 3.13 #5167

Merged
merged 7 commits into from
Nov 4, 2024
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
73 changes: 40 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,25 +364,33 @@ jobs:
python_job:
executor:
name: << parameters.executor >>
postgres_version: << parameters.postgres_version >>
python_version: << parameters.python_version >>
variant: << parameters.variant >>
postgres_version: << parameters.postgres_version >>
parameters:
executor:
description: "Which executor to use?"
default: python
type: enum
enum: ["python", "python_with_postgres"]
<<: *python_parameters
allow_fail:
description: "Allow the command to fail without failing job."
type: boolean
default: false
command:
description: "What command should the job run?"
default: "pytest"
type: enum
enum: ["pytest", "black", "mypy", "build_email_tracker_lists", "build_glean", "check_glean", "ruff"]
test_results_filename:
description: "What is the name of the jUnit XML test output? (Optional)"
default: ""
type: string
executor:
description: "Which executor to use?"
default: python
type: enum
enum: ["python", "python_with_postgres"]
mypy_strict:
description: "mypy will use --strict"
type: boolean
default: false
production_with_new_migrations:
description: "Test if deployed code will work with new migrations."
type: boolean
default: false
pytest_fail_fast:
description: "pytest will stop after 3 failures"
type: boolean
Expand All @@ -392,22 +400,14 @@ jobs:
default: "twilio"
type: enum
enum: ["no-phones", "twilio", "iq"]
test_results_filename:
description: "What is the name of the jUnit XML test output? (Optional)"
default: ""
type: string
update_dependency:
description: "Update a dependency before running the command (Optional)"
default: ""
type: string
mypy_strict:
description: "mypy will use --strict"
type: boolean
default: false
allow_fail:
description: "Allow the command to fail without failing job."
type: boolean
default: false
production_with_new_migrations:
description: "Test if deployed code will work with new migrations."
type: boolean
default: false
steps:
# Section 1: Prepare environment
- checkout_with_submodules
Expand Down Expand Up @@ -624,9 +624,9 @@ workflows:
- python_job:
name: mypy strict type check
command: mypy
test_results_filename: "mypy-strict.xml"
mypy_strict: true
allow_fail: true
mypy_strict: true
test_results_filename: "mypy-strict.xml"
filters: *default_filters

- python_job:
Expand All @@ -639,28 +639,28 @@ workflows:
- python_job:
name: pytest with postgres << matrix.postgres_version >>
command: pytest
test_results_filename: "pytest-postgres-<< matrix.postgres_version >>.xml"
executor: python_with_postgres
matrix:
parameters:
postgres_version: ["15.5", "16.1"]
executor: python_with_postgres
test_results_filename: "pytest-postgres-<< matrix.postgres_version >>.xml"
filters: *default_filters

- python_job:
name: sqlite migrations test
command: pytest
test_results_filename: "sqlite3-migrations.xml"
pytest_fail_fast: true
production_with_new_migrations: true
pytest_fail_fast: true
test_results_filename: "sqlite3-migrations.xml"
filters: *default_filters

- python_job:
name: postgres migrations test
command: pytest
executor: "python_with_postgres"
test_results_filename: "postgres-migrations.xml"
pytest_fail_fast: true
production_with_new_migrations: true
pytest_fail_fast: true
test_results_filename: "postgres-migrations.xml"
filters: *default_filters

- python_job:
Expand All @@ -673,19 +673,26 @@ workflows:
- python_job:
name: django 5.0 test
command: pytest
allow_fail: true
pytest_fail_fast: true
test_results_filename: pytest-django-5-0.xml
update_dependency: "Django>=5.0,<5.1"
allow_fail: true
filters: *default_filters

- python_job:
name: python 3.12 test
python_version: "3.12"
python_version: "3.12.7"
command: pytest
pytest_fail_fast: true
test_results_filename: pytest-python-3-12.xml
filters: *default_filters
Comment on lines 683 to +687
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (non-blocking): Should we alphabetize these? Or at least make their order consistent in each python job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm ordering the python_job job definition, then ordering the workflow definitions:

  • python_job.executor parameters
    • name
    • postgres_version (as a matrix for the postgres jobs)
    • python_version
    • variant
  • python_job parameters
    • allow_fail
    • command
    • executor
    • mypy_strict
    • production_with_new_migrations
    • pytest_fail_fast
    • pytest_phones_backend
    • test_results_filename
    • update_dependency
  • workflow parameters
    • filters
    • (matrix could go here since it is a workflow parameter)


- python_job:
name: python 3.13 test
python_version: "3.13"
allow_fail: true
command: pytest
pytest_fail_fast: true
test_results_filename: pytest-python-3-13.xml
filters: *default_filters

- python_job:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.8
FROM python:3.11.10

ARG CIRCLE_BRANCH
ARG CIRCLE_SHA1
Expand Down
5 changes: 4 additions & 1 deletion api/tests/emails_views_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,11 @@ def test_first_forwarded_email_unknown_mask(free_api_client: APIClient) -> None:


def test_first_forwarded_email_success(
free_api_client: APIClient, free_user: User
free_api_client: APIClient,
free_user: User,
settings: SettingsWrapper,
) -> None:
settings.RELAY_FROM_ADDRESS = "[email protected]"
address = free_user.relayaddress_set.create()
with (
override_flag("free_user_onboarding", True),
Expand Down
2 changes: 1 addition & 1 deletion docs/developer_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ joined by whitespace, such as newlines, before sending it to

[Ascii85]: https://en.wikipedia.org/wiki/Ascii85
[MozLog format]: https://wiki.mozilla.org/Firefox/Services/Logging#MozLog_application_logging_standard
[base64.a85encode]: https://docs.python.org/3.11/library/base64.html#base64.a85encode
[base64.a85encode]: https://docs.python.org/3/library/base64.html#base64.a85encode
[zlib.compress]: https://docs.python.org/3/library/zlib.html
[zlib]: https://docs.python.org/3/library/zlib.html
4 changes: 2 additions & 2 deletions emails/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
import zlib
from collections.abc import Callable
from email.errors import InvalidHeaderDefect
from email.errors import HeaderParseError, InvalidHeaderDefect
from email.headerregistry import Address, AddressHeader
from email.message import EmailMessage
from email.utils import formataddr, parseaddr
Expand Down Expand Up @@ -301,7 +301,7 @@ def generate_from_header(original_from_address: str, relay_mask: str) -> str:
display_name, original_address = parseaddr(oneline_from_address)
try:
parsed_address = Address(addr_spec=original_address)
except (InvalidHeaderDefect, IndexError) as e:
except (InvalidHeaderDefect, IndexError, HeaderParseError) as e:
# TODO: MPP-3407, MPP-3417 - Determine how to handle these
raise InvalidFromHeader from e

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dockerflow==2024.4.2
drf-spectacular==0.27.2
drf-spectacular-sidecar==2024.7.1
glean_parser==15.2.0
google-cloud-profiler==4.1.0
google-cloud-profiler==4.1.0; python_version < '3.13'
google-cloud-sqlcommenter==2.0.0; python_version < '3.12'
gunicorn==23.0.0
jwcrypto==1.5.6
Expand Down
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.11.8
python-3.11.10