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

Add simplecov for formatting and ignoring files for test coverage #2106

Merged
merged 5 commits into from
Mar 2, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
WORKING_PATH: /tmp
UPLOAD_PATH: /tmp
CACHE_PATH: /tmp/cache
TEST_REPORT_PATH: /tmp/test-results
executor:
name: samvera/ruby_fcrepo_solr_redis_postgres
ruby_version: << parameters.ruby_version >>
Expand Down Expand Up @@ -50,41 +51,28 @@ jobs:

- samvera/parallel_rspec

- run:
name: Install JUnit coverage reporter
command: yarn add --dev jest-junit
- run:
name: Run tests with JUnit as reporter
command: yarn test --ci --runInBand --testResultsProcessor="./node_modules/jest-junit-reporter"
environment:
JEST_JUNIT_OUTPUT_DIR: /tmp/test-results
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results

- store_artifacts:
path: tmp/screenshots

- deploy:
command: curl -k https://coveralls.io/webhook?repo_token=${COVERALLS_REPO_TOKEN} -d "payload[build_num]=${CIRCLE_BUILD_NUM}&payload[status]=done"
test:
docker:
- image: cimg/ruby:2.7.2-node
steps:
- checkout

- run:
name: Get yarn version
command: echo $(yarn --version) >> "YARN_VERSION"

- restore_cache:
keys:
- v1-yarn-{{ checksum "yarn.lock" }}-{{ checksum "YARN_VERSION" }}

- run: yarn

- save_cache:
key: v1-yarn-{{ checksum "yarn.lock" }}-{{ checksum "YARN_VERSION" }}
paths:
- ~/project/node_modules

- run:
name: Run jest tests
command: yarn test

workflows:
version: 2
ci:
jobs:
- test:
name: jest-test
- build:
name: ruby2-7-2
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ group :development, :test do
gem 'rspec_junit_formatter'
gem 'selenium-webdriver'
gem 'shoulda-matchers'
gem 'simplecov', require: false
gem 'solr_wrapper', '>= 0.3'
gem 'vcr'
gem 'webdrivers'
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ DEPENDENCIES
selenium-webdriver
shoulda-matchers
sidekiq
simplecov
solr_wrapper (>= 0.3)
spring
spring-watcher-listen (~> 2.0.0)
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"babel-jest": "^23.4.2",
"fstream": "^1.0.12",
"jest": "^23.2",
"jest-junit": "^12.0.0",
"jest-junit-reporter": "^1.1.0",
"jest-serializer-vue": "^2.0.2",
"source-map-support": "^0.5.6",
"vue-jest": "^2.6.0",
Expand All @@ -38,6 +40,7 @@
"roots": [
"app/javascript/test"
],
"testResultsProcessor": "./node_modules/jest-junit-reporter",
"verbose": true,
"moduleFileExtensions": [
"js",
Expand Down
13 changes: 12 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# frozen_string_literal: true

unless ENV['NO_COVERAGE'] == 'true'
require 'simplecov'
require 'coveralls'
Coveralls.wear!('rails')
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
])
SimpleCov.start 'rails' do
# Can filter out files from coverage reports, example below.
# add_filter 'app/controllers/metadata_samples_controller.rb'
add_filter "/test/"
add_filter "/spec/"
add_filter "README"
end
end

# This file is copied to spec/ when you run 'rails generate rspec:install'
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
# config.profile_examples = 10
config.profile_examples = 10

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
Expand Down
24 changes: 23 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5354,6 +5354,23 @@ jest-jasmine2@^23.6.0:
jest-util "^23.4.0"
pretty-format "^23.6.0"

jest-junit-reporter@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/jest-junit-reporter/-/jest-junit-reporter-1.1.0.tgz#88d6006ec13f82df40c47882c8640989cdcb1434"
integrity sha1-iNYAbsE/gt9AxHiCyGQJic3LFDQ=
dependencies:
xml "^1.0.1"

jest-junit@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-12.0.0.tgz#3ebd4a6a84b50c4ab18323a8f7d9cceb9d845df6"
integrity sha512-+8K35LlboWiPuCnXSyiid7rFdxNlpCWWM20WEYe6IZH6psfUWKZmSpSRQ5tk0C0cBeDsvsnIzcef5mYhyJsbug==
dependencies:
mkdirp "^1.0.4"
strip-ansi "^5.2.0"
uuid "^3.3.3"
xml "^1.0.1"

jest-leak-detector@^23.6.0:
version "23.6.0"
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-23.6.0.tgz#e4230fd42cf381a1a1971237ad56897de7e171de"
Expand Down Expand Up @@ -10070,7 +10087,7 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=

uuid@^3.3.2, uuid@^3.4.0:
uuid@^3.3.2, uuid@^3.3.3, uuid@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
Expand Down Expand Up @@ -10545,6 +10562,11 @@ xml-name-validator@^3.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=

xtend@^4.0.0, xtend@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
Expand Down