2019-08-21 07:29:56 +00:00
|
|
|
# Ruby CircleCI 2.0 configuration file
|
|
|
|
#
|
|
|
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
|
|
|
#
|
|
|
|
version: 2
|
2019-12-02 03:27:11 +00:00
|
|
|
defaults: &defaults
|
|
|
|
working_directory: ~/build
|
|
|
|
docker:
|
|
|
|
# specify the version you desire here
|
2022-05-27 12:03:24 +00:00
|
|
|
- image: cimg/ruby:3.0.4-browsers
|
2019-12-02 03:27:11 +00:00
|
|
|
|
|
|
|
# Specify service dependencies here if necessary
|
|
|
|
# CircleCI maintains a library of pre-built images
|
|
|
|
# documented at https://circleci.com/docs/2.0/circleci-images/
|
2022-03-28 12:45:38 +00:00
|
|
|
- image: cimg/postgres:14.1
|
|
|
|
- image: cimg/redis:6.2.6
|
2019-12-02 03:27:11 +00:00
|
|
|
environment:
|
|
|
|
- CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f
|
2020-06-22 07:49:26 +00:00
|
|
|
- RAILS_LOG_TO_STDOUT: false
|
2019-08-21 07:29:56 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2019-12-02 03:27:11 +00:00
|
|
|
<<: *defaults
|
2019-08-21 07:29:56 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
|
2019-11-25 18:25:18 +00:00
|
|
|
- run:
|
|
|
|
name: Configure Bundler
|
|
|
|
command: |
|
|
|
|
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
|
|
|
source $BASH_ENV
|
|
|
|
gem install bundler
|
|
|
|
|
2019-08-21 07:29:56 +00:00
|
|
|
- run:
|
|
|
|
name: Which bundler?
|
|
|
|
command: bundle -v
|
|
|
|
|
2019-12-02 03:27:11 +00:00
|
|
|
# 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
|
|
|
|
|
2019-08-21 07:29:56 +00:00
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2022-05-24 16:45:57 +00:00
|
|
|
- chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}
|
2019-12-03 13:56:38 +00:00
|
|
|
|
|
|
|
- run: bundle install --frozen --path ~/.bundle
|
2019-08-21 07:29:56 +00:00
|
|
|
- save_cache:
|
|
|
|
paths:
|
2019-12-02 03:27:11 +00:00
|
|
|
- ~/.bundle
|
2022-05-24 16:45:57 +00:00
|
|
|
key: chatwoot-bundle-{{ .Environment.CACHE_VERSION }}-v20220524-{{ checksum "Gemfile.lock" }}
|
2019-12-02 03:27:11 +00:00
|
|
|
|
2019-08-21 07:29:56 +00:00
|
|
|
|
|
|
|
# Only necessary if app uses webpacker or yarn in some other way
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
2021-08-23 16:04:23 +00:00
|
|
|
- chatwoot-yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
2019-08-21 07:29:56 +00:00
|
|
|
- chatwoot-yarn-
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: yarn
|
|
|
|
command: yarn install --cache-folder ~/.cache/yarn
|
|
|
|
|
|
|
|
# Store yarn / webpacker cache
|
|
|
|
- save_cache:
|
2021-08-23 16:04:23 +00:00
|
|
|
key: chatwoot-yarn-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
2019-08-21 07:29:56 +00:00
|
|
|
paths:
|
|
|
|
- ~/.cache/yarn
|
|
|
|
|
2019-12-02 03:27:11 +00:00
|
|
|
- run:
|
|
|
|
name: Download cc-test-reporter
|
|
|
|
command: |
|
2020-06-22 07:49:26 +00:00
|
|
|
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
|
2019-12-02 03:27:11 +00:00
|
|
|
- persist_to_workspace:
|
2020-06-22 07:49:26 +00:00
|
|
|
root: ~/tmp
|
2019-12-02 03:27:11 +00:00
|
|
|
paths:
|
|
|
|
- cc-test-reporter
|
|
|
|
|
2021-11-17 13:25:15 +00:00
|
|
|
# verify swagger specification
|
|
|
|
- run:
|
|
|
|
name: Verify swagger API specification
|
|
|
|
command: |
|
|
|
|
bundle exec rake swagger:build
|
|
|
|
if [[ `git status swagger/swagger.json --porcelain` ]]
|
|
|
|
then
|
|
|
|
echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar > ~/tmp/openapi-generator-cli-5.3.0.jar
|
|
|
|
java -jar ~/tmp/openapi-generator-cli-5.3.0.jar validate -i swagger/swagger.json
|
2019-08-21 07:29:56 +00:00
|
|
|
# Database setup
|
|
|
|
- run: yarn install --check-files
|
|
|
|
- run: bundle exec rake db:create
|
|
|
|
- run: bundle exec rake db:schema:load
|
|
|
|
|
2022-07-15 02:51:59 +00:00
|
|
|
- run:
|
|
|
|
name: Bundle audit
|
|
|
|
command: bundle exec bundle audit update && bundle exec bundle audit check -v
|
2019-12-02 03:27:11 +00:00
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Rubocop
|
|
|
|
command: bundle exec rubocop
|
2022-07-15 02:51:59 +00:00
|
|
|
|
|
|
|
# - run:
|
|
|
|
# name: Brakeman
|
|
|
|
# command: bundle exec brakeman
|
2019-12-02 03:27:11 +00:00
|
|
|
|
|
|
|
- run:
|
|
|
|
name: eslint
|
|
|
|
command: yarn run eslint
|
2019-08-21 07:29:56 +00:00
|
|
|
|
|
|
|
# Run rails tests
|
2020-02-16 11:50:38 +00:00
|
|
|
- run:
|
2019-12-02 03:27:11 +00:00
|
|
|
name: Run backend tests
|
|
|
|
command: |
|
2022-03-28 09:08:07 +00:00
|
|
|
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) --profile=10 --format documentation
|
2020-06-22 07:49:26 +00:00
|
|
|
~/tmp/cc-test-reporter format-coverage -t simplecov -o ~/tmp/codeclimate.backend.json coverage/backend/.resultset.json
|
2019-12-02 03:27:11 +00:00
|
|
|
- persist_to_workspace:
|
2020-06-22 07:49:26 +00:00
|
|
|
root: ~/tmp
|
2020-02-16 11:50:38 +00:00
|
|
|
paths:
|
2019-12-02 03:27:11 +00:00
|
|
|
- codeclimate.backend.json
|
|
|
|
|
2020-02-16 11:50:38 +00:00
|
|
|
- run:
|
2019-12-02 03:27:11 +00:00
|
|
|
name: Run frontend tests
|
|
|
|
command: |
|
|
|
|
yarn test:coverage
|
2020-06-22 07:49:26 +00:00
|
|
|
~/tmp/cc-test-reporter format-coverage -t lcov -o ~/tmp/codeclimate.frontend.json buildreports/lcov.info
|
2019-12-02 03:27:11 +00:00
|
|
|
- persist_to_workspace:
|
2020-06-22 07:49:26 +00:00
|
|
|
root: ~/tmp
|
2020-02-16 11:50:38 +00:00
|
|
|
paths:
|
2019-12-02 03:27:11 +00:00
|
|
|
- codeclimate.frontend.json
|
2019-08-21 07:29:56 +00:00
|
|
|
|
|
|
|
# collect reports
|
|
|
|
- store_test_results:
|
2020-06-22 07:49:26 +00:00
|
|
|
path: ~/tmp/test-results
|
2019-08-21 07:29:56 +00:00
|
|
|
- store_artifacts:
|
2020-06-22 07:49:26 +00:00
|
|
|
path: ~/tmp/test-results
|
2019-08-21 07:29:56 +00:00
|
|
|
destination: test-results
|
2020-06-22 07:49:26 +00:00
|
|
|
- store_artifacts:
|
|
|
|
path: log
|
2019-12-02 03:27:11 +00:00
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Upload coverage results to Code Climate
|
|
|
|
command: |
|
2020-06-22 07:49:26 +00:00
|
|
|
~/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
|