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

feat: docker-based local work without lms #420

Merged
merged 1 commit into from
Sep 6, 2023
Merged

Conversation

johnnagro
Copy link
Contributor

TLDR

Adds a make test-shell which launches a dockerized version of the local dev environment - rather than using a local virtualenv.

Description

~ Working from openedx/edx-enterprise#1467 ~

There are sometimes benefits and conveniences to having a containerized local environment versus setting up and maintaining python, virtualenv, and system dependencies (mysql-dev, etc) natively. Sometimes installing your code into the LMS container extends your testing cycle past your patience. Here is some docker/makefile config to enable make test-shell to launch a containerized environment containing your local development code so you can make test / make upgrade / 'profit' / etc inside a container.

Action!

pytest

ubuntu@ip-172-31-38-188:~/edx-repos/edx-arch-experiments$ make test-shell
docker-compose run -u 0 test-shell env TERM=xterm-256color /bin/bash
root@app:/edx/app/edx-arch-experiments# ls
CHANGELOG.rst       Dockerfile            edx_arch_experiments.egg-info  manage.py     pylintrc         README.rst    setup.py
codecov.yml         docs                  LICENSE.txt                    MANIFEST.in   pylintrc_backup  requirements  test_settings.py
docker-compose.yml  edx_arch_experiments  Makefile                       openedx.yaml  pylintrc_tweaks  setup.cfg     tox.ini
root@app:/edx/app/edx-arch-experiments# pytest
================================================================== test session starts ===================================================================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.2.0
django: settings: test_settings (from env)
rootdir: /edx/app/edx-arch-experiments
configfile: tox.ini
plugins: django-4.5.2, cov-4.1.0
collected 1 item                                                                                                                                         

edx_arch_experiments/tests/test_stub.py .                                                                                                          [100%]

---------- coverage: platform linux, python 3.8.10-final-0 -----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
edx_arch_experiments/__init__.py                  1      0   100%
edx_arch_experiments/apps.py                      5      0   100%
edx_arch_experiments/settings/__init__.py         0      0   100%
edx_arch_experiments/settings/common.py           2      2     0%   6-7
edx_arch_experiments/settings/production.py       2      2     0%   4-5
edx_arch_experiments/settings/scripts.py          4      4     0%   4-8
edx_arch_experiments/tests/test_stub.py           1      0   100%
---------------------------------------------------------------------------
TOTAL                                            15      8    47%
Coverage XML written to file coverage.xml


=================================================================== 1 passed in 0.14s ====================================================================
root@app:/edx/app/edx-arch-experiments#

make validate

ubuntu@ip-172-31-38-188:~/edx-repos/edx-arch-experiments$ make test-shell
docker-compose run -u 0 test-shell env TERM=xterm-256color /bin/bash
root@app:/edx/app/edx-arch-experiments# make validate
tox -e quality
GLOB sdist-make: /edx/app/edx-arch-experiments/setup.py
quality inst-nodeps: /edx/app/edx-arch-experiments/.tox/.tmp/package/1/edx-arch-experiments-2.0.0.zip
quality installed: asgiref==3.7.2,astroid==2.15.6,bleach==6.0.0,certifi==2023.5.7,cffi==1.15.1,charset-normalizer==3.2.0,click==8.1.5,click-log==0.4.0,code-annotations==1.3.0,coverage==7.2.7,cryptography==41.0.2,dill==0.3.6,Django==3.2.20,django-crum==0.7.9,django-waffle==3.0.0,docutils==0.20.1,edx-arch-experiments @ file:///edx/app/edx-arch-experiments/.tox/.tmp/package/1/edx-arch-experiments-2.0.0.zip#sha256=a10aea254751c177b241f25962cbc75e226602ab2e823a8e42297e3437284c51,edx-django-utils==5.5.0,edx-lint==5.3.4,exceptiongroup==1.1.2,idna==3.4,importlib-metadata==6.8.0,importlib-resources==6.0.0,iniconfig==2.0.0,isort==5.12.0,jaraco.classes==3.3.0,jeepney==0.8.0,Jinja2==3.1.2,keyring==24.2.0,lazy-object-proxy==1.9.0,markdown-it-py==3.0.0,MarkupSafe==2.1.3,mccabe==0.7.0,mdurl==0.1.2,more-itertools==9.1.0,newrelic==8.8.1,packaging==23.1,pbr==5.11.1,pkginfo==1.9.6,platformdirs==3.9.1,pluggy==1.2.0,psutil==5.9.5,pycodestyle==2.10.0,pycparser==2.21,pydocstyle==6.3.0,Pygments==2.15.1,pylint==2.17.4,pylint-celery==0.3,pylint-django==2.5.3,pylint-plugin-utils==0.8.2,PyNaCl==1.5.0,pytest==7.4.0,pytest-cov==4.1.0,pytest-django==4.5.2,python-slugify==8.0.1,pytz==2023.3,PyYAML==6.0.1,readme-renderer==40.0,requests==2.31.0,requests-toolbelt==1.0.0,rfc3986==2.0.0,rich==13.4.2,SecretStorage==3.3.3,six==1.16.0,snowballstemmer==2.2.0,sqlparse==0.4.4,stevedore==5.1.0,text-unidecode==1.3,tomli==2.0.1,tomlkit==0.11.8,twine==4.0.2,typing_extensions==4.7.1,urllib3==2.0.3,webencodings==0.5.1,wrapt==1.15.0,zipp==3.16.2
quality run-test-pre: PYTHONHASHSEED='728355740'
quality run-test: commands[0] | pylint edx_arch_experiments manage.py setup.py
quality run-test: commands[1] | pycodestyle edx_arch_experiments manage.py setup.py
quality run-test: commands[2] | pydocstyle edx_arch_experiments manage.py setup.py
quality run-test: commands[3] | isort --check-only --diff edx_arch_experiments manage.py setup.py test_settings.py
quality run-test: commands[4] | make selfcheck
The Makefile is well-formed.
________________________________________________________________________ summary _________________________________________________________________________
  quality: commands succeeded
  congratulations :)
tox -e pii_check
ERROR: unknown environment 'pii_check'
make: *** [Makefile:63: pii_check] Error 1
root@app:/edx/app/edx-arch-experiments#

Copy link

@marlonkeating marlonkeating left a comment

Choose a reason for hiding this comment

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

Solution works well on my end!

Dockerfile Outdated
@@ -0,0 +1,98 @@
# Docker in this repo is only supported for running tests locally
# as an alternative to virtualenv natively - johnnagro 2022-02-11

Choose a reason for hiding this comment

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

Update date?

Makefile Outdated
@@ -105,3 +105,8 @@ dummy_translations: ## generate dummy translation (.po) files
build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files

validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations

## Docker in this repo is only supported for running tests locally
## as an alternative to virtualenv natively - johnnagro 2022-02-11

Choose a reason for hiding this comment

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

Another date to update

@@ -0,0 +1,24 @@
# Docker in this repo is only supported for running tests locally
# as an alternative to virtualenv natively - johnnagro 2022-02-11

Choose a reason for hiding this comment

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

Another date to update

@johnnagro johnnagro force-pushed the johnnagro/test-shell/0 branch from ff8bf8d to 5a71dbc Compare September 6, 2023 18:09
@johnnagro johnnagro merged commit fedfd9e into main Sep 6, 2023
4 checks passed
@johnnagro johnnagro deleted the johnnagro/test-shell/0 branch September 6, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants