Skip to content

Commit

Permalink
Integrate coveralls with circleci
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzval Mallepeddi authored and hortongn committed Jul 29, 2020
1 parent bc2e80f commit 5884eb2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 49 deletions.
43 changes: 32 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
version: 2.1
jobs:
build:
docker:
Expand All @@ -13,7 +13,19 @@ jobs:
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
environment:
BUNDLE_PATH: vendor/bundle
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
RAILS_ENV: test
RACK_ENV: test
SPEC_OPTS: --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
WORKING_PATH: /tmp
UPLOAD_PATH: /tmp
CACHE_PATH: /tmp/cache
COVERALLS_PARALLEL: true

parallelism: 4
working_directory: ~/application_portfolio

steps:
Expand Down Expand Up @@ -51,21 +63,30 @@ jobs:
command: |
gem install rubocop
bundle exec rubocop
# run tests!
- run:
name: Run Tests
name: Run rspec in parallel
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
circleci tests split --split-by=timings)"
bundle exec rspec \
--format progress \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
destination: test-results

- store_artifacts:
path: coverage

- deploy:
name: Update Coveralls
command: |
curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_BUILD_NUM&payload[status]=done"
workflows:
version: 2
ci:
jobs:
- build:
name: ruby2-6-5
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service_name: circleci
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gem 'jbuilder', '~> 2.5'
# Use rails-controller-testing for testing a controller
gem 'rails-controller-testing'
# Use coveralls for code-coverage
gem 'coveralls', require: false
gem 'coveralls', '~> 0.8.22', require: false
# Use rubocop for static code analysis
gem 'rubocop'
# Use simplecov to generate the coveralls report in .html format
Expand Down Expand Up @@ -73,6 +73,7 @@ group :development, :test do
# Use factory_bot_rails to generate random test data
gem 'factory_bot_rails'
gem 'rspec-rails', '~>3.8'
gem 'rspec_junit_formatter'
end

group :development do
Expand Down
42 changes: 14 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.6)
coveralls (0.7.1)
multi_json (~> 1.3)
rest-client
simplecov (>= 0.7)
term-ansicolor
thor
coveralls (0.8.23)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
term-ansicolor (~> 1.3)
thor (>= 0.19.4, < 2.0)
tins (~> 1.6)
crass (1.0.6)
csv (3.1.5)
devise (4.7.1)
Expand All @@ -114,8 +114,6 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.3)
docile (1.3.2)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
Expand All @@ -133,9 +131,6 @@ GEM
gritter (1.2.0)
groupdate (5.0.0)
activesupport (>= 5)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
io-like (0.3.1)
Expand All @@ -158,20 +153,15 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
msgpack (1.3.3)
multi_json (1.14.1)
mysql2 (0.5.3)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.0.2)
netrc (0.11.0)
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
Expand Down Expand Up @@ -227,11 +217,6 @@ GEM
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
Expand All @@ -250,6 +235,8 @@ GEM
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.84.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
Expand Down Expand Up @@ -285,10 +272,11 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
simplecov (0.18.5)
simplecov (0.16.1)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -319,9 +307,6 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
warden (1.2.8)
rack (>= 2.0.6)
Expand Down Expand Up @@ -352,7 +337,7 @@ DEPENDENCIES
chartkick (= 3.3.0)
chromedriver-helper
coffee-rails (~> 4.2)
coveralls
coveralls (~> 0.8.22)
csv
devise
dotenv-rails
Expand All @@ -370,6 +355,7 @@ DEPENDENCIES
rb-readline
recaptcha
rspec-rails (~> 3.8)
rspec_junit_formatter
rubocop
sass-rails (~> 5.0)
selenium-webdriver
Expand Down
16 changes: 7 additions & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
#

require 'simplecov'
SimpleCov.start 'rails'

SimpleCov.at_exit do
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
SimpleCov.result.format!
end

# Include coveralls for code-coverage
require 'coveralls'
Coveralls.wear!
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
)
SimpleCov.start('rails')

require 'devise'

Expand Down

0 comments on commit 5884eb2

Please sign in to comment.