Skip to content

Commit

Permalink
Restoring code coverage reporting for the Coveralls API client (#1870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgriffiniii authored Jul 31, 2024
1 parent 49aeb09 commit 90c4a3c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
21 changes: 9 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ commands:
- run: gem install bundler -v '2.3.22'
- run: cp Gemfile.lock Gemfile.lock.bak
- restore_cache:
key: &gem_key rails_template-cimg-{{ checksum "Gemfile.lock.bak" }}
key: &gem_key pdc_describe-cimg-{{ checksum "Gemfile.lock.bak" }}
- run: bundle config set path './vendor/bundle'
- run: bundle config set --local without production
- run: bundle install --jobs=4 --retry=3
Expand All @@ -15,7 +15,7 @@ commands:
- ./vendor/bundle
- restore_cache:
name: Restore Yarn Package Cache
key: &yarn_key rails_template-yarn-cimg-{{ checksum "yarn.lock" }}
key: &yarn_key pdc_describe-yarn-cimg-{{ checksum "yarn.lock" }}
- run:
name: Install NPM Dependencies via Yarn
command: yarn install --frozen-lockfile
Expand All @@ -28,7 +28,7 @@ orbs:
browser-tools: circleci/[email protected]
jobs:
build:
working_directory: ~/rails_template
working_directory: ~/pdc_describe
docker:
- &ruby_docker
image: cimg/ruby:3.1.0-browsers
Expand All @@ -39,7 +39,7 @@ jobs:
- run: sudo apt update && sudo apt install postgresql-client libmsgpack-dev
- install_dependencies
- persist_to_workspace:
root: &root '~/rails_template'
root: &root '~/pdc_describe'
paths: '*'

rubocop:
Expand All @@ -55,14 +55,14 @@ jobs:

eslint:
# We don't actually need any of the ruby environment to lint JS... but use what we have for now.
working_directory: ~/rails_template
working_directory: ~/pdc_describe
docker:
- image: cimg/ruby:3.1.0-browsers
environment:
RAILS_ENV: test
steps:
- attach_workspace:
at: '~/rails_template'
at: '~/pdc_describe'
- install_dependencies
- run:
name: Run eslint
Expand All @@ -76,7 +76,7 @@ jobs:
- *ruby_docker
- image: postgres:15-alpine
environment:
POSTGRES_USER: rails_template_user
POSTGRES_USER: pdc_describe_user
POSTGRES_DB: test_db
POSTGRES_HOST_AUTH_METHOD: trust
steps:
Expand All @@ -86,17 +86,14 @@ jobs:
- run:
name: Wait for PostgreSQL
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run: bundle exec rake db:create
- run: bundle exec rake db:migrate
- run: bundle exec rake db:create RAILS_ENV=test
- run: bundle exec rake db:migrate RAILS_ENV=test
- run:
name: Run Rspec
command: COVERALLS_REPO_TOKEN=$COVERALLS_REPO_TOKEN bundle exec rspec spec
- store_artifacts:
path:
~/rails_template/coverage
~/rails_template/tmp/capybara
~/rails_template/tmp/screenshots
~/pdc_describe/coverage

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ group :development, :test do
gem "bcrypt_pbkdf"
gem "bixby"
gem "byebug"
gem "coveralls_reborn", "~> 0.28"
gem "ed25519"
gem "equivalent-xml", "~> 0.6.0"
gem "pry-byebug"
Expand All @@ -92,7 +93,6 @@ end
group :test do
gem "axe-core-rspec"
gem "capybara"
gem "coveralls_reborn", require: false
gem "database_cleaner-active_record"
gem "factory_bot_rails", require: false
gem "ffaker"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ DEPENDENCIES
capistrano-passenger
capistrano-rails (~> 1.4)
capybara
coveralls_reborn
coveralls_reborn (~> 0.28)
database_cleaner-active_record
datacite!
datacite-mapping
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ development:
test:
<<: *default
database: test_db
username: <%= ENV["lando_database_creds_user"] || "rails_template_user" %>
username: <%= ENV["lando_database_creds_user"] || "pdc_describe_user" %>

staging: &staging
adapter: postgresql
Expand Down
21 changes: 13 additions & 8 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'

require "coveralls"
Coveralls.wear!("rails")

require "spec_helper"

ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
# Add additional requires below this line. Rails is not loaded until this point!

require "simplecov"
require "simplecov_json_formatter"
SimpleCov.start "rails" do
multi = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::SimpleFormatter,
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::JSONFormatter
SimpleCov::Formatter::JSONFormatter,
Coveralls::SimpleCov::Formatter
])
formatter(multi)
end

require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
# Add additional requires below this line. Rails is not loaded until this point!

require "rspec/rails"
require "axe-rspec"
require "database_cleaner/active_record"
Expand Down
3 changes: 0 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

require "coveralls"
Coveralls.wear!("rails")

require "factory_bot"
FactoryBot.find_definitions

Expand Down

0 comments on commit 90c4a3c

Please sign in to comment.