Skip to content

refactor: move xmodule folder to root#30394

Merged
mumarkhan999 merged 1 commit intomasterfrom
umar/move-xmdule-folder-to-root
Jun 20, 2022
Merged

refactor: move xmodule folder to root#30394
mumarkhan999 merged 1 commit intomasterfrom
umar/move-xmdule-folder-to-root

Conversation

@mumarkhan999
Copy link
Contributor

@mumarkhan999 mumarkhan999 commented May 16, 2022

In this PR
We are moving common/lib/xmodule/xmodule/ to / root level.

The following things have been updated in this PR

  • entry points and other configs in setup.py
  • Github actions
  • symlinks
  • Module imports
  • Webpack configurations
  • Linting and coverage related configs
  • Few docs

Ticket Links

Sandbox URL for this PR https://xmodule.sandbox.edx.org/

  • This sandbox is operational till Saturday, 2 July 2022

@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch 9 times, most recently from 2363b2e to 8cc7b23 Compare May 23, 2022 06:59
@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch 12 times, most recently from c31dfdf to 3691d4b Compare May 27, 2022 12:04
@Jawayria Jawayria closed this Jun 2, 2022
@Jawayria Jawayria reopened this Jun 2, 2022
@Jawayria Jawayria force-pushed the umar/move-xmdule-folder-to-root branch from 90ab2d7 to 0f02b40 Compare June 2, 2022 11:59
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the correct symlink name worked here but I wonder how previous one is working on master then?

Copy link
Member

Choose a reason for hiding this comment

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

@Jawayria:
Using the correct symlink name worked here but I wonder how previous one is working on master then

This works on master because of this line in webpack.common.config.js: https://github.com/openedx/edx-platform/blob/7f5d8e3511ed70a3097b3114818a0e335eefb867/webpack.common.config.js#L394

That line adds common/lib/xmodule to Webpack's list of directories for JS module resolution. When Webpack sees import ..., it'll look in all of those directories for modules. That's how it finds the file common/lib/xmodule/xmodule/js/src/xmodule.js based on import xmodule/js/src/xmodule.

Your fix does indeed fix the tests, but I am nervous to change import paths in tests, because I also do not understand this mish-mash of JavaScript tooling very well :) if we change import paths in tests but neglect to do so in some untested production file, then it could cause bugs.

So, we instead need to change webpack.common.config.js to search from the repository root (.) instead of common/lib/xmodule. According to webpack's docs, though, adding . to the module resolution list would cause Webpack to search for imports in every single JavaScript directory, not just the repository root... but if we add the absolute path using path.resolve(__dirname), then everything works fine!

Copy link
Contributor

@Jawayria Jawayria Jun 3, 2022

Choose a reason for hiding this comment

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

Here I had to make correction in path and similar corrections in some other files. Again I don't understand how is it working on master?

Copy link
Member

Choose a reason for hiding this comment

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

@Jawayria
Here I had to made correction in path and similar corrections in some other files. Again I don't understand how is it working on master?

Just like with the other import issue: this works on master because in webpack.common.js, common/lib/xmodule/xmodule/js/src is added to the list of module resolution directories. If you fix the resolution path, though, then the original imports should start working again.

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Hi @Jawayria , I spent some time digging into this and I think I figured out what's going on with those broken JS import paths. The main culprit seems to be some webpack configuration that needs updating, which I explain more in my comments.

I also reviewed your PR because, well, I needed to look through the entire thing to figure out the import bug anyway 😄 If it was not ready for review my apologies.

I also want to ping @ormsbee and @0x29a (from the BD-13 XModule cleanup) about this PR just as an FYI and a heads-up on the upcoming exciting merge conflicts.

Copy link
Member

Choose a reason for hiding this comment

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

Why did you delete this file, and the other XML files in this directory? Were they unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were 10 years old files. I tried to find their usage but couldn't find any. That's why removed them.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me. Just make a note in your final commit message so that future developers know that it was on purpose.

Copy link
Member

Choose a reason for hiding this comment

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

@Jawayria:
Using the correct symlink name worked here but I wonder how previous one is working on master then

This works on master because of this line in webpack.common.config.js: https://github.com/openedx/edx-platform/blob/7f5d8e3511ed70a3097b3114818a0e335eefb867/webpack.common.config.js#L394

