I am using bitbucket with pipelines for Ruby On Rails application. My aim is to use the pipeline with parallel steps to run each of the Rspecs in the parallel pipeline. To do that I have added a default step to install the dependencies and then use the parallel steps to run each RSpec like models, controllers, etc, But on researching, it is found that pipelines execute in different containers, so we can't share this in parallel steps. Below are the changes I have done so far.
image: ruby:2.5.7
pipelines:
default:
- step:
name: Docker Build Image
script:
- export DATABASE_URL=<test_db_url>
- apt-get update
- apt-get install libmagic-dev
- gem install bundler
- bundle config set without 'development'
- bundle install
- bundle exec rails db:schema:load RAILS_ENV=test
services:
- redis
- postgres
- parallel:
- step:
name: Model Specs
script:
- bundle exec rspec spec/models --format documentation
services:
- redis
- postgres
- step:
name: Controller Specs
script:
- bundle exec rspec spec/controllers --format documentation
- step:
name: Helper Specs
script:
- bundle exec rspec spec/helpers --format documentation
- step:
name: Job Specs
script:
- bundle exec rspec spec/jobs --format documentation
- step:
name: Lib Specs
script:
- bundle exec rspec spec/lib --format documentation
- step:
name: Services Specs
script:
- bundle exec rspec spec/services --format documentation
- step:
name: Policy Specs
script:
- bundle exec rspec spec/policies --format documentation
definitions:
services:
redis:
image: redis
postgres:
image: postgres:9.5
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
But On executing, it is failed. Do we have a feature like once it is created a build that is generated from the default step, then we can share that build along with these parallel steps?.
I have tried using artifacts
Tried using this link: https://stackoverflow.com/a/52676969/5023291
but running this causes with artifacts causes not working with the initial setup.
image: ruby:2.5.7
pipelines:
default:
- step:
name: Docker Build Image
script:
- export DATABASE_URL=<DB_URL>
- apt-get update
- apt-get install libmagic-dev
- gem install bundler
- bundle config set without 'development'
- bundle install
- bundle exec rails db:schema:load RAILS_ENV=test
- docker save --output test_dummy.tar test_dummy
artifacts:
- test_dummy.tar
services:
- redis
- postgres
- docker
- parallel:
- step:
name: Model Specs
script:
- docker load --input test_dummy.tar
- bundle exec rspec spec/models --format documentation
- step:
name: Controller Specs
script:
- docker load --input test_dummy.tar
- bundle exec rspec spec/controllers --format documentation
definitions:
services:
redis:
image: redis
postgres:
image: postgres:9.5
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
Please help me, if I am missing anything.