Skip to content

Latest commit

 

History

History
88 lines (56 loc) · 3.4 KB

README.md

File metadata and controls

88 lines (56 loc) · 3.4 KB

SimpleCov::Buildkite

Gem Version Build Status

Generate Buildkite annotations from your SimpleCov coverage reports when running your build on Buildkite.

Installation

Add this line to your application's Gemfile, after simplecov:

gem "simplecov"
gem "simplecov-buildkite"

And then execute:

$ bundle

Or install it yourself as:

$ gem install simplecov-buildkite

Usage

Use it alongside your favourite formatter. For example, in Rails with RSpec, add it in your spec_helper.rb like this:

# spec/spec_helper.rb

require "simplecov"
require "simplecov-buildkite"

SimpleCov.start "rails" do
  load_profile "buildkite"

  formatter SimpleCov::Formatter::MultiFormatter.new([
    SimpleCov::Formatter::HTMLFormatter,
    SimpleCov::Buildkite::AnnotationFormatter,
  ])
end

When run on Buildkite with the "buildkite" profile enabled, this will also output a pretty Buildkite annotation, with coverage change breakdowns for the current PR or branch and commit:

Buildkite build showing a SimpleCov report in a Buildkite annotation

You can customize the title and annotation context using environment variables in your Pipeline. You can provide multiple coverage reports for a single build by providing distinct values for the annotation context.

steps:
- command: bin/rails engine1:spec
  env:
    SIMPLECOV_BUILDKITE_TITLE: "Engine 1 Coverage"
    SIMPLECOV_BUILDKITE_CONTEXT: "engine-1-coverage"

- command: bin/rails engine2:spec
  env:
    SIMPLECOV_BUILDKITE_TITLE: "Engine 2 Coverage"
    SIMPLECOV_BUILDKITE_CONTEXT: "engine-2-coverage"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/simplecov-buildkite. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SimpleCov::Buildkite project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.