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

chore: upgrade to ruby 3 #392

Merged
merged 2 commits into from
Dec 9, 2022
Merged

chore: upgrade to ruby 3 #392

merged 2 commits into from
Dec 9, 2022

Conversation

xitij2000
Copy link
Contributor

@xitij2000 xitij2000 commented Sep 21, 2022

This PR adds support for running cs_comments_service on Ruby 3 in addition to Ruby 2.5

Given that Ruby 2.5 is EOL, 2.7 will be EOL within months. Ruby 3 gives us a bit over a year to upgrade to Ruby 3.1.

Sandbox URL: TBD - sandbox is being provisioned.

Merge deadline: "None"

Testing instructions:

This PR can be used with the corresponding devstack PR to manually test this PR.

Testing should involve manual interaction with all the aspects of the forum.

Author notes and concerns:

The code has been tested and is working with 3.1 as well, but there are issues when running 3.1 on CI. It will hopefully not require much effort to upgrade to 3.1

@openedx-webhooks openedx-webhooks added core committer open-source-contribution PR author is not from Axim or 2U labels Sep 21, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 21, 2022

Thanks for the pull request, @xitij2000!

As a core committer in this repo, you can merge this once the pull request is approved per the core committer reviewer requirements and according to the agreement with your edX Champion.

@codecov
Copy link

codecov bot commented Sep 21, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@063fd26). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head 712a8bd differs from pull request most recent head afeb30c. Consider uploading reports for the commit afeb30c to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #392   +/-   ##
=========================================
  Coverage          ?   96.08%           
=========================================
  Files             ?       58           
  Lines             ?     4522           
  Branches          ?        0           
=========================================
  Hits              ?     4345           
  Misses            ?      177           
  Partials          ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@xitij2000 xitij2000 changed the title kshitij/ruby3 chore: upgrade to ruby 3 Sep 21, 2022
@natabene
Copy link

@xitij2000 Thank you for the contribution, let me know once this is ready.

@ghassanmas
Copy link
Member

@xitij2000 Following our today BTR call, we were disucssing whether discussion (backend service) should run on Ruby 3 or not.

One factor obviously is deadline of this PR, can you by any chance estimae when this would be ready/merged?

Also can you confirm that the alternative is to run the service on a ruby version (2.5.7) ref which already has reached its EOL?

Note: I personally tested this locally but I had to do #395 first and the test was run tutor based using the forum plugin, overhangio/tutor-forum#11 and we are in the process of testing in the acutal production.

@jmbowman
Copy link

It looks like there's also a Ruby 2.7.6 upgrade option that might be easier, but that would also go EOL about 3 months before Palm is released. I think this one slipped under the radar because our Ruby entries in the support windows doc were outdated.

@xitij2000
Copy link
Contributor Author

@xitij2000 Following our today BTR call, we were disucssing whether discussion (backend service) should run on Ruby 3 or not.

One factor obviously is deadline of this PR, can you by any chance estimae when this would be ready/merged?

Also can you confirm that the alternative is to run the service on a ruby version (2.5.7) ref which already has reached its EOL?

Note: I personally tested this locally but I had to do #395 first and the test was run tutor based using the forum plugin, overhangio/tutor-forum#11 and we are in the process of testing in the acutal production.

I will try to prioritise this in the upcoming sprint. Initially the aim was just to get tests running on Ruby 3.0 to catch any new failures, and slowly fix things over time, but I can put some of my CC time to getting this running.

@jmbowman I aimed for 3.x for that very reason, that 2.7 was also close to EOL. I will see if I can get all tests passing and if the forum is running without issues on 3.x, and if not I'll see if 2.7 is easier.

@mtyaka
Copy link
Contributor

mtyaka commented Nov 9, 2022

@xitij2000 This looks great and it required less changes than I thought it would!
I think we'll want to pull in the change from #395 before merging, but other than that everything looks good and seems to be working well (I tested it on The Olive demo instance) which is already running code from this branch on ruby 3).

