From f479441c4e07934292b31b4313a6a98f3915e518 Mon Sep 17 00:00:00 2001 From: darronschall Date: Fri, 24 May 2024 15:10:43 -0400 Subject: [PATCH 1/3] Add `simplecov` gem for development Don't forget to `rm Gemfile.lock && bundle install` --- protoc-gen-twirp_ruby.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/protoc-gen-twirp_ruby.gemspec b/protoc-gen-twirp_ruby.gemspec index b3533dd..eb0a58a 100644 --- a/protoc-gen-twirp_ruby.gemspec +++ b/protoc-gen-twirp_ruby.gemspec @@ -51,6 +51,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "rspec" spec.add_development_dependency "rspec-file_fixtures" + spec.add_development_dependency "simplecov" spec.add_development_dependency "standard" # For more information and examples about making a new gem, check out our From 757022b644bacb0f89b14ea3841744f340083996 Mon Sep 17 00:00:00 2001 From: darronschall Date: Fri, 24 May 2024 15:28:56 -0400 Subject: [PATCH 2/3] Run specs with coverage when COVERAGE is truthy We default to not running with coverage to speed up the suite. To run with coverage locally, use: ``` COVERAGE=true bundle exec rake spec ``` --- spec/spec_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2aca8e2..ed55f51 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,12 @@ # frozen_string_literal: true +if %w[t true yes y 1].include?(ENV["COVERAGE"]) + require "simplecov" + SimpleCov.start do + enable_coverage :branch + end +end + require "rspec/file_fixtures" require "twirp/protoc_plugin" require "support/matchers/be_empty_scaffolding_matcher" From 67f478acd2aa59f8e1cb87edea06acf006290eed Mon Sep 17 00:00:00 2001 From: darronschall Date: Fri, 24 May 2024 15:31:14 -0400 Subject: [PATCH 3/3] Integrate Code Climate into rspec GitHub Action --- .github/workflows/rspec.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 9849e70..66136dc 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -9,6 +9,10 @@ on: jobs: build: + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + COVERAGE: true + runs-on: ubuntu-latest name: Ruby ${{ matrix.ruby }} strategy: @@ -27,5 +31,16 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true cache-version: 1 + + - name: Setup Code Climate Test Reporter + run: | + sudo curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + sudo chmod +x ./cc-test-reporter + ./cc-test-reporter before-build + - name: Run RSpec run: bundle exec rake spec + + - name: Coverage Report + run: | + ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?