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

No clear examples for rails project #29

Open
mcampo84 opened this issue Dec 13, 2019 · 4 comments
Open

No clear examples for rails project #29

mcampo84 opened this issue Dec 13, 2019 · 4 comments

Comments

@mcampo84
Copy link

I'm new to Ruby on Rails, Github Actions and Coveralls, and I can't seem to get this github action working. It doesn't seem to be able to find the coverage report file after I run rspec tests.

My .coveralls.yml file looks like this:


on: [push, "pull_request"]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up Ruby 2.6
      uses: actions/setup-ruby@v1
      with:
        ruby-version: 2.6.x

    - name: Run rspec
      run: |
        gem install bundler
        bundle install
        bundle exec rspec spec

    - name: Coveralls
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}

What am I missing?

@clh161
Copy link

clh161 commented Jan 13, 2020

same problem to yours
I tried to add path-to-lcov but no luck

    - name: Coveralls
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        path-to-lcov: coverage/.resultset.json

I wonder if Rails is not supported

@stephaneliu
Copy link

stephaneliu commented Sep 6, 2020

Overalls expects a consolidated lcov.info file.

# Gemfile
gem "simplecov-lcov"

# spec_helper.rb
if ENV["COVERAGE"]
  require "simplecov"
  require "simplecov-lcov"

  SimpleCov.start "rails" do
    if ENV["CI"]
      SimpleCov::Formatter::LcovFormatter.config do |config
        config.report_with_simgle_file = true
        config.lcov_file_name = "lcov.info"
    else
      SimpleCov::Formatter::HTMLFormatter
    end
end

# test.yml
...
- name: Run test
   ...
   run: |
     ...
     COVERAGE=true CI=true DISABLE_SPRING=true bundle exec rspec spec
- name: Coveralls 
  uses: coverallsapp/github-action@master
  with:
    github-tocken: ${{ secrets.GITHUB_TOKEN }}
    path-to-lcov: "./coverage/lcvo/lcov.info"

@jfo84
Copy link

jfo84 commented Oct 1, 2020

Here is some cleaned up code of @stephaneliu, etc.

spec_helper.rb

if ENV['COVERAGE'] == 'true'
  require 'coveralls'
  require 'simplecov'
  require 'simplecov-lcov'

  if ENV['CI'] == 'true'
    SimpleCov::Formatter::LcovFormatter.config do |config|
      config.report_with_single_file = true
      config.lcov_file_name = 'lcov.info'
    end

    SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
      SimpleCov::Formatter::LcovFormatter,
      Coveralls::SimpleCov::Formatter
    ])
  else
    SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
  end

  SimpleCov.start('rails')
end

ci.yml

- name: Coveralls 
  uses: coverallsapp/github-action@master
  with:
    github-tocken: ${{ secrets.GITHUB_TOKEN }}
    path-to-lcov: "./coverage/lcov/lcov.info"

Gemfile

  gem 'simplecov', require: false
  gem 'simplecov-lcov', require: false
  gem 'coveralls_reborn', '~> 0.18.0', require: false

You will need this library as well since the original is unmaintained.

Cheers

@silva96
Copy link

silva96 commented Oct 6, 2020

You don't need a the coveralls nor coverals_reborn gem if using github actions, it picks up the lcov file written by the simplecov gem.

You need to add to your gemfile 2 gems, under the test group

  gem 'simplecov',      require: false
  gem 'simplecov-lcov', require: false

Also create a file called .simplecov in your root dir

and add this

require 'simplecov-lcov'

SimpleCov::Formatter::LcovFormatter.config do |c|
  c.report_with_single_file = true
  c.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
  [
    SimpleCov::Formatter::HTMLFormatter,
    SimpleCov::Formatter::LcovFormatter,
  ]
)
SimpleCov.start('rails')

electrofelix added a commit to vagrant-libvirt/vagrant-libvirt that referenced this issue Feb 20, 2021
Correct the generation of the line coverage following the example at
coverallsapp/github-action#29.
electrofelix added a commit to vagrant-libvirt/vagrant-libvirt that referenced this issue Feb 20, 2021
Migrate to github actions as travis has switched to a process that will
require requesting minutes regularly for open source projects, and
current development is slow enough that this additional overhead is too
much.

Correct the generation of the line coverage following the example at
coverallsapp/github-action#29. Remove dependency on coveralls
gem as no longer needed if using the action.

Patch older versions of simplecov to contain a branch_coverage?
method to ensure working with simplecov-lcov.
nschonni added a commit to nschonni/omniauth that referenced this issue May 30, 2023
The coveralls_reborn mentions that the gem isn't needed for Actions.
Followed setup from coverallsapp/github-action#29 (comment)
nschonni added a commit to nschonni/omniauth that referenced this issue May 30, 2023
The coveralls_reborn mentions that the gem isn't needed for Actions.
Followed setup from coverallsapp/github-action#29 (comment)
nschonni added a commit to nschonni/omniauth that referenced this issue May 30, 2023
The coveralls_reborn mentions that the gem isn't needed for Actions.
Followed setup from coverallsapp/github-action#29 (comment)
nschonni added a commit to nschonni/omniauth that referenced this issue May 31, 2023
The coveralls_reborn mentions that the gem isn't needed for Actions.
Followed setup from coverallsapp/github-action#29 (comment)
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

No branches or pull requests

5 participants