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

Re-Add Code Climate #2551

Merged
merged 15 commits into from
Jul 8, 2024
55 changes: 48 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
RAILS_ENV: test
NODE_ENV: test
RACK_ENV: test
COVERAGE: true
CC_TEST_REPORTER_ID: 04daa6564351115dc1515504790cd379ad8dc25e7778f0641e0f8c63185f887c
Copy link
Member Author

@sethherr sethherr Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now required in all builds based on this issue thread

TRANSLATION_BRANCH: main
TZ: /usr/share/zoneinfo/America/Chicago
RETRY_FLAKY: true
Expand Down Expand Up @@ -237,6 +239,12 @@ jobs:
- tmp/cache/assets
- tmp/cache/webpacker

- run:
name: Install Code Climate Test Reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter

- run:
name: Wait for PostgreSQL to start
command: dockerize -wait tcp://localhost:5432 -timeout 1m
Expand All @@ -250,20 +258,50 @@ jobs:
- run:
name: RSpec
command: |
mkdir -p test-results/rspec
RSPEC_CMD="bundle exec rspec --profile 10 --order random --format RspecJunitFormatter --out test-results/rspec/rspec.xml --format progress --color --require spec_helper"
mkdir -p /tmp/test-results/rspec coverage
./cc-test-reporter before-build
RSPEC_CMD="bundle exec rspec --profile 10 --order random --format RspecJunitFormatter --out /tmp/test-results/rspec/rspec.xml --format progress --color --require spec_helper"
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --command="xargs $RSPEC_CMD" --verbose --split-by=timings
- run:
name: Save Code Climate Test Coverage
command: |
./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
- persist_to_workspace:
root: coverage
paths:
- codeclimate.*.json
- run:
name: "Jest: Tests"
command: |
mkdir -p test-results/junit
mkdir -p /tmp/test-results/junit
yarn jest --ci --runInBand --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT: "test-results/junit/js-test-results.xml" # This is the env variable for the old version of jest-junit
JEST_JUNIT_OUTPUT_DIR: "test-results/junit/"

JEST_JUNIT_OUTPUT: "/tmp/test-results/junit/js-test-results.xml" # This is the env variable for the old version of jest-junit
JEST_JUNIT_OUTPUT_DIR: "/tmp/test-results/junit/"
- store_test_results:
path: test-results
path: /tmp/test-results
- store_artifacts:
path: coverage

upload-coverage:
docker:
- image: cimg/ruby:2.7.8-node
environment:
CC_TEST_REPORTER_ID: 04daa6564351115dc1515504790cd379ad8dc25e7778f0641e0f8c63185f887c
working_directory: ~/bikeindex/bike_index
steps:
- attach_workspace:
at: ~/bikeindex/bike_index
- run:
name: Install Code Climate Test Reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
command: |
echo $CIRCLE_NODE_TOTAL
./cc-test-reporter sum-coverage codeclimate.*.json --parts $CIRCLE_NODE_TOTAL
./cc-test-reporter upload-coverage --debug

deploy_production:
machine:
Expand All @@ -281,6 +319,9 @@ workflows:
commit:
jobs:
- build
- upload-coverage:
requires:
- build
- deploy_production:
requires:
- build
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ group :development do
gem "guard", require: false
gem "guard-rspec", require: false
gem "letter_opener"
gem "rerun"
gem "rerun" # restart sidekiq processes in development on app change
gem "terminal-notifier"
gem "annotate" # Annotate models with schema info
end
Expand Down Expand Up @@ -175,9 +175,9 @@ group :test do
gem "factory_bot_rails"
gem "rails-controller-testing"
gem "rspec-sidekiq"
gem "simplecov", require: false
gem "vcr" # Stub external HTTP requests
gem "webmock" # mocking for VCR
gem "rspec-retry", require: false # Retry failures on CI
end

gem "dockerfile-rails", ">= 1.5", group: :development
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ GEM
database_cleaner (1.7.0)
date (3.3.3)
diff-lcs (1.4.4)
docile (1.4.0)
dockerfile-rails (1.5.0)
rails
domain_name (0.5.20190701)
Expand Down Expand Up @@ -665,6 +666,12 @@ GEM
sidekiq-failures (1.0.0)
sidekiq (>= 4.0.0)
simple_oauth (0.3.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sitemap_generator (6.1.2)
builder (~> 3.0)
sixarm_ruby_unaccent (1.2.0)
Expand Down Expand Up @@ -846,6 +853,7 @@ DEPENDENCIES
secure_headers (~> 2.5.0)
sidekiq
sidekiq-failures
simplecov
sitemap_generator (~> 6)
skylight
sprockets (= 4.0.0)
Expand Down
17 changes: 17 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# simplecov must be required before anything else
if ENV["COVERAGE"]
require "simplecov"
require "simplecov_json_formatter"
SimpleCov.start("rails") do
add_filter "/spec/"
add_filter "/config/"
add_filter "/vendor/"

add_group "Serializers", "app/serializers"
add_group "Services", "app/services"
add_group "Uploaders", "app/uploaders"
end

Rails.application.eager_load! if defined?(Rails)
end

require "spec_helper"

# Assign here because only one .env file
Expand Down