@@ -3,19 +3,22 @@
|
|||||||
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
||||||
#
|
#
|
||||||
version: 2
|
version: 2
|
||||||
|
defaults: &defaults
|
||||||
|
working_directory: ~/build
|
||||||
|
docker:
|
||||||
|
# specify the version you desire here
|
||||||
|
- image: circleci/ruby:2.6.5-node-browsers
|
||||||
|
|
||||||
|
# Specify service dependencies here if necessary
|
||||||
|
# CircleCI maintains a library of pre-built images
|
||||||
|
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||||
|
- image: circleci/postgres:9.4
|
||||||
|
environment:
|
||||||
|
- CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
docker:
|
<<: *defaults
|
||||||
# specify the version you desire here
|
|
||||||
- image: circleci/ruby:2.6.5-node-browsers
|
|
||||||
|
|
||||||
# Specify service dependencies here if necessary
|
|
||||||
# CircleCI maintains a library of pre-built images
|
|
||||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
|
||||||
- image: circleci/postgres:9.4
|
|
||||||
|
|
||||||
working_directory: ~/build
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
|
||||||
@@ -30,29 +33,22 @@ jobs:
|
|||||||
name: Which bundler?
|
name: Which bundler?
|
||||||
command: bundle -v
|
command: bundle -v
|
||||||
|
|
||||||
# Restore bundle cache
|
# Run bundler
|
||||||
|
# Load installed gems from cache if possible, bundle install then save cache
|
||||||
|
# Multiple caches are used to increase the chance of a cache hit
|
||||||
|
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
|
# when lock file changes, use increasingly general patterns to restore cache
|
||||||
- chatwoot-bundle-v2-
|
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
||||||
|
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
|
||||||
- run:
|
- v1-gem-cache-{{ arch }}-
|
||||||
name: Bundle Install
|
- run: bundle install && bundle clean
|
||||||
command: bundle check || bundle install
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Bundle audit
|
|
||||||
command: bundle exec bundle audit update && bundle exec bundle audit check -v
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: Rubocop
|
|
||||||
command: bundle exec rubocop
|
|
||||||
|
|
||||||
# Store bundle cache
|
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }}
|
|
||||||
paths:
|
paths:
|
||||||
- vendor/bundle
|
- ~/.bundle
|
||||||
|
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
|
||||||
|
|
||||||
|
|
||||||
# Only necessary if app uses webpacker or yarn in some other way
|
# Only necessary if app uses webpacker or yarn in some other way
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
@@ -64,30 +60,60 @@ jobs:
|
|||||||
name: yarn
|
name: yarn
|
||||||
command: yarn install --cache-folder ~/.cache/yarn
|
command: yarn install --cache-folder ~/.cache/yarn
|
||||||
|
|
||||||
- run:
|
|
||||||
name: eslint
|
|
||||||
command: yarn run eslint
|
|
||||||
|
|
||||||
- run:
|
|
||||||
name: test
|
|
||||||
command: yarn test
|
|
||||||
|
|
||||||
# Store yarn / webpacker cache
|
# Store yarn / webpacker cache
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: chatwoot-yarn-{{ checksum "yarn.lock" }}
|
key: chatwoot-yarn-{{ checksum "yarn.lock" }}
|
||||||
paths:
|
paths:
|
||||||
- ~/.cache/yarn
|
- ~/.cache/yarn
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Download cc-test-reporter
|
||||||
|
command: |
|
||||||
|
mkdir -p tmp/
|
||||||
|
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
||||||
|
chmod +x ./tmp/cc-test-reporter
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: tmp
|
||||||
|
paths:
|
||||||
|
- cc-test-reporter
|
||||||
|
|
||||||
# Database setup
|
# Database setup
|
||||||
- run: yarn install --check-files
|
- run: yarn install --check-files
|
||||||
- run: bundle exec rake db:create
|
- run: bundle exec rake db:create
|
||||||
- run: bundle exec rake db:schema:load
|
- run: bundle exec rake db:schema:load
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Bundle audit
|
||||||
|
command: bundle exec bundle audit update && bundle exec bundle audit check -v
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Rubocop
|
||||||
|
command: bundle exec rubocop
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: eslint
|
||||||
|
command: yarn run eslint
|
||||||
|
|
||||||
# Run rails tests
|
# Run rails tests
|
||||||
- type: shell
|
- run:
|
||||||
command: |
|
name: Run backend tests
|
||||||
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
command: |
|
||||||
|
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
||||||
|
./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.backend.json coverage/backend/.resultset.json
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: tmp
|
||||||
|
paths:
|
||||||
|
- codeclimate.backend.json
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Run frontend tests
|
||||||
|
command: |
|
||||||
|
yarn test:coverage
|
||||||
|
./tmp/cc-test-reporter format-coverage -t lcov -o tmp/codeclimate.frontend.json buildreports/lcov.info
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: tmp
|
||||||
|
paths:
|
||||||
|
- codeclimate.frontend.json
|
||||||
|
|
||||||
# collect reports
|
# collect reports
|
||||||
- store_test_results:
|
- store_test_results:
|
||||||
@@ -95,3 +121,9 @@ jobs:
|
|||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: /tmp/test-results
|
path: /tmp/test-results
|
||||||
destination: test-results
|
destination: test-results
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Upload coverage results to Code Climate
|
||||||
|
command: |
|
||||||
|
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 2 -o tmp/codeclimate.total.json
|
||||||
|
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json
|
||||||
1
Gemfile
1
Gemfile
@@ -81,6 +81,7 @@ group :test do
|
|||||||
gem 'action-cable-testing'
|
gem 'action-cable-testing'
|
||||||
gem 'mock_redis'
|
gem 'mock_redis'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
gem 'simplecov', require: false
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ GEM
|
|||||||
devise (> 3.5.2, < 5)
|
devise (> 3.5.2, < 5)
|
||||||
rails (>= 4.2.0, < 6.1)
|
rails (>= 4.2.0, < 6.1)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
|
docile (1.3.2)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.7.5)
|
dotenv (2.7.5)
|
||||||
@@ -361,6 +362,11 @@ GEM
|
|||||||
rack-protection (>= 2.0.0)
|
rack-protection (>= 2.0.0)
|
||||||
redis (>= 4.1.0)
|
redis (>= 4.1.0)
|
||||||
simple_oauth (0.3.1)
|
simple_oauth (0.3.1)
|
||||||
|
simplecov (0.17.1)
|
||||||
|
docile (~> 1.1)
|
||||||
|
json (>= 1.8, < 3)
|
||||||
|
simplecov-html (~> 0.10.0)
|
||||||
|
simplecov-html (0.10.2)
|
||||||
spring (2.1.0)
|
spring (2.1.0)
|
||||||
spring-watcher-listen (2.0.1)
|
spring-watcher-listen (2.0.1)
|
||||||
listen (>= 2.7, < 4.0)
|
listen (>= 2.7, < 4.0)
|
||||||
@@ -481,6 +487,7 @@ DEPENDENCIES
|
|||||||
sentry-raven
|
sentry-raven
|
||||||
shoulda-matchers
|
shoulda-matchers
|
||||||
sidekiq
|
sidekiq
|
||||||
|
simplecov
|
||||||
spring
|
spring
|
||||||
spring-watcher-listen
|
spring-watcher-listen
|
||||||
telegram-bot-ruby
|
telegram-bot-ruby
|
||||||
|
|||||||
@@ -88,6 +88,10 @@
|
|||||||
"pre-commit": "lint-staged"
|
"pre-commit": "lint-staged"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"jest": {
|
||||||
|
"collectCoverage": true,
|
||||||
|
"coverageReporters": ["lcov", "text"]
|
||||||
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,vue}": [
|
"*.{js,vue}": [
|
||||||
"eslint --fix",
|
"eslint --fix",
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
require 'simplecov'
|
||||||
|
SimpleCov.start 'rails'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.expect_with :rspec do |expectations|
|
config.expect_with :rspec do |expectations|
|
||||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
ENV['RAILS_ENV'] ||= 'test'
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
require 'simplecov'
|
||||||
|
SimpleCov.start 'rails'
|
||||||
|
|
||||||
require File.expand_path('../config/environment', __dir__)
|
require File.expand_path('../config/environment', __dir__)
|
||||||
require 'rails/test_help'
|
require 'rails/test_help'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user