Build config imports: Merging `deploy` array and objects

When working on moving our builds to use the build config imports (see also Experience report: Sharing complex build configuration) I noticed that our deploy sections didn’t merge nicely.

In the shared config I had

deploy:
  provider: script
  script: "travis-deploy ${DOCKER_NAME} ${TAGS}"
  on:
    all_branches: true

In the importing config I had:

import:
- source: shared-config.yml
  mode: deep_merge_prepend

deploy:
- provider: npm
  ...

I somehow expected either both deploys to be present in the merged configuration, or a warning/error that these are not mergeable (note one of them is an array, one is an object!).

What happened instead was that just the npm deployment got used, and the script deployment from the shared configuration was dropped silently.

Fix/Workaround after spotting the difference in types: Convert the shared configuration deploy to use an array as well.

It’s not as clear cut what the “intuitive” way of action would be here.

E.g. if there was another npm provider entry the original, it’s possible that you would rather wish to replace it.

So the best action in my book is to follow Python Zen, koan 12, and produce a warning.

Absolutely agree with you here: I as human can perfectly well fix this issue, but I would certainly appreciate the system to help me by pointing to it.

So, what we are actually lacking here is warnings from the config merge logic!

Since the import feature comes bundled with config validation, it looks like the simplest solution to feed them into the validation results.