Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: "${{ !contains(github.ref, 'main')}}"

jobs:
test:
name: "Run tests"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby:
- "3.4"
- "3.3"
gemfile:
- gemfiles/rails-6.0-mongo.gemfile
- gemfiles/rails-6.0-mongoid.gemfile
include:
- gemfile: gemfiles/rails-5.2-mongo.gemfile
ruby: "2.7"
- gemfile: gemfiles/rails-5.2-mongoid.gemfile
ruby: "2.7"
- gemfile: gemfiles/rails-5.1-mongo.gemfile
ruby: "2.6"
- gemfile: gemfiles/rails-5.1-mongoid.gemfile
ruby: "2.6"
- gemfile: gemfiles/rails-5.0-mongo.gemfile
ruby: "2.6"
- gemfile: gemfiles/rails-5.0-mongoid.gemfile
ruby: "2.6"

services:
mongodb:
image: mongo:3.6
ports:
- 27017:27017

env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}

steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run tests
run: bundle exec rake test

rubocop:
name: "RuboCop"
runs-on: ubuntu-latest

steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
gemfile: gemfiles/rails-6.0-mongo.gemfile
bundler-cache: true

- name: Run RuboCop
run: bundle exec rubocop
8 changes: 4 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ Style/StringLiterals:
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes

Style/AlignParameters:
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation

Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Style/AlignHash:
Layout/HashAlignment:
EnforcedLastArgumentHashStyle: ignore_implicit

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/IndentArray:
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Style/FormatString:
Expand Down
109 changes: 0 additions & 109 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"

gemspec

gem "rubocop", "1.84.1"
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MongoSessionStore is a [Rails][rails]-compatible session store for
Driver][mongo]. It also allows for custom Mongo session store that works with
any (or no!) Mongo ODM.

MongoSessionStore version 3 is compatible with Rails 4.0 through 5.2. For Rails
MongoSessionStore version 3 is compatible with Rails 5.0+. For Rails
3 support please check out issue [#17][issue-rails3] for options and let us
know if you need support.

Expand Down Expand Up @@ -70,24 +70,28 @@ MongoStore::Session.where("updated_at" => { "$gt" => 2.days.ago })

## Development

### Test environment

Start MongoDB with this script:

```
script/testenv
```

### Testing

To run the tests for a specific store. You must first set a `BUNDLE_GEMFILE` in
the environment.

You can also use Docker, see the section below this one.

```sh
bundle exec rake
```

Examples:

```sh
BUNDLE_GEMFILE=gemfiles/rails-4.0-mongo.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-4.0-mongoid.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-4.1-mongo.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-4.1-mongoid.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-4.2-mongo.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-4.2-mongoid.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-5.0-mongo.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-5.0-mongoid.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-5.1-mongo.gemfile bundle exec rake
Expand All @@ -98,6 +102,20 @@ BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile bundle exec rake
BUNDLE_GEMFILE=gemfiles/rails-6.0-mongoid.gemfile bundle exec rake
```

#### Docker testing

To run tests in a Docker container with a specific Ruby version and gemfile:

```sh
BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
```

The `BUNDLE_GEMFILE` environment variable is required. Ruby version defaults to 3.4 but can be customized:

```sh
RUBY_VERSION=2.7 BUNDLE_GEMFILE=gemfiles/rails-6.0-mongo.gemfile script/test
```

### Performance benchmark

The repository includes a performance benchmark. It runs against all available
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
mongodb:
image: mongo:3.6
ports:
- "27017:27017"
9 changes: 0 additions & 9 deletions gemfiles/rails-4.0-mongo.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails-4.0-mongoid.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails-4.1-mongo.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails-4.1-mongoid.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails-4.2-mongo.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails-4.2-mongoid.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails-5.1-mongoid.gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "mongoid"
gem "mongoid", "~> 7.0"

gem "rails", "~> 5.1.0"
gem "devise", ">= 4.2"
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails-6.0-mongo.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ gem "mongo"
gem "rails", "~> 6.0.0"
gem "devise", "~> 4.7.0"
gem "sqlite3", "~> 1.4.0"
gem "bigdecimal"
gem "mutex_m"
gem "drb"

gemspec :path => "../"
3 changes: 3 additions & 0 deletions gemfiles/rails-6.0-mongoid.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ gem "mongoid"
gem "rails", "~> 6.0.0"
gem "devise", "~> 4.7.0"
gem "sqlite3", "~> 1.4.0"
gem "bigdecimal"
gem "mutex_m"
gem "drb"

gemspec :path => "../"
1 change: 1 addition & 0 deletions lib/mongo_session_store/mongoid_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def pack(data)

def unpack(packed)
return unless packed

if packed.respond_to? :data
Marshal.load(packed.data)
else
Expand Down
Loading
Loading