Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

build: add python 3.11 and 3.12 ci checks #4153

Conversation

Danyal-Faheem
Copy link
Contributor

@Danyal-Faheem Danyal-Faheem commented Apr 18, 2024

⛔️ MAIN BRANCH WARNING! 2U EMPLOYEES must make branches against the 2u/main BRANCH

  • I have checked the branch to which I would like to merge.

⛔️ DEPRECATION WARNING

Anyone internally merging to this repository is expected to release and monitor their changes; if you are not able to do this DO NOT MERGE, please coordinate with someone who can to ensure that the changes are released.

Required Testing

  • Before deploying this change, complete a purchase in the stage environment.
    (^ We can remove that manual check once REV-2624 is done and the corresponding e2e test runs again)

Description

  • Added CI checks as part of the upgrade process to python 3.11 and python 3.12.
  • Also fixes one part of the downstream issue in tutor-ecommerce.
  • Updated docker-compose to docker compose.
  • Install python3.x in the container and its dependencies for testing.
  • Run tox as python3.x -m tox to make sure tox is run in the specific python environment.
  • Added the PYTHON_ENV and PYTHON_VERSION variables to utilize the matrix values to test against multiple python versions.
  • Updated the tox.ini fle to include py311 and py312 as well.
  • Build docs against python 3.11 and 3.12 as well.
  • Updated requirements and removed certain constraints to make them compatible with py311 and py312.
  • Run migrations on pending models.
  • Update pylintrc with new warnings to ignore after updating pylint version.

@Danyal-Faheem Danyal-Faheem requested a review from a team as a code owner April 18, 2024 09:22
@DawoudSheraz
Copy link
Contributor

@feanil Hi. Can you run the workflows on this PR, please? Thanks

Copy link

@andrey-canon andrey-canon left a comment

Choose a reason for hiding this comment

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

Hi @Danyal-Faheem, firstly, I would like to ask to fix the automatic tests and secondly, these changes are not doing what is supposed to do since this is triggering 3 different actions but all of them are running with python 3.8 indeed the 3.12 test shouldn't pass since that depends on #4147

@Danyal-Faheem
Copy link
Contributor Author

Hi @andrey-canon. Thank you for pointing out the problem. The Dockerfile is currently forcing python3.8 in the containers. I'll update the PR to allow different python versions to be installed.

@Danyal-Faheem Danyal-Faheem force-pushed the danyalfaheem/add-python-3.11-ci-checks branch from 5955824 to 7caffb5 Compare May 3, 2024 11:23
@Danyal-Faheem Danyal-Faheem changed the title ci: add python 3.11 and 3.12 checks build: add python 3.11 and 3.12 ci checks May 3, 2024
@feanil
Copy link
Contributor

feanil commented May 9, 2024

@Danyal-Faheem do we have an update on this PR? It looks like once we get it working, we'll need to backport this to Redwood as well.

@feanil feanil linked an issue May 9, 2024 that may be closed by this pull request
@Danyal-Faheem
Copy link
Contributor Author

Hi @feanil, we're still working on this PR. It needs some changes in the Dockerfile as well. We will try to get it done as soon as possible so that we can backport it to redwood.

@Danyal-Faheem Danyal-Faheem force-pushed the danyalfaheem/add-python-3.11-ci-checks branch from 7caffb5 to 0190f4d Compare May 28, 2024 09:59
@Faraz32123
Copy link

@Danyal-Faheem and I have tested the changes, there's still some python tests failing under test-python workflow.
We have added pylintrc file to ignore some of the pylint warnings. We also had to upgrade some requirements so that CI checks also work with python 3.(8,11,12).
Thats the update for now!

@feanil feanil requested a review from andrey-canon May 28, 2024 14:04
@Faraz32123 Faraz32123 force-pushed the danyalfaheem/add-python-3.11-ci-checks branch from 3f976dd to ce381be Compare May 31, 2024 07:57
pin django-oscar to 3.2,
removed migrations,
replace depreciated assertDictContainsSubset method with python code
@Faraz32123
Copy link

Hi @feanil, this PR is ready for review. Can you take a look? Thanks.

pylintrc_backup Outdated
@@ -0,0 +1,294 @@
[MASTER]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this file wont be needed.

@@ -31,6 +31,7 @@ edx-django-utils
edx-drf-extensions>=8.13.0 # 8.13 fixes forgiven JWTs for ecommerce
edx-django-sites-extensions
edx-ecommerce-worker
edx-lint
Copy link
Contributor

@DawoudSheraz DawoudSheraz May 31, 2024

Choose a reason for hiding this comment

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

rather than base, this should be in test.in as this is only needed during testing.

@@ -130,7 +130,18 @@ def _assert_success_checkout_page(self, sku=None):

response = self.client.get(self.path)
self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset({'course': self.course}, response.context)
if sys.version_info > (3, 9):
context = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment here to explain why this is needed would be helpful. Plus, see if this can be improved. There are a bit too many if-elses in the test.

Choose a reason for hiding this comment

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

adding a comment for now.

