circleci-demo-workflows icon indicating copy to clipboard operation
circleci-demo-workflows copied to clipboard

DRY-er config for multiple workflows?

Open bitjson opened this issue 6 years ago • 1 comments

Hi there,

I'm trying to run my tests on multiple versions of Node.js, and I'm noticing how repetitive the config is in this example: https://github.com/CircleCI-Public/circleci-demo-workflows/blob/parallel-jobs/.circleci/config.yml#L8-L34 (Selected: all the lines that are repeated.)

Is there any less repetitive way to define this configuration? Especially for configs with multiple steps, the configuration grows much faster than seems necessary.

Is there some way I could at least define sets of steps and use them? Maybe something like:

version: 2.0

procedures:
  install-and-test:
      - checkout
      - run: bundle install --path vendor/bundle
      - run: bundle exec rake db:create db:schema:load
      - run:
          name: Run tests
          command: rake
jobs:
  "ruby-2.2":
    docker:
      - image: circleci/ruby:2.2-node
      - image: circleci/postgres:9.4.12-alpine
    working_directory: ~/circleci-demo-workflows
    steps:
      - procedure: install-and-test

  "ruby-2.3":
    docker:
      - image: circleci/ruby:2.3-node
      - image: circleci/postgres:9.4.12-alpine
    working_directory: ~/circleci-demo-workflows
    steps:
      - procedure: install-and-test

  "ruby-2.4":
    docker:
      - image: circleci/ruby:2.4-node
      - image: circleci/postgres:9.4.12-alpine
    working_directory: ~/circleci-demo-workflows
    steps:
      - procedure: install-and-test

workflows:
  version: 2
  build:
    jobs:
      - "ruby-2.2"
      - "ruby-2.3"
      - "ruby-2.4"

Thanks!

bitjson avatar Mar 15 '18 23:03 bitjson

See https://github.com/sunpy/sunpy/blob/master/.circleci/config.yml

cclauss avatar Apr 13 '18 14:04 cclauss