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

Add support for mongoid 9 #16

Merged
merged 21 commits into from
Jun 17, 2024

Conversation

sairamsrinivasan
Copy link
Collaborator

@sairamsrinivasan sairamsrinivasan commented Jun 12, 2024

This PR adds support for Mongoid 9 so that we can use some of the methods that come with this gem.

@dblock
Copy link
Contributor

dblock commented Jun 12, 2024

Looks like a bunch of tests are no longer working, some versions will have to be locked down. LMK if you need help.

CHANGELOG.md Show resolved Hide resolved
@sairamsrinivasan
Copy link
Collaborator Author

Looks like a bunch of tests are no longer working, some versions will have to be locked down. LMK if you need help.

I'll look into this

@sairamsrinivasan
Copy link
Collaborator Author

sairamsrinivasan commented Jun 15, 2024

@dblock - I noticed that there was a .travis.yml file. Is this used? It seems like the test pipeline is running on GHA?

Additionally, I brought in appraisal to help me lock versions. This included updating test.yml in the directory .github/workflows/** to pull from the gem files generated by appraisal.

How would I go about testing these changes to see if they were applied correctly?

@sairamsrinivasan sairamsrinivasan marked this pull request as draft June 16, 2024 00:07
@sairamsrinivasan
Copy link
Collaborator Author

I'm converting this to a draft PR. The tests pass locally. Need to test CI.

@@ -1,3 +1,7 @@
# frozen_string_literal: true

ENV['MONGOID_ENV'] = 'test'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this? I don't think it's used anywhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is still necessary. Mongoid is not able to resolve the environment and throws an error while trying to run the test. Here's an example of an error thrown without this statement:

An error occurred while loading ./spec/mongoid/compatibility/version_spec.rb.
Failure/Error: Mongoid.load! 'spec/config/mongoid9.yml'

Mongoid::Errors::NoEnvironment:

  message:
    Could not load the configuration since no environment was defined.
  summary:
    Mongoid could not determine the environment to use because it was not specified in any of the following locations: Rails.env, Sinatra::Base.environment, ENV["RACK_ENV"], ENV["MONGOID_ENV"]. Without knowing the environment, Mongoid cannot load its configuration.
  resolution:
    Please ensure an environment is set in one of the listed locations. The environment must be explicitly set.

@dblock
Copy link
Contributor

dblock commented Jun 16, 2024

I'm converting this to a draft PR. The tests pass locally. Need to test CI.

You can/should enable CI on your fork and you'll see these run.

@sairamsrinivasan
Copy link
Collaborator Author

sairamsrinivasan commented Jun 16, 2024

@dblock - I'm testing CI and I noticed that the pipeline fails trying to install bundler with a specific ruby version. I found this github thread that goes over the problem: ruby/setup-ruby#496

Error message:

Run ruby/setup-ruby@v1
Modifying PATH
Downloading Ruby
Extracting  Ruby
Print Ruby version
Installing Bundler
  Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2
  /opt/hostedtoolcache/Ruby/2.2.[10](https://github.com/sairamsrinivasan/mongoid-compatibility/actions/runs/9538619927/job/26288063365?pr=1#step:5:11)/x64/bin/gem install bundler -v ~> 1.0
  ERROR:  While executing gem ... (RuntimeError)
      Marshal.load reentered at marshal_load
  Took   0.30 seconds
Error: The process '/opt/hostedtoolcache/Ruby/2.2.10/x64/bin/gem' failed with exit code 1

Test Pipeline: https://github.com/sairamsrinivasan/mongoid-compatibility/actions/runs/9538619927/job/26288063365?pr=1

Any thoughts here? Can we trim down the list of versions defined in that matrix within test.yml?

@sairamsrinivasan
Copy link
Collaborator Author

@dblock - To follow up with my comment above. I upgraded the minimum ruby version to 2.6 in CI and the tests pass within a pipeline from my fork. See here: sairamsrinivasan#1

Danger is throwing a 401 error that I'm not too sure how to get around:

/home/runner/work/mongoid-compatibility/mongoid-compatibility/vendor/bundle/ruby/2.6.0/gems/octokit-4.25.1/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/sairamsrinivasan/mongoid-compatibility/pulls/1: 401 - Bad credentials // See: https://docs.github.com/rest (Octokit::Unauthorized)

https://github.com/sairamsrinivasan/mongoid-compatibility/actions/runs/9538782572/job/26288380863?pr=1

Any insight to this would be much appreciated.

@sairamsrinivasan sairamsrinivasan marked this pull request as ready for review June 16, 2024 20:52
Copy link
Contributor

@dblock dblock left a comment

Choose a reason for hiding this comment

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

We don't need to test bundler 1, since everything is 2 here want to get rid of it altogether?

Don't worry about danger.

@dblock
Copy link
Contributor

dblock commented Jun 16, 2024

For danger, copy the workflow/token from https://github.com/mongoid/mongoid-rspec/blob/master/.github/workflows/danger.yml#L17.

@sairamsrinivasan
Copy link
Collaborator Author

sairamsrinivasan commented Jun 17, 2024

We don't need to test bundler 1, since everything is 2 here want to get rid of it altogether?

Don't worry about danger.

For danger, copy the workflow/token from https://github.com/mongoid/mongoid-rspec/blob/master/.github/workflows/danger.yml#L17.

@dblock - I appreciate the quick review! CI now passes in my fork. Example: sairamsrinivasan#1

@dblock dblock merged commit 1c1c415 into mongoid:master Jun 17, 2024
40 checks passed
@dblock
Copy link
Contributor

dblock commented Jun 17, 2024

Merged, thanks!

Want to make the next release? Remind me your rubygems username?

@sairamsrinivasan
Copy link
Collaborator Author

Merged, thanks!

Want to make the next release? Remind me your rubygems username?

@dblock - Thanks for merging this PR. I'd be more than happy to make the next release. My rubygems username is: sai_srinivasan

@dblock
Copy link
Contributor

dblock commented Jun 18, 2024

I think we should get #17 before releasing. But either way, invited you to https://github.com/mongoid/mongoid-compatibility/invitations and Rubygems, please follow https://github.com/mongoid/mongoid-compatibility/blob/master/RELEASING.md for a release.

@sairamsrinivasan
Copy link
Collaborator Author

@dblock - I tried to run rake release to create the tag. However, I ran into permission issues pushing to rubygems. Can you send a confirmation link to my username again: sai_srinivasan?

Thanks!

@dblock
Copy link
Contributor

dblock commented Jun 23, 2024

$ gem owner mongoid-compatibility --add sai_srinivasan
Adding sai_srinivasan: User is already invited to this gem

You should have an invitation in email?

@sairamsrinivasan
Copy link
Collaborator Author

sairamsrinivasan commented Jun 23, 2024

@dblock - I checked my email thoroughly. I was looking for an email similar to the one that I received for mongoid-rspec. However, I couldn't find anything in my inbox. I found the github invitation. Also checked my spam and trash folder with no luck. I think there's a way to re-send a confirmation email through rubygems.org

image

Can you please send another one when you get the chance?

@dblock
Copy link
Contributor

dblock commented Jun 24, 2024

@sairamsrinivasan didn't find that link, but I removed/re-added you in owners now, it's pending, see if you got it?

@sairamsrinivasan
Copy link
Collaborator Author

@dblock - Thanks for doing that. I received an invite from rubygems.org. I pushed the new tag: https://rubygems.org/gems/mongoid-compatibility/versions/1.0.0

@dblock
Copy link
Contributor

dblock commented Jun 25, 2024

Great. Don't forget to increment the version for next developer iteration, see https://github.com/mongoid/mongoid-compatibility/blob/master/RELEASING.md for details.

@sairamsrinivasan
Copy link
Collaborator Author

@dblock - I did. I had to add a section to RELEASING. that covers preparing for the next version

Check out this commit on master: 25b4114

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.

2 participants