Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
circleci 2.0 config.yml
version: 2
jobs:
build:
working_directory: /app
docker:
- image: smarthr/circleci-base
environment:
RAILS_ENV: test
DB_HOST: 127.0.0.1
REDIS_HOST: 127.0.0.1
TZ: /usr/share/zoneinfo/Asia/Tokyo
CIRCLE_TEST_REPORTS: /tmp/test-results
SOME_YOUR_ENVIRONMENTS: some_value
- image: mysql:5.7
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --innodb-file-format=Barracuda
environment:
MYSQL_USER: root
MYSQL_ALLOW_EMPTY_PASSWORD: yes
- image: redis
steps:
- checkout
- restore_cache:
name: Restore bundle cache
keys:
- bundle-{{ checksum "Gemfile.lock" }}
- run:
name: Run bundle install
command: bundle install
- save_cache:
name: Store bundle cache
key: bundle-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Run Rubocop
command: |
test_reports_dir=$CIRCLE_TEST_REPORTS/rubocop
mkdir -p $test_reports_dir
junit_formatter_ruby=$(bundle show rubocop-junit-formatter)/lib/rubocop/formatter/junit_formatter.rb
bundle exec rubocop -L | \
circleci tests split --split-by=timings --timings-type=filename | \
xargs bundle exec rubocop -D -R -r $junit_formatter_ruby -c .rubocop.yml --format RuboCop::Formatter::JUnitFormatter --out $test_reports_dir/rubocop.xml
- restore_cache:
name: Restore npm cache
keys:
- npm-{{ checksum "package.json" }}
- run:
name: Run npm install
command: |
npm cache clean
npm install
- save_cache:
name: Store npm cache
key: npm-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Run Frontend Test
command: |
npm run deploy
.run_frontend_sass_lint.sh
.run_frontend_eslint.sh
.run_frontend_flow.sh
.run_frontend_spec.sh
- run:
name: Create DB
command: |
RAILS_ENV=test bundle exec rake db:create
bundle exec rake db:schema:load
- run:
name: Run Test
command: |
test_reports_dir=$CIRCLE_TEST_REPORTS/rspec
mkdir -p $test_reports_dir
circleci tests glob "spec/**/*_spec.rb" | \
circleci tests split --split-by=timings --timings-type=filename | \
xargs bundle exec rspec --color --format RspecJunitFormatter --out $test_reports_dir/rspec.xml --format progress --require spec_helper --require rails_helper --tag ~type:profiling --profile --
- run:
name: Setup AWS credentials
command: |
mkdir -p ~/.aws
printf "[default]\nregion = ap-northeast-1\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/config
printf "[default]\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/credentials
chmod 600 ~/.aws/*
- deploy:
command: ./deploy.sh
- store_test_results:
path: /tmp/test-results
notify:
webhooks:
- url: YOUR_COVERALLS_WEBHOOK_URL

I was testing your build, with a few variations, and was curious if you had thoughts on https://stackoverflow.com/questions/47826623/getting-sh-12-redis-server-not-found-in-circleci-2-0-using-docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment