CI YAML includes do not update Anchored References

Description

Anchors in included templates don't override/evaluate from the template that is including.

Example Template(template.yml):

stages: 
- deploy 

.dedicated-runner: &dedicated-runner 
  retry: 1 
  tags: []

test:
  stage: deploy
  script: 
    - echo 'hi'
  <<: *dedicated-runner 

ex: .gitlab-ci.yml

include: 'template.yml'

.dedicated-runner: &dedicated-runner 
  retry: 1
  tags: 
    - tags 

The .dedicated-runner anchor will not apply in the template's test job. So for this example, any runner (ignoring the tags) will pick up the job.

A potential workaround is to include/override the job entirely. But this defeats the purpose of reducing duplication.

test:
  stage: deploy
  script: 
    - echo 'hi'
  <<: *dedicated-runner 

Links / references

https://docs.gitlab.com/ee/ci/yaml/#include

Since GitLab 10.8 we are now recursively merging the files defined in include with those in .gitlab-ci.yml. Files defined by include are always evaluated first and recursively merged with the content of .gitlab-ci.yml

It seems like this may be expected behavior and we may just need additional docs to clarify.

Internal ZD: https://gitlab.zendesk.com/agent/tickets/96577