Skip to content

Commit

Permalink
feat: add picasso commands in simple way (#2)
Browse files Browse the repository at this point in the history
* feat: add picasso commands in simple way

* test: add workflows and fix tests

* docs: add information in the readme

* test: fix tests

* fix: add importlib_resources for palm support

* fix: add commands in picasso installation

* feat: add backward compatibility

* fix: fix tests

* fix: add condition before MOUNTED_DIRECTORIES

* test: add integration tests

* fix: implement feedback improvements

Co-authored-by: Maria Grimaldi <[email protected]>

* fix: correct test

* docs: improve usage description

* fix: implement feedback

* test: add again the test-types

* fix: apply feedback about quick checks and separate methods

* docs: update the readme format

Co-authored-by: Brayan Cerón <[email protected]>

* chore: improve integration tests

* refactor: use handler to manage requirement tasks depending on tutor version

* refactor: improve the naming in enable_private_packages

* docs: improve code docs

* refactor: return all command error messages instead

* fix: check the commands inside the loop and format

* docs: add documentation about the type ignore

* fix: use typing Pattern instead of regex one

---------

Co-authored-by: Maria Grimaldi <[email protected]>
Co-authored-by: Brayan Cerón <[email protected]>
  • Loading branch information
3 people authored Aug 27, 2024
1 parent 79e39a1 commit bf51ed8
Show file tree
Hide file tree
Showing 12 changed files with 593 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint Commit Messages
on: [pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6
72 changes: 72 additions & 0 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Integration Tests
on: [pull_request]

jobs:
tutor-integration-test:
name: Integration with Tutor
strategy:
matrix:
tutor_version: ["<19.0.0", "<18.0.0", "<17.0.0", "<16.0.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Prepare Tutor & launch
run: |
pip install "tutor${{ matrix.tutor_version }}"
pip install -e .
TUTOR_ROOT="$(pwd)" tutor --version
TUTOR_ROOT="$(pwd)" tutor config save
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Enable the tutor plugin
run: |
TUTOR_ROOT="$(pwd)" tutor plugins enable picasso
TUTOR_ROOT="$(pwd)" tutor picasso -h
- name: Adding data to the config.yml
run: |
cat <<EOF >> config.yml
PICASSO_MANAGE_DPKG:
name: eox-manage
repo: [email protected]:eduNEXT/eox-manage.git
version: v5.2.0
PICASSO_THEMES:
- name: endx-saas-themes
repo: [email protected]:eduNEXT/ednx-saas-themes.git
version: master
PICASSO_EXTRA_COMMANDS:
- tutor plugins update
- tutor plugins index add https://raw.githubusercontent.com/eduNEXT/tutor-plugin-indexes/picasso_test/
- tutor plugins install mfe mfe_extensions aspects
- tutor plugins enable mfe mfe_extensions aspects
- tutor config save
EOF
- name: Check run-extra-commands
run: |
TUTOR_ROOT="$(pwd)" tutor picasso run-extra-commands
- name: Check enable-themes
run: |
TUTOR_ROOT="$(pwd)" tutor picasso enable-themes
- name: Check enable-private-packages
run: |
TUTOR_ROOT="$(pwd)" tutor picasso enable-private-packages
if grep -q 'eox-manage' env/build/openedx/requirements/private.txt; then
echo "'eox-manage' found in env/build/openedx/requirements/private.txt."
elif grep -q 'eox-manage' env/build/openedx/Dockerfile; then
echo "'eox-manage' found in env/build/openedx/Dockerfile."
else
echo "'eox-manage' not found for the building process."
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run tests

on:
pull_request:
branches: [master]
branches: [main]

jobs:
tests:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
recursive-include tutorpicasso/patches *
recursive-include tutorpicasso/templates *
recursive-include tutorpicasso/commands *
163 changes: 158 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
picasso plugin for `Tutor <https://docs.tutor.edly.io>`__
#########################################################
Picasso `Tutor`_ Plugin
#########################

picasso plugin for Tutor
|Maintainance Badge| |Test Badge|

.. |Maintainance Badge| image:: https://img.shields.io/badge/Status-Maintained-brightgreen
:alt: Maintainance Status
.. |Test Badge| image:: https://img.shields.io/github/actions/workflow/status/edunext/tutor-contrib-picasso/.github%2Fworkflows%2Ftests.yml?label=Test
:alt: GitHub Actions Workflow Test Status

Picasso is a `Tutor`_ plugin that streamlines and automates complex pre-build tasks into a cohesive command.

Current features include:

- Adding private requirements: install private packages or dependencies in edx-platform.
- Executing a bundle of commands: run multiple commands in a specific order with a single command.
- Adding themes: manage custom themes to personalize Open edX.

This plugin is based on https://github.com/eduNEXT/tutor-contrib-edunext-distro


Installation
Expand All @@ -11,15 +26,153 @@ Installation
pip install git+https://github.com/eduNEXT/tutor-contrib-picasso
Usage
*****
Enable the plugin
******************

.. code-block:: bash
# To enable the plugin
tutor plugins enable picasso
# Show the picasso commands
tutor picasso -h
.. note::

Please remember to run these commands before you build your images.


Compatibility notes
*******************

This plugin was tested from Olive release.

Usage
*******

Enable Private Packages
^^^^^^^^^^^^^^^^^^^^^^^^

To enable the installation of private Open edX Django apps, follow these steps:

1. Add configuration to the configuration file

First, add the necessary configuration in your Tutor environment's ``config.yml`` file:

.. code-block:: yaml
PICASSO_<YOUR_PACKAGE_NAME>_DPKG:
name: <your_package_name>
repo: <your SSH URL for cloning the repo. e.g., [email protected]:yourorg/package.git>
version: <your branch, tag o release for cloning. e.g., v5.2.0>
.. note::

It is needed to use the SSH URL to clone private packages.

2. Save the configuration with ``tutor config save``

3. Run the following command to enable private packages:

.. code-block:: bash
# Enable private packages
tutor picasso enable-private-packages
This command allows the installation of private Open edX Django apps. It clones the private repository and, through the ``tutor mounts`` command, adds it to the Dockerfile for inclusion in the build process.

.. warning::

For the mount to work correctly and include the package in the Dockerfile, it must be added to a tutor filter ``MOUNTED_DIRECTORIES``. By default, Picasso adds ``eox-*`` packages. If you need to add another private package, don't forget to include this configuration in a Tutor plugin.

.. code-block:: python
hooks.Filters.MOUNTED_DIRECTORIES.add_items(
[
("openedx", "<your_package_name>"),
]
)
.. note::

If you want to use public packages, we recommend using the ``OPEN_EDX_EXTRA_PIP_REQUIREMENTS`` variable in the ``config.yml`` of your Tutor environment.


Enable Themes
^^^^^^^^^^^^^^

To enable themes in your Tutor environment, follow these steps:

1. Add the necessary configuration in your Tutor environment's ``config.yml`` file:

.. code-block:: yaml
PICASSO_THEMES:
- name: <your_theme_name>
repo: <your SSH URL for cloning the repo. e.g., [email protected]:yourorg/theme.git>
version: <your branch, tag o release for cloning. e.g., edunext/redwood.master>
- name: <another_theme_name>
repo: <your SSH URL for cloning the repo. e.g., [email protected]:yourorg/another_theme.git>
version: <your branch, tag o release for cloning. e.g., edunext/redwood.blue>
.. note::

If your theme repository is public, you can also use the HTTPS URL in ``repo``.

2. Save the configuration with ``tutor config save``

3. Run the enable command

.. code-block:: bash
# Enable themes
tutor picasso enable-themes
This command clones your theme repository into the folder that Tutor uses for themes. Documentation available at `Installing custom theme`_ tutorial.

.. note::

Don't forget to add extra configurations in a Tutor plugin if your theme requires it.


Run Extra Commands
^^^^^^^^^^^^^^^^^^^

To execute a list of Tutor commands in your Tutor environment, follow these steps:

1. Add the necessary configuration in your Tutor environment's ``config.yml`` file:

.. code-block:: yaml
PICASSO_EXTRA_COMMANDS:
- <A tutor command. e.g., tutor plugins index add X>
- <A tutor command. e.g., tutor plugins install mfe>
- <A tutor command. e.g., tutor picasso enable-themes>
- <A tutor command. e.g., tutor config save>
.
.
.
2. Save the configuration with ``tutor config save``

3. Run the following command

.. code-block:: bash
# Run Tutor commands
tutor picasso run-extra-commands
This command allows you to run a list of Tutor commands. These commands are executed in bash and, for security reasons, are restricted to running only Tutor commands.


License
*******

This software is licensed under the terms of the AGPLv3.


.. _Tutor: https://docs.tutor.edly.io
.. _Installing custom theme: https://docs.tutor.edly.io/tutorials/theming.html#theming
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def load_about():
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.8",
install_requires=["tutor>=18.0.0,<19.0.0"],
install_requires=["tutor", "importlib_resources", "packaging"],
extras_require={
"dev": [
"tutor[dev]>=18.0.0,<19.0.0",
"tutor[dev]",
]
},
entry_points={
Expand Down
2 changes: 1 addition & 1 deletion tutorpicasso/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "18.0.0"
__version__ = "0.1.0"
23 changes: 23 additions & 0 deletions tutorpicasso/commands/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Picasso commands group.
"""

import click

from tutorpicasso.commands.enable_private_packages import enable_private_packages
from tutorpicasso.commands.enable_themes import enable_themes
from tutorpicasso.commands.run_extra_commands import run_extra_commands


@click.group(help="Run picasso commands")
def picasso() -> None:
"""
Main picasso command group.
This command group provides functionality to run picasso commands.
"""


picasso.add_command(enable_private_packages)
picasso.add_command(run_extra_commands)
picasso.add_command(enable_themes)
Loading

0 comments on commit bf51ed8

Please sign in to comment.