Submit Your Ideas

We want to hear from you - vote for the features and improvements you'd most like to see, or submit your own ideas if you don't find them already listed.

Allow bundling several steps, e.g. by supporting nested steps

Carrying over from https://discuss.circleci.com/t/allow-bundling-several-steps-e-g-by-supporting-nested-steps/15339

I just learned that you can use yaml references in your config.yml (which is btw not mentioned anywhere in the docs that I have seen) which I’ve now started using extensively to remove a lot of repetition. All my steps now look something like

 - *cache_restore_node_download
 - *cmd_install_node
 - *cache_save_node_download

with those references defined as:

  - &cache_restore_node_download
    restore_cache:
       name: Restoring cache - node installation package
       key: cache-downloads-node-{{ checksum ".tmp/node_version" }}

  - &cmd_install_node
    run:
      name: Installing node
      command: |
        # [snip] ...commands to download the correct node version if another version was restored above...
        # [snip] ...install node from downloaded archive...

  - &cache_save_node_download
    save_cache:
      name: Saving cache - node installation package
      key: cache-downloads-node-{{ checksum ".tmp/node_version" }}
      paths:
        - ~/.downloads/node/

However, having to do this in every job in a workflow is still a lot of repetition, especially since this is not my only cache and I have to do this several times.

It would make the config much more concise if it was possible to combine all those three steps into one, e.g. with a reference such as:

- &install_node
  - restore_cache: ...
  - run: ...
  - save_cache: ...

so that one of my steps could be:

 - *install_node

This however translates to a nested array, which is not a structure that Circle supports. This could be allowed by Circle if nested steps were flattened to a 1-dimensional array, e.g. if

 - - restore_cache: ...
   - run: ...
   - save_cache: ...

was rewritten as simply

 - restore_cache: ...
 - run: ...
 - save_cache: ...

This is to say, nested steps are just one way of supporting bundling multiple steps into one yaml reference. I’m open to hear about other possibilities of allowing that if somebody has other ideas or already does this in some other way!

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Jun 9 2018
  • Planned
  • Attach files
  • Admin
    Nathan Dintenfass commented
    02 Jul 09:42

    We are working on some config improvements that will address the desire here, I think. See: https://github.com/CircleCI-Public/config-preview-sdk