Choose a reason for hiding this comment

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

Will also look for the alternative for the if-else.

@@ -2,7 +2,7 @@
-r docs.txt

django-debug-toolbar

needle
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Choose a reason for hiding this comment

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

Its not longer needed, It was added to resolve conlicts. removing it.

@@ -12,3 +12,5 @@ ptvsd

# For devserver code reloading
pywatchman
astroid==3.2.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is astroid needed here? Furthermore, since the version has been constrained in constraints.txt, it wont be needed here.

Choose a reason for hiding this comment

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

astroid had a conflict with pylint version. So, it needs to be pinned.
I'll remove it from dev.in as it is in contraints.txt.

@@ -12,3 +12,5 @@ ptvsd

# For devserver code reloading
pywatchman
astroid==3.2.2
edx-lint
Copy link
Contributor

Choose a reason for hiding this comment

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

it won't be required here. Once it is added to test.in, it should start appearing in dev.txt

@Faraz32123
Copy link

Hi @feanil, this PR is ready for review. Can you take a look? Thanks.

Hello @feanil, Hope so you are doing well. A soft reminder for you. So that this issue can be closed. Thanks.

@Faraz32123
Copy link

Hello @andrey-canon,
Can u also have a look at this PR for me. Thanks.

@andrey-canon
Copy link

Hello @andrey-canon, Can u also have a look at this PR for me. Thanks.

Hi @Faraz32123, sure, no problem, however I cannot do that this week, so I will review this next one : D

@Faraz32123
Copy link

Hello @feanil and @andrey-canon, I hope you guys are doing well, a reminder for you guys to review this PR for this issue to be closed. Thanks.

Copy link

@andrey-canon andrey-canon left a comment

Choose a reason for hiding this comment

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

Most of the changes look good to me. I just left a suggestion related to the test changes because, personally, I don't see the point of implementing two different ways for different Python versions when one of them is compatible with both (I think I didn't test that). If so could you please apply that to all the tests modifications

@@ -130,7 +130,21 @@ def _assert_success_checkout_page(self, sku=None):

response = self.client.get(self.path)
self.assertEqual(response.status_code, 200)
self.assertDictContainsSubset({'course': self.course}, response.context)
if sys.version_info > (3, 9):
# assertDictContainsSubset is depreciated in python version>3.9

Choose a reason for hiding this comment

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

Suggested change
# assertDictContainsSubset is depreciated in python version>3.9
# assertDictContainsSubset is deprecated in Python version > 3.9

???

self.assertDictContainsSubset({'course': self.course}, response.context)
if sys.version_info > (3, 9):
# assertDictContainsSubset is depreciated in python version>3.9
# context.response return ContextList object, belwo statements will convert it to dict

Choose a reason for hiding this comment

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

Suggested change
# context.response return ContextList object, belwo statements will convert it to dict
# response.context returns a ContextList object; the below statements will convert it to a dict

??

if sys.version_info > (3, 9):
# assertDictContainsSubset is depreciated in python version>3.9
# context.response return ContextList object, belwo statements will convert it to dict
# assertLessEqual method is used instead of depreciated assertDictContainsSubset method

Choose a reason for hiding this comment

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

Suggested change
# assertLessEqual method is used instead of depreciated assertDictContainsSubset method
# assertLessEqual method is used instead of the deprecated assertDictContainsSubset method

Comment on lines 181 to 184
if sys.version_info > (3, 9):
self.assertLessEqual(expected.items(), last_request.headers.items())
else:
self.assertDictContainsSubset(expected, last_request.headers)

Choose a reason for hiding this comment

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

Suggested change
if sys.version_info > (3, 9):
self.assertLessEqual(expected.items(), last_request.headers.items())
else:
self.assertDictContainsSubset(expected, last_request.headers)
self.assertLessEqual(expected.items(), last_request.headers.items())

@@ -122,7 +123,10 @@ def test_post_enterprise_customer_user(self, mock_helpers, expected_return):
self.learner.username
)

self.assertDictContainsSubset(expected_return, response)
if sys.version_info > (3, 9):

Choose a reason for hiding this comment

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

same comment as above

@Faraz32123
Copy link

Hello @andrey-canon, thanks for the review. I have updated the code according to the requested changes. Can u look into it again so that we can finalize it.

@@ -1,6 +1,7 @@


import json
import sys

Choose a reason for hiding this comment

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

I think you can remove this from all the files

@Faraz32123 Faraz32123 force-pushed the danyalfaheem/add-python-3.11-ci-checks branch from 5035417 to 9360ac0 Compare June 14, 2024 09:14
Copy link

@andrey-canon andrey-canon left a comment

Choose a reason for hiding this comment

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

Thanks for applying all the suggested changes

CC @feanil LGTM

@feanil feanil merged commit 8a9be80 into openedx-unsupported:master Jun 20, 2024
20 checks passed
@Faraz32123
Copy link

Hello @feanil,
Can you also have a look at the backport PR to redwood and merge it.
Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ecommerce] Test Python 3.11 and 3.12
5 participants