Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable coverage in Undercover CI #2536

Merged
merged 4 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/feature-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env:
BUNDLE_PATH_RELATIVE_TO_CWD: true
AVO_LICENSE_KEY: license_123
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: adrianthedev:${{secrets.GH_REGISTRY_AVO_FILTERS_TOKEN}}
COVERAGE: true

jobs:
feature_specs:
Expand Down Expand Up @@ -104,6 +105,11 @@ jobs:
id: run_tests
run: bundle exec rspec spec/features

- uses: actions/upload-artifact@v3
with:
name: coverage_features_${{ matrix.rails }}_ruby_${{ matrix.ruby }}
path: coverage/.resultset.json

- uses: actions/upload-artifact@v3
if: always() && steps.run_tests.outcome == 'failure'
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
POSTGRES_PORT: 5432
BUNDLE_PATH_RELATIVE_TO_CWD: true
AVO_LICENSE_KEY: license_123
COVERAGE: true

jobs:
system_specs:
Expand Down Expand Up @@ -103,6 +104,11 @@ jobs:
id: run_tests
run: bundle exec rspec spec/system

- uses: actions/upload-artifact@v3
with:
name: coverage_system_${{ matrix.rails }}_ruby_${{ matrix.ruby }}
path: coverage/.resultset.json

- uses: actions/upload-artifact@v3
if: always() && steps.run_tests.outcome == 'failure'
with:
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/undercover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Undercover: Merge coverage"
on:
workflow_run:
workflows: ["Feature Tests", "System Tests"]
types:
- completed
jobs:
await-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: ahmadnassri/action-workflow-run-wait@v1
with:
timeout: 600000 # 10 minutes
coverage:
runs-on: ubuntu-latest
needs: [await-tests]
env:
COVERAGE_COMPARE_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
COVERAGE_COMPARE_BRANCH: ${{ github.event.workflow_run.head_branch }}
steps:
- uses: actions/checkout@v3
- run: echo "Merging coverage reports for $COVERAGE_COMPARE_BRANCH @ $COVERAGE_COMPARE_COMMIT_SHA"
- uses: dawidd6/action-download-artifact@v3 # supports downloads between workflows
with:
workflow: feature-tests.yml
workflow_search: true
search_artifacts: true
commit: ${{ env.COVERAGE_COMPARE_COMMIT_SHA }}
name: coverage_features_7.1_ruby_3.3.0
path: coverage_features # creates coverage_features/.resultset.json
- uses: dawidd6/action-download-artifact@v3
with:
workflow: system-tests.yml
workflow_search: true
search_artifacts: true
commit: ${{ env.COVERAGE_COMPARE_COMMIT_SHA }}
name: coverage_system_7.1_ruby_3.3.0
path: coverage_system # creates coverage_system/.resultset.json
- run: |
sudo gem install simplecov simplecov-lcov
ruby scripts/merge_coverage.rb coverage_all.lcov
- run: |
ruby -e "$(curl -s https://undercover-ci.com/uploader.rb)" -- \
--repo avo-hq/avo \
--commit ${{ env.COVERAGE_COMPARE_COMMIT_SHA }}
--lcov coverage_all.lcov
- uses: actions/upload-artifact@v3
with:
name: avo_coverage_merged_lcov
path: coverage_all.lcov
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.50.0)
Expand Down Expand Up @@ -600,6 +601,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_6.1_ruby_3.1.4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.50.0)
Expand Down Expand Up @@ -500,6 +501,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -563,6 +565,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_6.1_ruby_3.2.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_6.1_ruby_3.2.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.49.0)
Expand Down Expand Up @@ -500,6 +501,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -563,6 +565,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_6.1_ruby_3.3.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.50.0)
Expand Down Expand Up @@ -500,6 +501,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -563,6 +565,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7.1_ruby_3.1.4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.50.0)
Expand Down Expand Up @@ -533,6 +534,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -596,6 +598,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7.1_ruby_3.2.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_7.1_ruby_3.2.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.49.0)
Expand Down Expand Up @@ -533,6 +534,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -596,6 +598,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7.1_ruby_3.3.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ group :test do
gem "fuubar"
gem "simplecov", require: false
gem "simplecov-cobertura"
gem "simplecov-lcov"
gem "webmock"
gem "spring-commands-rspec"
gem "launchy", require: false
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ GEM
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
smart_properties (1.17.0)
solargraph (0.50.0)
Expand Down Expand Up @@ -533,6 +534,7 @@ GEM
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-22
arm64-darwin-23
x86_64-linux

Expand Down Expand Up @@ -596,6 +598,7 @@ DEPENDENCIES
rubocop-shopify
simplecov
simplecov-cobertura
simplecov-lcov
solargraph
solargraph-rails
spring
Expand Down
22 changes: 22 additions & 0 deletions scripts/merge_coverage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'simplecov'

Check failure on line 4 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:4:9: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. require 'simplecov' ^^^^^^^^^^^
require 'simplecov-lcov'

Check failure on line 5 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:5:9: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. require 'simplecov-lcov' ^^^^^^^^^^^^^^^^

puts('Merging coverage results...')

Check failure on line 7 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:7:6: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. puts('Merging coverage results...') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

report_path = ARGV[0] || 'coverage.lcov'

Check failure on line 9 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:9:26: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. report_path = ARGV[0] || 'coverage.lcov' ^^^^^^^^^^^^^^^
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov::Formatter::LcovFormatter.config.single_report_path = report_path

SimpleCov.collate(['coverage_features/.resultset.json', 'coverage_system/.resultset.json']) do

Check failure on line 13 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:13:20: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. SimpleCov.collate(['coverage_features/.resultset.json', 'coverage_system/.resultset.json']) do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check failure on line 13 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:13:57: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. SimpleCov.collate(['coverage_features/.resultset.json', 'coverage_system/.resultset.json']) do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
enable_coverage :branch
formatter SimpleCov::Formatter::LcovFormatter
end

if File.size(report_path).zero?
puts('Written report has 0 bytes')

Check failure on line 19 in scripts/merge_coverage.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: scripts/merge_coverage.rb:19:8: C: [Corrected] Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. puts('Written report has 0 bytes') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
exit 1
end
puts("Done! LCOV saved to #{SimpleCov::Formatter::LcovFormatter.config.single_report_path}")
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
add_filter "/spec/support/"
add_filter "/spec/rails_helper"
add_filter "/spec/spec_helper"
enable_coverage(:branch)
end

if ENV["CI"]
Expand Down