.circleci/config.yml
version: 2.1
orbs:
browser-tools: circleci/browser-tools@1.4.6
jobs:
test:
parallelism: 12
# Call bash as interactive login shell to make sure nvm is loaded through .bashrc
shell: /bin/bash -ileo pipefail
resource_class: small
docker:
- image: cimg/ruby:3.2.2-browsers
environment:
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
MOCHA_FILE: /tmp/circleci-test-results/mocha.xml
DATABASE_URL: mysql2://root:very-secret@127.0.0.1/sharetribe_test
NODE_VERSION: 18.16.0
NODE_ENV: test
RAILS_ENV: test
RACK_ENV: test
BUNDLE_PATH: vendor/bundle
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
RUBYOPT: "-W0"
- image: mysql:8.0.35
environment:
MYSQL_ROOT_PASSWORD=very-secret
steps:
- browser-tools/install-chromedriver
# Chrome driver installation leaves a license file in project dir, which
# prevents checkout. The project dir must be empty.
- run:
name: Clean install
command: rm -f LICENSE.chromedriver
- run:
name: Check install
command: |
google-chrome --version
chromedriver --version
- checkout
- restore_cache:
keys:
- bundler-cache-v-8-{{ checksum "Gemfile.lock" }}
- restore_cache:
keys:
- node-cache-v9-{{ checksum "package.json" }}-{{ checksum "client/package-lock.json" }}
- run:
name: install system deps
command: script/ci-install-deps.sh
- run:
name: Update rubygems and bundler
command: sudo gem update --system 3.4.6 --no-document
- run:
name: Configure bundler
command: bundle config set --local without development
- run:
name: bundle install
command: bundle check || bundle install
- run:
name: npm ci
command: npm ci && cd client && npm ci
- save_cache:
key: bundler-cache-v-8-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- ~/.bundle
- save_cache:
key: node-cache-v9-{{ checksum "package.json" }}-{{ checksum "client/package-lock.json" }}
paths:
- ~/.nvm
- ~/.npm
- ~/.bashrc
- client/node_modules
- ./node_modules
- run:
name: prepare
command: script/ci-prepare.sh
- run:
name: Wait for DB
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 1m
- run:
name: db setup
command: bundle exec rake db:create db:structure:load ts:configure ts:index ts:start --trace
- run:
name: rspec tests to run
command: shopt -s globstar && echo $(circleci tests glob spec/**/*_spec.rb | circleci tests split --split-by=timings)
- run:
name: rspec
command: shopt -s globstar && mkdir -p $CIRCLE_TEST_REPORTS/rspec && bundle exec rspec --format progress --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/rspec.xml $(circleci tests glob spec/**/*_spec.rb | circleci tests split --split-by=timings --show-counts)
- run:
name: cucumber tests to run
command: shopt -s globstar && echo $(circleci tests glob features/**/*.feature | circleci tests split --split-by=timings)
- run:
name: cucumber
command: shopt -s globstar && mkdir -p $CIRCLE_TEST_REPORTS/cucumber && bundle exec cucumber -p ci --format junit --out $CIRCLE_TEST_REPORTS/cucumber/junit.xml $(circleci tests glob features/**/*.feature | circleci tests split --split-by=timings --show-counts)
- run:
name: npm test
command: if [[ "$CIRCLE_NODE_INDEX" == "2" || ( "$CIRCLE_NODE_TOTAL" -lt "3" && "$CIRCLE_NODE_INDEX" == "1" ) ]] ; then npm test ; fi
working_directory: client
- store_test_results:
path: /tmp/circleci-test-results
- store_artifacts:
path: /tmp/circleci-test-results
- store_artifacts:
path: ~/project/tmp/capybara
destination: test-screenshots
lint:
parallelism: 2
# Call bash as interactive login shell to make sure nvm is loaded through .bashrc
shell: /bin/bash -ileo pipefail
resource_class: small
docker:
- image: cimg/ruby:3.2.2-browsers
environment:
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
MOCHA_FILE: /tmp/circleci-test-results/mocha.xml
DATABASE_URL: mysql2://root:very-secret@127.0.0.1/sharetribe_test
NODE_VERSION: 18.16.0
NODE_ENV: test
RAILS_ENV: test
RACK_ENV: test
BUNDLE_PATH: vendor/bundle
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
RUBYOPT: "-W0"
steps:
- checkout
- restore_cache:
keys:
- bundler-cache-v-8-{{ checksum "Gemfile.lock" }}
- restore_cache:
keys:
- node-cache-v9-{{ checksum "package.json" }}-{{ checksum "client/package-lock.json" }}
- run:
name: install system deps
command: script/ci-install-deps.sh
- run:
name: Update rubygems and bundler
command: sudo gem update --system 3.4.6 --no-document
- run:
name: Configure bundler
command: bundle config set --local without development
- run:
name: bundle install
command: bundle check || bundle install
- run:
name: npm ci
command: npm ci && cd client && npm ci
- save_cache:
key: bundler-cache-v-8-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- ~/.bundle
- save_cache:
key: node-cache-v9-{{ checksum "package.json" }}-{{ checksum "client/package-lock.json" }}
paths:
- ~/.nvm
- ~/.npm
- ~/.bashrc
- client/node_modules
- ./node_modules
- run:
name: prepare
command: script/ci-prepare.sh
- run:
name: rubocop
command: if [[ "$CIRCLE_NODE_INDEX" == "0" ]] ; then bundle exec rubocop ; fi
- run:
name: npm lint
command: if [[ "$CIRCLE_NODE_INDEX" == "1" || "$CIRCLE_NODE_TOTAL" == "1" ]] ; then npm run lint ; fi
working_directory: client
workflows:
version: 2
test:
jobs:
- test
- lint