refactor: move xmodule folder to root#30394
Conversation
2363b2e to
8cc7b23
Compare
c31dfdf to
3691d4b
Compare
90ab2d7 to
0f02b40
Compare
There was a problem hiding this comment.
Using the correct symlink name worked here but I wonder how previous one is working on master then?
There was a problem hiding this comment.
@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!
xmodule/js/spec/time_spec.js
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
80fb790 to
62bda91
Compare
kdmccormick
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Why did you delete this file, and the other XML files in this directory? Were they unused?
There was a problem hiding this comment.
These were 10 years old files. I tried to find their usage but couldn't find any. That's why removed them.
There was a problem hiding this comment.
Sounds good to me. Just make a note in your final commit message so that future developers know that it was on purpose.
There was a problem hiding this comment.
@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!
xmodule/js/spec/time_spec.js
Outdated
There was a problem hiding this comment.
@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.
25bcd0b to
bc3fea6
Compare
kdmccormick
left a comment
There was a problem hiding this comment.
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 countoutput dropped by a few hundred tests. This is because ./xmodule tests are not being counted nor run on this branch.
13a247a to
47323fe
Compare
Fixed. |
|
@mumarkhan999 pytest is still not being run in the |
47323fe to
d543a9a
Compare
kdmccormick
left a comment
There was a problem hiding this comment.
Thanks for all your hard work on this huge PR. Just two more questions, and then I'm ready to approve, assuming tests pass.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
.github/workflows/unit-tests.yml
Outdated
There was a problem hiding this comment.
👍🏻
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?
There was a problem hiding this comment.
Yeah sure... will create a ticket for this.
|
I recommend giving whoever is on call for edX T&L (@connorhaugh ?) a heads up before merging this one. |
cb1ac69 to
aac1bfc
Compare
- 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
aac1bfc to
a91df0c
Compare
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
🤞🏻 |
|
EdX Release Notice: This PR has been deployed to the production environment. |
In this PR
We are moving
common/lib/xmodule/xmodule/to/root level.The following things have been updated in this PR
setup.pysymlinksTicket Links
Sandbox URL for this PR https://xmodule.sandbox.edx.org/