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

build: finish replacing paver assets #34554

Merged
merged 1 commit into from
May 6, 2024

Conversation

kdmccormick
Copy link
Member

@kdmccormick kdmccormick commented Apr 19, 2024

Description (for squashed commit)

Together, these changes make it so that all features of the Paver-based asset compilation system are supported with drop-in Paver-free replacements. The remaining Paver asset functions are trivial wrappers, which can be comfortably deleted before Sumac.

  • Turn ./manage.py ... compile_sass into a simple wrapper around npm run compile-sass
  • Turn paver webpack into a simple wrapper around npm run webpack
  • Turn pavelib.assets:collect_assets into a simple wrapper around ./manage.py ... collectstatic
  • Add/improve deprecation warnings for all Paver asset commands.
  • Load defaults for asset-related Django settings from environment variables. This allows the build to work without Python. For the settings which will be removed in Sumac, I've added deprecation warnings.
  • Change EDX_PLATFORM_THEME_DIRS env var to COMPREHENSIVE_THEME_DIRS. This simplifies the migration instructions, because all the new env vars now match their corresponding Django settings. This amends an ADR, but it should not be a breaking change because the env var was recently added (since Quince) and nobody should be using it yet.
  • Add a static asset guide at docs/static-assets.rst, and improve the "bare metal" docs in the README extracted and merged here: docs: improve 'bare metal' docs and add static assets reference #34678
  • Future-proof the static assets ADR with links. The linked pages will be kept up-to-date even if the ADR isn't.

Part of: #34467

Merge considerations

This needs to merge before Redwood (May 9) so that Paver can be safely removed before Sumac.

As soon as this merges, I'll re-communicate the Paver DEPR, which I've re-written to encompass all Paver commands and Paver-related settings.

Testing

Automated

All changed code will be hit by the static assets check and CI. I've also updated the paver and compile_sass test suites to check that the wrapped npm commands are as expected.

Manual

In a fresh edx-platform clone, I checked out master. Set up a venv and ran paver update_assets.

In another fresh clone, I checked out this branch. Set up venv and ran paver update_assets.

I compared the contents of the two clones, ensuring that built assets were identical.

Finally, in my Tutor environment, I ran make clean to delete all built assets, and then rebuilt with COMPREHENSIVE_THEMES_DIR=/openedx/themes paver update_assets. I then smoke-tested the LMS/CMS frontends.

@kdmccormick kdmccormick changed the title build: finish reimplementing assets, sans paver build: finish reimplementing static asset processing Apr 19, 2024
@kdmccormick kdmccormick force-pushed the kdmccormick/assets-final branch from 1b9ca1c to 289e75e Compare April 19, 2024 21:46
@kdmccormick kdmccormick self-assigned this Apr 19, 2024
@kdmccormick kdmccormick force-pushed the kdmccormick/assets-final branch 2 times, most recently from ecaa339 to d936472 Compare April 24, 2024 20:27
@kdmccormick kdmccormick changed the title build: finish reimplementing static asset processing build!: finish reimplementing static asset processing Apr 24, 2024
@kdmccormick kdmccormick force-pushed the kdmccormick/assets-final branch 12 times, most recently from 8d15a9d to 7757d59 Compare April 30, 2024 22:19
@kdmccormick kdmccormick changed the title build!: finish reimplementing static asset processing build: finish replacing paver assets May 1, 2024
@kdmccormick kdmccormick marked this pull request as ready for review May 1, 2024 14:50
@kdmccormick kdmccormick requested a review from feanil May 1, 2024 14:56
README.rst Outdated

Provision your database::

# (TODO: we need a step here to create the database itself)
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
# (TODO: we need a step here to create the database itself)
# (TODO: we need a step here to create the database itself)

Gotta look into what Tutor does and update this. @feanil , if you have the command you ran written down, let me know and I'll drop it in here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been running a minimal docker compose with the following config:

services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE: "edxapp"
      MYSQL_USER: "edxapp001"
      MYSQL_PASSWORD: "password"
      MYSQL_RANDOM_ROOT_PASSWORD: true
    ports:
      - 3306:3306
  mongo:
    image: mongo:7
    environment:
      MONGO_INITDB_DATABASE: 'edxapp'
    ports:
      - 27017:27017
    volumes:
      - type: bind
        source: mongo-entrypoints.d
        target: /docker-entrypoint-initdb.d/
        read_only: true
  memcache:
    image: memcached
    ports:
      - 11211:11211

