Skip to content

Commit

Permalink
Add test coverage reporting to Sonarcloud (#54)
Browse files Browse the repository at this point in the history
* Add test coverage reporting
  • Loading branch information
danfowler authored Jun 15, 2023
1 parent 67d18e7 commit 6214a20
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Push Test Coverage to SonarCloud

on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Build and test with Rake
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rake test
- run: |
rm -rf vendor
- name: Fix Code Coverage Paths
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage/coverage.json
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions omise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake"
spec.add_development_dependency "pry"
spec.add_development_dependency "minitest", ">= 5.4"
spec.add_development_dependency "simplecov"
end
3 changes: 3 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sonar.projectKey=omise_omise-ruby
sonar.organization=omise
sonar.exclusions=**/test/**
7 changes: 7 additions & 0 deletions test/support.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
require "simplecov"
require "simplecov_json_formatter"
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
SimpleCov.start do
add_filter "test/"
end

require "rubygems"
require "bundler/setup"

Expand Down

0 comments on commit 6214a20

Please sign in to comment.