That line adds common/lib/xmodule to Webpack's list of directories for JS module resolution. When Webpack sees import ..., it'll look in all of those directories for modules. That's how it finds the file common/lib/xmodule/xmodule/js/src/xmodule.js based on import xmodule/js/src/xmodule.

Your fix does indeed fix the tests, but I am nervous to change import paths in tests, because I also do not understand this mish-mash of JavaScript tooling very well :) if we change import paths in tests but neglect to do so in some untested production file, then it could cause bugs.

So, we instead need to change webpack.common.config.js to search from the repository root (.) instead of common/lib/xmodule. According to webpack's docs, though, adding . to the module resolution list would cause Webpack to search for imports in every single JavaScript directory, not just the repository root... but if we add the absolute path using path.resolve(__dirname), then everything works fine!

Copy link
Member

Choose a reason for hiding this comment

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

@Jawayria
Here I had to made correction in path and similar corrections in some other files. Again I don't understand how is it working on master?

Just like with the other import issue: this works on master because in webpack.common.js, common/lib/xmodule/xmodule/js/src is added to the list of module resolution directories. If you fix the resolution path, though, then the original imports should start working again.

@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch 5 times, most recently from 25bcd0b to bc3fea6 Compare June 15, 2022 07:40
Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Thanks for making those fixes. This is so close! Two things:

  • The 2u-internal ticket link in your commit message is hidden to all of the community except 2U. Why not include the public openedx.atlassian.net version of the ticket too?
  • Compared to master, the verify unit tests count output dropped by a few hundred tests. This is because ./xmodule tests are not being counted nor run on this branch.

@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch 4 times, most recently from 13a247a to 47323fe Compare June 16, 2022 14:36
@mumarkhan999
Copy link
Contributor Author

Thanks for making those fixes. This is so close! Two things:

  • The 2u-internal ticket link in your commit message is hidden to all of the community except 2U. Why not include the public openedx.atlassian.net version of the ticket too?
  • Compared to master, the verify unit tests count output dropped by a few hundred tests. This is because ./xmodule tests are not being counted nor run on this branch.

Fixed.

@kdmccormick
Copy link
Member

@mumarkhan999 pytest is still not being run in the xmodule/ folder. You can tell because there are no unit-tests / python-3.8-django-pinned,xmodule-* entries in the list of checks on this PR. I think you need to edit the list of shards in unit-tests.yml.

@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch from 47323fe to d543a9a Compare June 16, 2022 15:27
Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

Thanks for all your hard work on this huge PR. Just two more questions, and then I'm ready to approve, assuming tests pass.

Comment on lines +273 to +278
Copy link
Member

Choose a reason for hiding this comment

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

You had originally added an xmodule-2 shard, which tested the folder using CMS settings. I thought that was a great idea. Any specific reason you decided to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually when the xmodule folder was in common the tests were also being executed by just lms settings... so I just tried to keep it that way.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough.

Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

This isn't something you need to fix now, but it's unfortunate that we need to list shards both here and in unit-test-shards.json. It would be really easy to add a new shard in the JSON file but forget to add it here. Could you ask your tech lead to add this to your backlog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sure... will create a ticket for this.

Copy link
Member

@kdmccormick kdmccormick Jun 16, 2022

Choose a reason for hiding this comment

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

Thanks

@kdmccormick
Copy link
Member

I recommend giving whoever is on call for edX T&L (@connorhaugh ?) a heads up before merging this one.

@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch 3 times, most recently from cb1ac69 to aac1bfc Compare June 20, 2022 09:04
- Moving xmodule folder to root as we're dissolving sub-projects of common folder in edx-platform
    - More info: https://openedx.atlassian.net/browse/BOM-2579
- -e common/lib/xmodule has been removed from the requirements as xmodule has itself become the part of edx-platform and not being installed through requirements
- The test files common/lib/xmodule/test_files/ have been removed as they are not being used anymore
@mumarkhan999 mumarkhan999 force-pushed the umar/move-xmdule-folder-to-root branch from aac1bfc to a91df0c Compare June 20, 2022 09:34
@mumarkhan999 mumarkhan999 merged commit 182eb39 into master Jun 20, 2022
@mumarkhan999 mumarkhan999 deleted the umar/move-xmdule-folder-to-root branch June 20, 2022 11:03
@edx-pipeline-bot
Copy link
Contributor

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

@kdmccormick
Copy link
Member

🤞🏻

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants