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
22 changes: 15 additions & 7 deletions .github/workflows/test-activerecord.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: test-activerecord
on: [push, pull_request]
on: workflow_call
permissions:
contents: read
jobs:
Expand All @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
entry:
- { ruby: '3.3', activerecord: '~> 6.1.0', grape: '~> 1.8', rack: '~> 2.2' }
- { ruby: '3.3', activerecord: '~> 7.2.0', grape: '~> 2.4' }
- { ruby: '3.3', activerecord: '~> 7.2.0', grape: '~> 3.0' }
- { ruby: '3.4', activerecord: '~> 8.0.0', grape: '~> 2.4' }
- { ruby: '3.4', activerecord: '~> 8.1.0', grape: '~> 4.0' }
- { ruby: '4.0', activerecord: '~> 8.1.0', grape: '~> 4.0' }
- { ruby: '3.3', activerecord: '~> 6.1.0', grape: '~> 1.8', rack: '~> 2.2', coverage: false }
- { ruby: '3.3', activerecord: '~> 7.2.0', grape: '~> 2.4', coverage: false }
- { ruby: '3.3', activerecord: '~> 7.2.0', grape: '~> 3.0', coverage: true }
- { ruby: '3.4', activerecord: '~> 8.0.0', grape: '~> 2.4', coverage: false }
- { ruby: '3.4', activerecord: '~> 8.1.0', grape: '~> 4.0', coverage: false }
- { ruby: '4.0', activerecord: '~> 8.1.0', grape: '~> 4.0', coverage: false }
name: test (ruby=${{ matrix.entry.ruby }}, activerecord=${{ matrix.entry.activerecord }}, grape=${{ matrix.entry.grape }})
env:
ACTIVERECORD_VERSION: ${{ matrix.entry.activerecord }}
Expand All @@ -29,3 +29,11 @@ jobs:
bundler-cache: true
- name: Run Tests
run: bundle exec rake spec
- uses: coverallsapp/github-action@v2
if: matrix.entry.coverage
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov/grape-roar.lcov
format: lcov
flag-name: activerecord-${{ strategy.job-index }}
parallel: true
24 changes: 16 additions & 8 deletions .github/workflows/test-mongodb.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: test-mongodb
on: [push, pull_request]
on: workflow_call
permissions:
contents: read
jobs:
Expand All @@ -10,13 +10,13 @@ jobs:
fail-fast: false
matrix:
entry:
- { ruby: '3.3', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 1.7.0', rack: '~> 2.2' }
- { ruby: '3.3', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 2.0.0' }
- { ruby: '3.3', mongoid: '~> 7.5.4', mongodb: '7.0', grape: '~> 2.4' }
- { ruby: '3.3', mongoid: '~> 8.1.11', mongodb: '8.0', grape: '~> 2.4' }
- { ruby: '3.3', mongoid: '~> 8.1.11', mongodb: '8.0', grape: '~> 3.0' }
- { ruby: '3.4', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0' }
- { ruby: '4.0', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0' }
- { ruby: '3.3', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 1.7.0', rack: '~> 2.2', coverage: false }
- { ruby: '3.3', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 2.0.0', coverage: true }
- { ruby: '3.3', mongoid: '~> 7.5.4', mongodb: '7.0', grape: '~> 2.4', coverage: false }
- { ruby: '3.3', mongoid: '~> 8.1.11', mongodb: '8.0', grape: '~> 2.4', coverage: false }
- { ruby: '3.3', mongoid: '~> 8.1.11', mongodb: '8.0', grape: '~> 3.0', coverage: false }
- { ruby: '3.4', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0', coverage: true }
- { ruby: '4.0', mongoid: '~> 9.1', mongodb: '8.0', grape: '~> 4.0', coverage: false }
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }}, grape=${{ matrix.entry.grape }})
env:
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
Expand All @@ -40,3 +40,11 @@ jobs:
bundler-cache: true
- name: Run Tests
run: bundle exec rake spec
- uses: coverallsapp/github-action@v2
if: matrix.entry.coverage
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: coverage/lcov/grape-roar.lcov
format: lcov
flag-name: mongoid-${{ strategy.job-index }}
parallel: true
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ jobs:
bundler-cache: true
- name: Run Tests
run: bundle exec rake spec
test-activerecord:
uses: ./.github/workflows/test-activerecord.yml
test-mongodb:
uses: ./.github/workflows/test-mongodb.yml
finish:
name: Finish Coveralls
needs: [test, test-activerecord, test-mongodb]
runs-on: ubuntu-latest
steps:
- uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Gemfile.lock
doc
pkg
.bundle
/coverage/
gemfiles/*.lock
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [#40](https://github.com/ruby-grape/grape-roar/pull/40): Document deeply nested representers and verify shared post/image records retain their attributes across repeated requests - [@dblock](https://github.com/dblock).
* [#42](https://github.com/ruby-grape/grape-roar/pull/42): Support caching plain rendered representations without forwarding Roar-only options to generic JSON encoders; document cache serialization and request-context keys - [@dblock](https://github.com/dblock).
* [#41](https://github.com/ruby-grape/grape-roar/pull/41): Document hash-backed representers with explicit key getters and verify module/decorator rendering for symbol and string keys - [@dblock](https://github.com/dblock).
* [#43](https://github.com/ruby-grape/grape-roar/pull/43): Add SimpleCov LCOV reports and a coverage badge; merge Coveralls reports from selected existing ORM matrix entries without duplicate test runs - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.5.0 (2025/09/25)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ GRAPE_VERSION='~> 1.8' RACK_VERSION='~> 2.2' bundle exec rake

Setting `ACTIVERECORD_VERSION` or `MONGOID_VERSION` loads that ORM and automatically includes its tagged examples in the suite. ActiveRecord adapter and validation tests do not require a database. Mongoid examples require MongoDB at `localhost:27017` and use the dedicated `grape_roar_test` database. CI runs MongoDB service containers for Mongoid 6.x through 9.x and tests newer Grape versions with ORM releases that permit their ActiveSupport requirements.

Spec runs generate `coverage/lcov/grape-roar.lcov` with SimpleCov. `test.yml` runs the core matrix and calls the separate reusable `test-activerecord.yml` and `test-mongodb.yml` workflows. Only `test.yml` handles push and pull-request events, so the ORM matrices run once per event. ORM entries marked `coverage: true` upload reports using the built-in GitHub token, covering ActiveRecord and both Mongoid association implementations without extra test runs. After the core matrix and both reusable workflows succeed, one completion job in `test.yml` merges the uploads into a single Coveralls report.

#### Write Tests

Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape-roar](spec/grape-roar).
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ gemspec
group :test do
gem 'rack-test'
gem 'rspec'
gem 'simplecov', require: false
gem 'simplecov-lcov', require: false
end

group :development, :test do
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ Grape::Roar
-----------

[![Gem Version](http://img.shields.io/gem/v/grape-roar.svg)](http://badge.fury.io/rb/grape-roar)
[![Coverage Status](https://coveralls.io/repos/github/ruby-grape/grape-roar/badge.svg?branch=master)](https://coveralls.io/github/ruby-grape/grape-roar?branch=master)
[![test](https://github.com/ruby-grape/grape-roar/actions/workflows/test.yml/badge.svg)](https://github.com/ruby-grape/grape-roar/actions/workflows/test.yml)
[![test-activerecord](https://github.com/ruby-grape/grape-roar/actions/workflows/test-activerecord.yml/badge.svg)](https://github.com/ruby-grape/grape-roar/actions/workflows/test-activerecord.yml)
[![test-mongodb](https://github.com/ruby-grape/grape-roar/actions/workflows/test-mongodb.yml/badge.svg)](https://github.com/ruby-grape/grape-roar/actions/workflows/test-mongodb.yml)

Use [Roar](https://github.com/apotonick/roar) with [Grape](https://github.com/intridea/grape).

Expand Down
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

require 'bundler'
Bundler.setup :default, :test

require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov::Formatter::LcovFormatter.config.lcov_file_name = 'grape-roar.lcov'
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start do
add_filter '/spec/'
end

Bundler.require

require 'grape'
Expand Down
Loading