Skip to content

Commit

Permalink
add code cov integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancyq committed Sep 8, 2024
1 parent 595ecfb commit 384799a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
codecov:
notify:
wait_for_ci: false
require_ci_to_pass: false

coverage:
status:
project:
default:
target: 99%
threshold: 1%
patch:
default:
target: 99%
threshold: 1%

comment:
require_changes: true
31 changes: 31 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Code Coverage
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
codecov:
runs-on: ubuntu-latest
timeout-minutes: 3

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Run Rspec
env:
CODE_COV: true
run: |
bundle exec rake spec
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ gemspec
group :development, :test do
gem "rake", "~> 13.0"
gem "rspec", "~> 3.12"

gem "simplecov", "~> 0.22.0", require: false
gem "simplecov-cobertura", require: false
end

group :development do
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GEM
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.1)
hashdiff (1.1.1)
json (2.7.2)
language_server-protocol (3.17.0.3)
Expand Down Expand Up @@ -58,6 +59,15 @@ GEM
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.13.0)
simplecov_json_formatter (0.1.4)
unicode-display_width (2.5.0)
vcr (6.3.1)
base64
Expand All @@ -80,6 +90,8 @@ DEPENDENCIES
rubocop (~> 1.65)
rubocop-rake
rubocop-rspec
simplecov (~> 0.22.0)
simplecov-cobertura
vcr (~> 6.3)
webmock (~> 3.23)

Expand Down
11 changes: 11 additions & 0 deletions spec/support/simplecov.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

if ENV["CODE_COV"]
require "simplecov"
SimpleCov.start
end

if ENV["CODE_COV"] && ENV["CI"]
require "simplecov-cobertura"
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
end

0 comments on commit 384799a

Please sign in to comment.