From b0efc8c2ef9669dda524d87b9b4c9328f5d1d01f Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 14 Oct 2026 19:22:23 -0400 Subject: [PATCH] Report GridFS test coverage to Coveralls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 9 ++++++++- .gitignore | 1 + CHANGELOG.md | 1 + README.md | 3 ++- gemfiles/mongoid-9.0.gemfile | 1 + test/helper.rb | 9 +++++++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e773e82..0a519d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,10 +30,11 @@ jobs: - { ruby: '3.3', mongodb: '6', gemfile: 'mongoid-9.0' } - { ruby: '3.4', mongodb: '7.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' } - { ruby: '3.4', mongodb: '8.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' } - - { ruby: '4.0', mongodb: '8.0', gemfile: 'mongoid-9.0', bundler: '2.7.2' } + - { ruby: '4.0', mongodb: '8.0', gemfile: 'mongoid-9.0', bundler: '2.7.2', coverage: true } name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}), gemfile=${{ matrix.entry.gemfile }}) env: BUNDLE_GEMFILE: gemfiles/${{ matrix.entry.gemfile }}.gemfile + COVERAGE: ${{ matrix.entry.coverage && 'true' || 'false' }} services: mongodb: image: mongo:${{ matrix.entry.mongodb }} @@ -54,3 +55,9 @@ jobs: bundler-cache: true - name: Run tests run: bundle exec rake + - name: Upload coverage to Coveralls + if: ${{ matrix.entry.coverage }} + uses: coverallsapp/github-action@v2 + with: + file: coverage/.resultset.json + format: simplecov diff --git a/.gitignore b/.gitignore index 7804ec0..2ed3597 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ Gemfile.lock Gemfile.danger.lock gemfiles/*.lock pkg/* +coverage/ diff --git a/CHANGELOG.md b/CHANGELOG.md index b6ce024..7763cc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 2.6.1 (Next) +* [#85](https://github.com/mongoid/mongoid-grid_fs/pull/85): Report test coverage to Coveralls and update CI badges - [@dblock](https://github.com/dblock). * [#84](https://github.com/mongoid/mongoid-grid_fs/pull/84): Migrate Danger to danger-pr-comment workflows - [@dblock](https://github.com/dblock). * [#84](https://github.com/mongoid/mongoid-grid_fs/pull/84): Modernize CI through Ruby 4.0 and MongoDB 8 with Mongoid 9, use Bundler 2 for modern Rails, and explicitly load Logger for Rails 6 - [@dblock](https://github.com/dblock). * Your contribution here. diff --git a/README.md b/README.md index 1af5ff6..efa9199 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ mongoid-grid_fs --------------- [![Gem Version](https://badge.fury.io/rb/mongoid-grid_fs.svg)](https://badge.fury.io/rb/mongoid-grid_fs) -[![CI](https://github.com/mongoid/mongoid-grid_fs/actions/workflows/ci.yml/badge.svg)](https://github.com/mongoid/mongoid-grid_fs/actions/workflows/ci.yml) +[![CI](https://github.com/mongoid/mongoid-grid_fs/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid-grid_fs/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-grid_fs/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-grid_fs?branch=master) A pure Mongoid/Moped implementation of the MongoDB GridFS specification diff --git a/gemfiles/mongoid-9.0.gemfile b/gemfiles/mongoid-9.0.gemfile index b17abe3..74c9062 100644 --- a/gemfiles/mongoid-9.0.gemfile +++ b/gemfiles/mongoid-9.0.gemfile @@ -5,5 +5,6 @@ gem 'rails', '~> 7.0' gem 'base64' gem 'bigdecimal' gem 'logger' +gem 'simplecov', '~> 0.22', require: false if ENV['COVERAGE'] == 'true' gemspec path: '../' diff --git a/test/helper.rb b/test/helper.rb index 50d72bf..dd582db 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,3 +1,12 @@ +if ENV['COVERAGE'] == 'true' + require 'simplecov' + SimpleCov.start do + add_filter '/test/' + add_filter '/vendor/' + track_files 'lib/**/*.rb' + end +end + require 'logger' require 'rails' require 'stringio'