From 885e0b955722e4d86f89547764537ee74f707cf9 Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Wed, 26 Jun 2024 18:11:43 -0500 Subject: [PATCH 1/4] perf: add support to redwood --- README.md | 5 +++-- setup.cfg | 2 +- setup.py | 2 +- tutordistro/__about__.py | 2 +- tutordistro/patches/openedx-dockerfile-pre-assets | 15 +++++++-------- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f0de920..075e68d 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,13 @@ Please see the following table for details on compatibility. | olive | v15 | | palm | v16 | | quince | v17 | +| redwood | v18 | Then, specify the docker image variables to identify your custom images, like the example: ```yaml -DOCKER_IMAGE_OPENEDX: 'docker.io/ednxops/distro-edunext-edxapp:quince' -DOCKER_IMAGE_OPENEDX_DEV: 'docker.io/ednxops/distro-edunext-edxapp-dev:quince' +DOCKER_IMAGE_OPENEDX: "docker.io/ednxops/distro-edunext-edxapp:redwood" +DOCKER_IMAGE_OPENEDX_DEV: "docker.io/ednxops/distro-edunext-edxapp-dev:redwood" ``` Finally, launch your instance or build a new image to reflect the changes. diff --git a/setup.cfg b/setup.cfg index 9d74dc0..b389914 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 17.2.0 +current_version = 18.0.0 commit = False tag = False diff --git a/setup.py b/setup.py index 7e381b6..42d6c45 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def load_about(): packages=find_packages(), include_package_data=True, python_requires=">=3.8", - install_requires=["tutor>=17.0.3, <18", "click", "schema"], + install_requires=["tutor>=18.0.0, <19", "click", "schema"], extras_require={ "test": ["behave", "pytest", "pylint", "pytest-mock", "pycodestyle", "isort", "schema"] }, diff --git a/tutordistro/__about__.py b/tutordistro/__about__.py index 383f31f..e7ec03d 100644 --- a/tutordistro/__about__.py +++ b/tutordistro/__about__.py @@ -2,4 +2,4 @@ Tutor Distro version. """ -__version__ = "17.2.0" +__version__ = "18.0.0" diff --git a/tutordistro/patches/openedx-dockerfile-pre-assets b/tutordistro/patches/openedx-dockerfile-pre-assets index 94c3c62..a315fc7 100644 --- a/tutordistro/patches/openedx-dockerfile-pre-assets +++ b/tutordistro/patches/openedx-dockerfile-pre-assets @@ -1,16 +1,15 @@ ENV NO_PYTHON_UNINSTALL 1 ENV NO_PREREQ_INSTALL 1 -RUN openedx-assets xmodule \ - && openedx-assets npm \ - && openedx-assets webpack --env=prod \ - && openedx-assets common +RUN npm run postinstall \ + && npm run webpack \ + && npm run compile-sass -- --skip-themes {% if DISTRO_THEMES_ROOT is defined %} COPY --chown=app:app ./themes/ {{ DISTRO_THEMES_ROOT }} {% endif %} {% if DISTRO_THEME_DIRS is defined and DISTRO_THEMES_NAME is defined %} -RUN openedx-assets themes \ - --theme-dirs {{ DISTRO_THEME_DIRS | join(' ') }} \ - --themes {{ DISTRO_THEMES_NAME | join(' ') }} \ - && openedx-assets collect --settings=tutor.assets \ +RUN npm run compile-sass -- \ + --theme-dir {{ DISTRO_THEME_DIRS | join(' --theme-dir ') }} \ + --theme {{ DISTRO_THEMES_NAME | join(' --theme ') }} \ + && ./manage.py lms collectstatic --noinput --settings=tutor.assets \ && rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/ {% endif %} From 1924007d121b46c9dc5949810f1e7f89fdf0fad2 Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Thu, 27 Jun 2024 08:54:37 -0500 Subject: [PATCH 2/4] fix: freeze when 'enable-themes' was execute twice When 'enable-themes' was executed before, a new execution failed overriding the existing folder --- .../infrastructure/tutor_commands.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py b/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py index dbc78f3..8c92dba 100644 --- a/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py +++ b/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py @@ -69,17 +69,24 @@ def run_command(self, command: str): command (str): Tutor command. """ try: - process = subprocess.run( + print(f'Running "{command}"') + + with subprocess.Popen( command, shell=True, - check=True, - capture_output=True, executable="/bin/bash", - ) - # This print is left on purpose to show the command output - print(process.stdout.decode()) + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) as process: + + stdout, stderr = process.communicate(input="y") + + if process.returncode != 0 or "error" in stderr.lower(): + raise subprocess.CalledProcessError( + process.returncode, command, output=stdout, stderr=stderr + ) except subprocess.CalledProcessError as error: - raise CommandError( - f"Error running command '{error.cmd}':\n{error.stderr.decode()}" - ) from error + raise CommandError(f"\n{error.stderr}") from error From e18653779ece74352b82e500478bd5d439a2cdd5 Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Thu, 27 Jun 2024 10:17:47 -0500 Subject: [PATCH 3/4] refactor: update changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab68756..f7152c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## v18.0.0 - 2024-06-27 + +### [18.0.0](https://github.com/eduNEXT/tutor-contrib-edunext-distro/compare/v17.2.0...v18.0.0) (2024-06-27) + +#### ⚠ BREAKING CHANGES + +* Add support to Redwood ([885e0b9](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/885e0b955722e4d86f89547764537ee74f707cf9)); the main change + +* Fix when 'tutor distro enable-themes' was executed before, a new execution hung when it tried to overwrite the existing theme folder. The process requires confirmation ('yes') to proceed with the overwrite, but it did not receive this input automatically, leading to a freeze ([1924007](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/1924007d121b46c9dc5949810f1e7f89fdf0fad2)) + ## v17.2.0 - 2024-04-05 ### [17.2.0](https://github.com/eduNEXT/tutor-contrib-edunext-distro/compare/v17.1.0...v17.2.0) (2024-04-05) From e07025033f8b86b1e6262b539dbe6a101bcddc9a Mon Sep 17 00:00:00 2001 From: Brayan Ceron Date: Mon, 8 Jul 2024 12:56:18 -0500 Subject: [PATCH 4/4] refactor: address the feedback given * refactor: improve & update method of compiling themes * refactor: enhance extra command logs * docs: Clarify & complement changelog entry --- CHANGELOG.md | 6 ++++-- README.md | 6 ++++-- .../distro/extra_commands/infrastructure/tutor_commands.py | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7152c1..89534e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 #### ⚠ BREAKING CHANGES -* Add support to Redwood ([885e0b9](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/885e0b955722e4d86f89547764537ee74f707cf9)); the main change +* [Feature] Add support to Redwood ([885e0b9](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/885e0b955722e4d86f89547764537ee74f707cf9)) -* Fix when 'tutor distro enable-themes' was executed before, a new execution hung when it tried to overwrite the existing theme folder. The process requires confirmation ('yes') to proceed with the overwrite, but it did not receive this input automatically, leading to a freeze ([1924007](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/1924007d121b46c9dc5949810f1e7f89fdf0fad2)) +* [Bugfix] Adapt the inline Tutor plugin `openedx-dockerfile-pre-assets` to stop using the deprecated command [openedx-assets](https://github.com/overhangio/tutor/blob/master/CHANGELOG.md#v1800-2024-06-19:~:text=%F0%9F%92%A5%5BFeature%5D%20The%20openedx,or%20cms%20container%3A) for setting the pre-assets of the custom themes added with Distro ([885e0b9](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/885e0b955722e4d86f89547764537ee74f707cf9#diff-d32c8a1ee8b6076c6fb3375498a9d455d41cad3104464e9b1e3900fd4265160a)) + +* [Bugfix] 'tutor distro enable-themes' command would hang when trying to overwrite an existing theme folder due to not being able to read the confirmation input ('yes') to perform the overwrite ([1924007](https://github.com/eduNEXT/tutor-contrib-edunext-distro/commit/1924007d121b46c9dc5949810f1e7f89fdf0fad2)). ## v17.2.0 - 2024-04-05 diff --git a/README.md b/README.md index 075e68d..a632d84 100644 --- a/README.md +++ b/README.md @@ -237,14 +237,16 @@ tutor distro enable-themes > tutor images build openedx-dev > tutor dev do init > tutor dev start -> tutor dev run lms openedx-assets themes --theme-dirs [THEME_DIRS] --themes [THEME_NAMES] +> tutor dev exec lms bash +> npm run compile-sass -- --theme-dir X --theme-dir Y --theme A --theme B > ``` > > or > > ```bash > tutor dev launch -> tutor dev run lms openedx-assets themes --theme-dirs [THEME_DIRS] --themes [THEME_NAMES] +> tutor dev exec lms bash +> npm run compile-sass -- --theme-dir X --theme-dir Y --theme A --theme B > ``` # Commands diff --git a/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py b/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py index 8c92dba..f998695 100644 --- a/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py +++ b/tutordistro/distro/extra_commands/infrastructure/tutor_commands.py @@ -69,8 +69,6 @@ def run_command(self, command: str): command (str): Tutor command. """ try: - print(f'Running "{command}"') - with subprocess.Popen( command, shell=True, @@ -81,6 +79,7 @@ def run_command(self, command: str): text=True, ) as process: + # It is sent a 'y' to say 'yes' on overriding the existing folders stdout, stderr = process.communicate(input="y") if process.returncode != 0 or "error" in stderr.lower(): @@ -88,5 +87,8 @@ def run_command(self, command: str): process.returncode, command, output=stdout, stderr=stderr ) + # This print is left on purpose to show the command output + print(stdout) + except subprocess.CalledProcessError as error: raise CommandError(f"\n{error.stderr}") from error