-
-
Save kofronpi/816ad8611cbad06d459f0680806ec0c1 to your computer and use it in GitHub Desktop.
config.yml circleci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaults: &defaults | |
working_directory: ~/circleci | |
steps: | |
- checkout | |
- run: | |
name: install dockerize | |
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | |
environment: | |
DOCKERIZE_VERSION: v0.3.0 | |
- run: | |
name: Wait for db | |
command: dockerize -wait tcp://localhost:5432 -timeout 1m | |
- run: | |
name: install postgresql-client and dependencies | |
command: | | |
if [ -z "$CEDAR" ] | |
then | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list | |
sudo apt-get update; sudo apt-get install cmake; sudo apt-get install libffi-dev; sudo apt-get install postgresql-client-12 | |
else | |
/buildpack/bin/compile /app /tmp | |
fi | |
# Restore bundle cache | |
- restore_cache: | |
keys: | |
- roar-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | |
- roar-{{ .Branch }} | |
- roar | |
# Bundle install dependencies | |
- run: | |
name: install gems with bundler | |
command: bundle config set deployment 'true' && bundle config set path 'vendor/bundle' && bundle config set without 'development' && bundle install --retry=3 --jobs=3 | |
# Store bundle cache | |
- save_cache: | |
key: roar-{{ .Branch }}-{{ checksum "Gemfile.lock" }} | |
paths: | |
- vendor/bundle | |
- save_cache: | |
key: roar-{{ .Branch }} | |
paths: | |
- vendor/bundle | |
- save_cache: | |
key: roar | |
paths: | |
- vendor/bundle | |
# Database setup | |
- run: | |
name: Set up database | |
environment: | |
- RAILS_ENV: test | |
- USERNAME_DB: docker | |
- PASSWORD_DB: docker | |
- PORT_DB: 5432 | |
- HOST_DB: 127.0.0.1 | |
command: bundle exec rails db:create && bundle exec rails db:migrate | |
# Run rspec in parallel | |
- run: | |
name: 'Run specs' | |
environment: | |
- RAILS_ENV: test | |
- RACK_ENV: test | |
- USERNAME_DB: docker | |
- PASSWORD_DB: docker | |
- PORT_DB: 5432 | |
- HOST_DB: 127.0.0.1 | |
- HOST_URL: 'localhost' | |
command: | | |
bin/rails test && bundle exec rspec --profile 10 \ | |
--format progress \ | |
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) | |
# Save artifacts | |
- type: store_test_results | |
path: /tmp/test-results | |
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: circleci/ruby:2.7.4-node | |
auth: | |
username: ###### | |
password: $DOCKERHUB_PASSWORD | |
environment: | |
RAILS_ENV: test | |
RACK_ENV: test | |
- image: circleci/postgres:12.8-ram | |
auth: | |
username: ###### | |
password: $DOCKERHUB_PASSWORD # or project environment variable reference | |
environment: | |
POSTGRES_USER: docker | |
POSTGRES_PASSWORD: docker | |
<<: *defaults | |
workflows: | |
version: 2 | |
pre_prod: | |
jobs: | |
- build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment