Skip to content

Commit

Permalink
Merge pull request #1303 from puppetlabs/CAT-1618-add_code_cov
Browse files Browse the repository at this point in the history
(CAT-1618) - Add Code Coverage to CI
  • Loading branch information
david22swan authored Jan 15, 2024
2 parents 001f624 + 7c9591e commit 10e10cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- "main"
workflow_dispatch:

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:

spec:
Expand All @@ -19,6 +22,7 @@ jobs:
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
rake_task: 'spec:coverage'
ruby_version: ${{ matrix.ruby_version }}

acceptance:
Expand Down
18 changes: 7 additions & 11 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
if ENV.fetch('COVERAGE', nil) == 'yes'
require 'codecov'
require 'simplecov'
require 'simplecov-console'

SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Console,
SimpleCov::Formatter::Codecov
SimpleCov::Formatter::Console
]

if ENV['CI'] == 'true'
require 'codecov'
SimpleCov.formatters << SimpleCov::Formatter::Codecov
end

SimpleCov.start do
track_files 'lib/**/*.rb'

Expand All @@ -19,14 +23,6 @@
add_filter '/.vendor'
add_filter '/docs'
add_filter '/lib/pdk/version.rb'

# do not track gitignored files
# this adds about 4 seconds to the coverage check
# this could definitely be optimized
add_filter do |f|
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
system("git check-ignore --quiet #{f.filename}")
end
end
end

Expand Down

0 comments on commit 10e10cb

Please sign in to comment.