with a mongo entrypoint file in the folder with the following content:

db.createUser(
  {
    user: "edxapp",
    pwd:  "password",   // cleartext dev password, change if you're gonna use this for production.
    roles: [
	     { role: "readWrite", db: "edxapp" },
           ]
  }
)

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

A couple of comments but generally looks good.

README.rst Outdated Show resolved Hide resolved
README.rst Outdated

Provision your database::

# (TODO: we need a step here to create the database itself)
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been running a minimal docker compose with the following config:

services:
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE: "edxapp"
      MYSQL_USER: "edxapp001"
      MYSQL_PASSWORD: "password"
      MYSQL_RANDOM_ROOT_PASSWORD: true
    ports:
      - 3306:3306
  mongo:
    image: mongo:7
    environment:
      MONGO_INITDB_DATABASE: 'edxapp'
    ports:
      - 27017:27017
    volumes:
      - type: bind
        source: mongo-entrypoints.d
        target: /docker-entrypoint-initdb.d/
        read_only: true
  memcache:
    image: memcached
    ports:
      - 11211:11211

with a mongo entrypoint file in the folder with the following content:

db.createUser(
  {
    user: "edxapp",
    pwd:  "password",   // cleartext dev password, change if you're gonna use this for production.
    roles: [
	     { role: "readWrite", db: "edxapp" },
           ]
  }
)

docs/static-assets.rst Outdated Show resolved Hide resolved
@kdmccormick kdmccormick force-pushed the kdmccormick/assets-final branch from 22c0a7c to debfec8 Compare May 1, 2024 19:34
@kdmccormick
Copy link
Member Author

Thanks @feanil . I decided to punt on this:

I've been running a minimal docker compose with the following config:
...

I think it'd be good, when we have some more time, to document the "bare metal" steps in a more thoughtful way. Perhaps a reference or how-to page, plus check-ins of your docker-compose files, and maybe even add something in CI test it.

For now, rather than adding commands or files that I haven't tested, I just added general text that I hope could point more advanced operators in the right direction:

Create a MySQL database and a MySQL user with write permissions, and configure Django to use them. Then, run migrations::

./manage.py lms migrate
./manage.py cms migrate

Together, these changes make it so that all features of the Paver-based
asset compilation system are supported with drop-in Paver-free
replacements. The remaining Paver asset functions are trivial wrappers,
which can be comfortably deleted before Sumac

* Turn `./manage.py ... compile_sass` into a simple wrapper around `npm
  run compile-sass`
* Turn `paver webpack` into a simple wrapper around `npm run webpack`
* Turn `pavelib.assets:collect_assets` into a simple wrapper around
  `./manage.py ... collectstatic`
* Add/improve deprecation warnings for all Paver asset commands.
* Load defaults for asset-related Django settings from environment
  variables. This allows the build to work without Python. For the
  settings which will be removed in Sumac, I've added deprecation
  warnings.
* Change EDX_PLATFORM_THEME_DIRS env var to COMPREHENSIVE_THEME_DIRS.
  This simplifies the migration instructions, because all the new env
  vars now match their corresponding Django settings. This amends an
  ADR, but it should not be a breaking change because the  env var was
  recently added (since Quince) and nobody should be using it yet.
* Future-proof the static assets ADR with links. The linked pages will
  be kept up-to-date even if the ADR isn't.

Part of: openedx#34467
@kdmccormick kdmccormick force-pushed the kdmccormick/assets-final branch from a90edce to 339d95d Compare May 5, 2024 14:05
@kdmccormick kdmccormick merged commit 3f0f7ce into openedx:master May 6, 2024
110 checks passed
@kdmccormick kdmccormick deleted the kdmccormick/assets-final branch May 6, 2024 12:29
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

kdmccormick added a commit that referenced this pull request May 6, 2024
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

jesperhodge pushed a commit that referenced this pull request May 6, 2024
Reverts #34554, which causes compilation of edX.org's
legacy comprehensive theme to be skipped in their deployment pipeline.
We have not determined the precise cause yet, but it seems like the
compile_sass management command is not correctly getting the
list of comprehensive theme directories from Django settings.
@kdmccormick
Copy link
Member Author

kdmccormick commented May 6, 2024

Reverted here: #34700

To be reintroduced here: #34701

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.

3 participants