Build config imports , deep merge

I am looking into the use of the new build config imports feature

I have a github repo from which I have raised a PR to import a build configuration.

However although I find that the new modes deep_merge_append and deep_merge_prepend work. The deep_merge does not work. It does not overwrite the existing array.

I am attempting to replace the first script array with the second, but deep_merge keeps the script array from the first import.

This is the change

The view config

shows that the merge_deep is not working as expected

I am importing

language: node_js
  - "12"
  - "10"
  - "8"
  - 'nvm install-latest-npm'
  - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
sudo: false
  - TEST=true
  fast_finish: true

and then merging

  - npm run lint
  - npm run test
  - npm run build

with merge_deep

but the result is still

- 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'

travis build results

1 Like

Thanks for the detailled report, @ghinks!

It seems we might have to improve our documentation here.

This config:

  - source: ljharb/travis-ci:node/majors/LTS-active.yml
  - source: .other_travis_configs.yml

will first merge your .travis.yml contents into LTS-active.yml (i.e. things in the .travis.yml file “win”, if the merge mode deep_merge would be used).

The result of that will then be merged into .other_travis_configs.yml (again, things in the result of the previous merge win over what’s in this one, as you specified deep_merge here).

The reasoning behind this is that in many cases, when you import something to your .travis.yml file, you want to be able to overwrite or customize that imported config with config in your .travis.yml file.

I believe you can achieve what you’re after by either moving

  - npm run lint
  - npm run test
  - npm run build

to your .travis.yml file, and specifying mode: deep_merge on the LTS-active.yml import (discarding your second import).

Or you could switch around the order of your two imports.

Is there any reason you want to keep the overwriting scripts in a second import?

Thank you @svenfuchs looking into this now as thanks giving is over in the US
My reading was exactly the opposite of what was happening. Just did a build and all
is good now that I understand the order of merging.