From aabc2eb6f8f9c7d6904b4e1c0f1138bb4269434e Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 25 Aug 2026 18:01:00 -0400 Subject: [PATCH] Report coverage to Coveralls on pull requests using GITHUB_TOKEN Switches from coveralls_reborn (which requires a Coveralls-specific COVERALLS_REPO_TOKEN secret that isn't available to workflow runs triggered by pull requests from forks) to the coverallsapp/github-action, which authenticates with the default GITHUB_TOKEN available on any PR. - Replace coveralls_reborn with simplecov-lcov to generate an lcov report that coverallsapp/github-action can consume. - Add pull_request as a trigger for the Coverage workflow so coverage is reported on PRs, not just on pushes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/coverage.yml | 9 ++++++--- CHANGELOG.md | 1 + Gemfile | 3 ++- spec/spec_helper.rb | 12 ++++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ea10b9c..1e5595e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,7 +1,7 @@ --- name: Coverage -on: [push] +on: [push, pull_request] jobs: build: @@ -15,5 +15,8 @@ jobs: bundler-cache: true - name: Build and test with RSpec run: bundle exec rspec - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + - name: Report coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage/lcov.info diff --git a/CHANGELOG.md b/CHANGELOG.md index 8111ee8..eb5202b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 1.2.2 (Next) +* [#65](https://github.com/dblock/ruby-enum/pull/65): Fixed coverage reporting to Coveralls not running on pull requests by switching from `coveralls_reborn`/`COVERALLS_REPO_TOKEN` to `coverallsapp/github-action`/`GITHUB_TOKEN` - [@dblock](https://github.com/dblock). * Your contribution here. ### 1.2.1 (2026/08/15) diff --git a/Gemfile b/Gemfile index 3ce44a3..82808f4 100644 --- a/Gemfile +++ b/Gemfile @@ -18,5 +18,6 @@ group :development, :test do end group :test do - gem 'coveralls_reborn', require: false + gem 'simplecov' + gem 'simplecov-lcov', require: false end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bdc51a2..8c82783 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,8 +4,16 @@ require 'rubygems' -require 'coveralls' -Coveralls.wear! +require 'simplecov' +require 'simplecov-lcov' + +SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true +SimpleCov::Formatter::LcovFormatter.config.single_report_path = 'coverage/lcov.info' +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::LcovFormatter + ]) +SimpleCov.start require 'rspec' require 'ruby-enum'