@@ -96,7 +96,7 @@ def get_paged_merged_responses(thread_id, responses, skip, limit, recursive=fals
paged_response_ids = limit.nil? ? response_ids.drop(skip) : response_ids.drop(skip).take(limit)
if recursive
content = Comment.where(comment_thread_id: thread_id).
or({:parent_id => {"$in" => paged_response_ids}}, {:id => {"$in" => paged_response_ids}}).
any_of({:parent_id => {"$in" => paged_response_ids}}, {:id => {"$in" => paged_response_ids}}).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way this API works has changed in mongoid.

So while the previous version was equivalent to:
comment_thread_id == thread_id AND (parent_id in paged_response_ids OR id in paged_response_ids)
It is now equivalent to
comment_thread_id == thread_id OR parent_id in paged_response_ids OR id in paged_response_ids)
since the where is merged into the or. Using any_of fixes this issue (ref)

@@ -331,7 +331,7 @@ def test_unicode_data(text)
page_3 = parse last_response.body


all_items["collection"].should == (
expect(all_items["collection"]).to eq(
page_1["collection"] +
page_2["collection"] +
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 just update to the newer syntax.

@@ -40,6 +40,6 @@
body { Faker::Lorem.paragraph }
course_id { comment_thread.course_id }
commentable_id { comment_thread.commentable_id }
endorsed false
endorsed { false }
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updates tot accommodate new versions of Faker, and migration from FactoryGirl -> FactoryBot

Comment on lines +82 to +83
def t(*args, **kwargs)
I18n.t(*args, **kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ruby generally uses more keyword arguments, which have had major changes in Ruby 3. Without this, keyword arguments are no longer passed and translations break when paramaterised translations are used (in one place).

@xitij2000 xitij2000 marked this pull request as ready for review November 9, 2022 09:19
@xitij2000
Copy link
Contributor Author

I've got all the tests running and passing on both Ruby 3.0 and 3.1, however with Ruby 3.1 the CI seems to fail due to failed dependencies when building an extension. I might not have time to resolve that, but it is working otherwise.

@mtyaka
Copy link
Contributor

mtyaka commented Nov 14, 2022

Thanks a lot for taking care of this @xitij2000! 👍

  • I tested this: I verified that the forums are working correctly on the Olive demo instance.
  • I read through the code
  • I checked for accessibility issues (N/A)
  • Includes documentation (N/A)

@arbrandes
Copy link

@asadazam93, is this something you could look at in the next couple of days? We want to have it in as part of the Olive release, since Ruby < 3 is out of support (and has been for a while).

@asadazam93
Copy link
Contributor

@xitij2000 Is this a breaking change?

@xitij2000
Copy link
Contributor Author

@xitij2000 Is this a breaking change?

It should not be. This PR is tested against both the current version of Ruby (2.5.7) and on Ruby 3.0.x. However, the idea is to eventually start using Ruby 3.0, so it sets the stage for that.

@ghassanmas
Copy link
Member

Hi folks, Would it be possible for this to be merged today or by tomorrow at least. Since then it need to be backported to olive and then tested again with the recent commits to olive...etc. Thus the sooner this is merged the less urguent things would need to be done for the olive relaese.

I appercaite your understaning and happy to help if anything is needed with this.

@ghassanmas ghassanmas mentioned this pull request Dec 9, 2022
xitij2000 and others added 2 commits December 9, 2022 16:03
Upgrade the service to work on both on Ruby 2.5.7 (currently used by the repo)
and 3.0 (which is currently supported).

Additionally, switch from running tests inside a docker container launched
through scripts to directly setting up and testing inside GitHub's containers.
    Also update readmde about how to update the rack-timeout
Copy link

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

This has been tested in production via the Tutor demo/testing deployment, and no issues were found. Approved!

@xitij2000 xitij2000 merged commit 3420c0a into master Dec 9, 2022
@openedx-webhooks
Copy link

@xitij2000 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

ghassanmas added a commit to ghassanmas/cs_comments_service that referenced this pull request Dec 9, 2022
Upgrade the service to work on both on Ruby 2.5.7 (currently used by the repo)
and 3.0 (which is currently supported).

Additionally, switch from running tests inside a docker container launched
through scripts to directly setting up and testing inside GitHub's containers.

Co-authored-by: Ghassan Maslamani <[email protected]>
@xitij2000 xitij2000 deleted the kshitij/ruby3 branch July 14, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core committer open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants