CircleCI Ideas

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

Carrying over from

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
       name: Restoring cache - node installation package
       key: cache-downloads-node-{{ checksum ".tmp/node_version" }}

  - &cmd_install_node
      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
      name: Saving cache - node installation package
      key: cache-downloads-node-{{ checksum ".tmp/node_version" }}
        - ~/.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
  • Shipped
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    July 02, 2018 09:42

    We are working on some config improvements that will address the desire here, I think. See:

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    January 10, 2019 07:47

    This is now baked in as of version 2.1 of config: