build: Set Django version for tests more safely; drop support for non-GHA - #31387
Conversation
96ba09e to
18c7365
Compare
There was a problem hiding this comment.
[Author's note] I believe that sh will pass through the PIP_SRC environment variable. This sh is actually from paver.shell, but it defaults to env=None and passes that to Popen, which should pass through the caller's environment for None.
There was a problem hiding this comment.
[Author's note] I'm not sure if this was really correct in the first place -- shouldn't the quality checks be using dev deps (pylint will complain about missing django-debug-toolbar) and pytest be using just testing deps?
There was a problem hiding this comment.
We're looking into the feasibility of ripping out this paver code anyway; note that the GitHub Actions workflows already use pylint directly instead of going through paver.
6a2eacc to
11009ff
Compare
11009ff to
c395d93
Compare
96dac6c to
bb8b8b5
Compare
bb8b8b5 to
7021e12
Compare
…-GHA We have a need to lock the version of Django for production and tests, but also to test on newer versions of Django so that we can get the repo ready for long-term-support releases. We've been doing that by extracting the `django==x.y.z` from the pip-compiled files and moving it to a django.txt that is then co-installed but can be overridden during tests. The problem is that this can result in broken packages. The approach here is to have `make test-requirements` continue to ensure a consistent set of packages, and then install a different Django on top of that in the CI script -- and call `pip check` to make sure that combination isn't broken. Adding Django 4.0 to the unit-tests.yml matrix will now correctly result in this error and a failing job: `django-splash 1.2.1 has requirement Django<4.0, but you have django 4.0.8.` The other half of this is to change other CI runners to remove their ability to control the Django version, since it's complicated to make this work, and we probably only need it in unit-tests.yml. Convert them to just use `make test-requirements`. Also: - Simplify handling of `pip --src` by setting `PIP_SRC` (rather than our own `PIP_SRC_DIR`, which pip ignores because `--src-dir` isn't an option that it knows). This is needed to allow `make test-requirements` to do the pip calls. An alternative would be to set a pip-options env var for the make target to use, but `PIP_SRC` already exists. - Remove outdated modifications to common_constraints - Add comment explaining why pylint tests need dev-requirements
7021e12 to
760fdc7
Compare
jmbowman
left a comment
There was a problem hiding this comment.
Would have saved you some time if we'd already done the cleanup pass of all the old Jenkins cruft first...oh well. Looks pretty good, just a couple of suggestions.
There was a problem hiding this comment.
We're looking into the feasibility of ripping out this paver code anyway; note that the GitHub Actions workflows already use pylint directly instead of going through paver.
| distlib==0.3.6 | ||
| # via virtualenv | ||
| django==3.2.16 | ||
| # via |
There was a problem hiding this comment.
Ha, kind of funny that we were ripping out the dependency but leaving the comments for it.
| COPY requirements/edx/django.txt requirements/edx/django.txt | ||
| RUN pip install -r requirements/pip.txt && \ | ||
| pip install -r requirements/edx/testing.txt -r requirements/edx/django.txt | ||
| RUN make test-requirements |
There was a problem hiding this comment.
Don't you need to copy in the Makefile also to be able to run this?
There was a problem hiding this comment.
Hmm, seems likely! Adding that. :-)
| @@ -1,5 +1,5 @@ | |||
| [tox] | |||
| envlist = py38-django{32}, quality-django{32} | |||
| envlist = py38, quality | |||
There was a problem hiding this comment.
Can we leave this as it was, but still make your change later in the file? I think the suffixes are harmless for now, and will be needed later when we start testing 4.0 and 4.1. And I like being more explicit about which Django version is being tested.
There was a problem hiding this comment.
I'm not sure what benefit they would provide -- tox would no longer be controlling the Django version, and still wouldn't be once 4.x testing starts.
There was a problem hiding this comment.
It would be for local testing of the 4.x upgrade. But I suppose it would be clearer to remove this for now and just add it back once it's actually implemented when we start that testing.
There was a problem hiding this comment.
I think for local testing what we'd want is just a branch where Django is upgraded to 4.x and tests are otherwise run as normal.
iamsobanjaved
left a comment
There was a problem hiding this comment.
LGTM. All changes were nicely explained
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
This is for #31374
We have a need to lock the version of Django for production and tests, but also to test on newer versions of Django so that we can get the repo ready for long-term-support releases.
We've been doing that by extracting the
django==x.y.zfrom the pip-compiled files and moving it to a django.txt that is then co-installed but can be overridden during tests. The problem is that this can result in broken packages.The approach here is to have
make test-requirementscontinue to ensure a consistent set of packages, and then install a different Django on top of that in the CI script -- and callpip checkto make sure that combination isn't broken.Adding Django 4.0 to the unit-tests.yml matrix will now correctly result in this error and a failing job:
django-splash 1.2.1 has requirement Django<4.0, but you have django 4.0.8.The other half of this is to change other CI runners to remove their ability to control the Django version, since it's complicated to make this work, and we probably only need it in unit-tests.yml. Convert them to just use
make test-requirements.Also:
pip --srcby settingPIP_SRC(rather than our ownPIP_SRC_DIR, which pip ignores because--src-dirisn't an option that it knows). This is needed to allowmake test-requirementsto do the pip calls. An alternative would be to set a pip-options env var for the make target to use, butPIP_SRCalready exists.Guide to the files in this PR:
Makefile: Used by all of the other files here --make test-requirementsis what we'll use for all test-dependencies installation going forward. Only changes here are tomake compile-requirements(shared bymake upgrade) in order to undo the testing.txt/django.txt split.requirements/edx/testing.txtandrequirements/edx/django.txtare changed as part of this.github/workflows/unit-tests.yml: Our mainpytestCI runner; runs as a GitHub Action but uses theedx-platform-runnerhosted by 2U. Only runs for edx-platform's main copy and a private fork.scripts/ci-runner.Dockerfileseems to be the docker image for this runner4.0to the matrix causes the appropriate failures (conflict with django-splash)..github/workflows/unit-tests-gh-hosted.yml: Same role, but runs on any other fork of edx-platform instead, and uses GHA runners (slower). Should be otherwise identical..github/workflows/pylint-checks.yml: Our mainpylint` checks.github/workflows/quality-checks.yml: Runs various other quality checks usingscripts/generic-ci-tests.sh(via./scripts/all-tests.sh`, unaffected here) which calls paver via toxtox.ini: Configures the tox testing environment, used here for quality checks; I've removed the "django" specifiers from its environments.scripts/xdist/prepare_xdist_nodes.shcallsscripts/xdist/setup_worker.shscripts/unit-tests.sh(unaffected by PR) calls in to these via generic-ci-tests.sh, but only if environment variableTEST_SUITEis set to one of lms-unit, cms-unit, or pavelib-unitTEST_SUITE=lms-unit SHARD=1 scripts/generic-ci-tests.shsuccessfully after runningmake lms-upin devstack. Calling that good enough.scripts/jenkins-common.shseems to be part of our old (now shut down) Jenkins test runnerspavelib/prereqs.pyinstalls Python dependencies for paver runs (used for quality checks, among other things)pavelib/utils/envs.pyis used by thispavelib/tests.pyandpavelib/utils/test/suites/pytest_suite.py